mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
2174 Commits
libpng-1.6
...
v1.6.41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba980b8f0c | ||
|
|
27e548af25 | ||
|
|
92b2128a75 | ||
|
|
6159bad8a9 | ||
|
|
3285bf0d4c | ||
|
|
4edbb4da81 | ||
|
|
9a774b9156 | ||
|
|
671661849a | ||
|
|
438a518611 | ||
|
|
8fb49b8b94 | ||
|
|
144b348e07 | ||
|
|
1a0d7a7481 | ||
|
|
866fdf6f8f | ||
|
|
6f8257e437 | ||
|
|
269b753496 | ||
|
|
2b814cde29 | ||
|
|
893b8113f0 | ||
|
|
7ec2bd28c7 | ||
|
|
70d10da35c | ||
|
|
064f992187 | ||
|
|
46f1106a3f | ||
|
|
a7fe3414e5 | ||
|
|
ce4b632dd7 | ||
|
|
6b0d1bd75b | ||
|
|
2a4f0f5aee | ||
|
|
7dacc4d5aa | ||
|
|
da109d3e6e | ||
|
|
f9348b77da | ||
|
|
2ea11e2235 | ||
|
|
b60316f4ee | ||
|
|
050ce505e4 | ||
|
|
2a23247420 | ||
|
|
6b241f3786 | ||
|
|
b3521c60af | ||
|
|
6beae586d6 | ||
|
|
bdbbcaa457 | ||
|
|
abb8d4a71f | ||
|
|
c993ae4c67 | ||
|
|
6abf8c1e91 | ||
|
|
0dfe422e9f | ||
|
|
71b9b5e16e | ||
|
|
9f9f8d8e63 | ||
|
|
437b24a958 | ||
|
|
2ed5a70bca | ||
|
|
85f866dea3 | ||
|
|
2fff013a69 | ||
|
|
acfd50ae0b | ||
|
|
8fc13a8704 | ||
|
|
1460b3ce78 | ||
|
|
e1088f99d4 | ||
|
|
d65b3ebf00 | ||
|
|
a3d1a35b98 | ||
|
|
9c1dc4d13d | ||
|
|
e755fb79ba | ||
|
|
f79c85e22d | ||
|
|
53d2188fa5 | ||
|
|
f2294569cf | ||
|
|
1547b335e4 | ||
|
|
b2ef6edbe8 | ||
|
|
5a6ea1822b | ||
|
|
22ad62c25e | ||
|
|
71475b064f | ||
|
|
ee9d6d7bf2 | ||
|
|
f8e5fa92b0 | ||
|
|
c81516e943 | ||
|
|
0b7bc40de1 | ||
|
|
82414985c1 | ||
|
|
c0616f1017 | ||
|
|
c741d1e392 | ||
|
|
ad9e42a877 | ||
|
|
d7f77bf271 | ||
|
|
f135775ad4 | ||
|
|
afc6c595bf | ||
|
|
e6c5bf46c4 | ||
|
|
8be5c147d5 | ||
|
|
f7abe3c419 | ||
|
|
82097c2108 | ||
|
|
e519af8b49 | ||
|
|
efc96c9d59 | ||
|
|
aab24fa1b3 | ||
|
|
efa9c2e920 | ||
|
|
c22ef3b2e3 | ||
|
|
66fede80d2 | ||
|
|
59fa76e164 | ||
|
|
70fda1837d | ||
|
|
aeb26da4cb | ||
|
|
cd0ea2a7f5 | ||
|
|
9923515ff4 | ||
|
|
61bfdb0cb0 | ||
|
|
9db8cff6ef | ||
|
|
b445aade83 | ||
|
|
3c152a8ef7 | ||
|
|
5a0b7e9c29 | ||
|
|
b126f80710 | ||
|
|
3c761b5135 | ||
|
|
07b8803110 | ||
|
|
32f465a66b | ||
|
|
074e2eaab0 | ||
|
|
790fef342b | ||
|
|
8a5732fcb3 | ||
|
|
77c3a39299 | ||
|
|
8cfdb5436d | ||
|
|
f6036c0aeb | ||
|
|
689e06516b | ||
|
|
33de006e12 | ||
|
|
9b5488054b | ||
|
|
04c016d79f | ||
|
|
b8ca9108ac | ||
|
|
e56f79c0c6 | ||
|
|
12222e6fbd | ||
|
|
9b65ad49d3 | ||
|
|
3f991d5092 | ||
|
|
b422bc1181 | ||
|
|
6fc5119423 | ||
|
|
0a158f3506 | ||
|
|
50d7a85154 | ||
|
|
2733482d8e | ||
|
|
3d57708c91 | ||
|
|
abccfd7968 | ||
|
|
823ef44f01 | ||
|
|
d72cda543c | ||
|
|
3c67eeca51 | ||
|
|
b60656ecdc | ||
|
|
c64655d058 | ||
|
|
8b7b99c1db | ||
|
|
62c027d4df | ||
|
|
e9e9801a84 | ||
|
|
0c2388cdae | ||
|
|
9cb84c4cb9 | ||
|
|
8c542ad9df | ||
|
|
2abaf81e0f | ||
|
|
ad0245bb96 | ||
|
|
1f974dd2a9 | ||
|
|
3ec225dd41 | ||
|
|
36bd1bbd54 | ||
|
|
0406deb1ca | ||
|
|
5f5f98a1a9 | ||
|
|
f10c6bb603 | ||
|
|
f16427e58e | ||
|
|
6aff792b66 | ||
|
|
ed8840a36f | ||
|
|
efdb24e54b | ||
|
|
1f20bc1e85 | ||
|
|
bbab57105b | ||
|
|
a1a81cc2ac | ||
|
|
c3a1d8424c | ||
|
|
eda0f47f46 | ||
|
|
3848c73ab4 | ||
|
|
dd8db8105c | ||
|
|
763c77e628 | ||
|
|
840af2eda6 | ||
|
|
8a354b41e9 | ||
|
|
0fe598d2f6 | ||
|
|
cbf8c64b58 | ||
|
|
6a42bc1c8e | ||
|
|
9e32b6f1ad | ||
|
|
cc0e959722 | ||
|
|
403422674d | ||
|
|
bfb0abe4d9 | ||
|
|
081e6751ab | ||
|
|
103f8346e3 | ||
|
|
723b2d9f2e | ||
|
|
b7ea74c97d | ||
|
|
8c3fdb0ac1 | ||
|
|
a37d483651 | ||
|
|
3796518809 | ||
|
|
8ca01083d6 | ||
|
|
cd03aaf7bf | ||
|
|
c4bd411c35 | ||
|
|
2224c8ea7b | ||
|
|
e2bb5e7512 | ||
|
|
d6e13b2acd | ||
|
|
c2e2cd2ec5 | ||
|
|
c3f209178b | ||
|
|
dbe3e0c43e | ||
|
|
2f753e260c | ||
|
|
f5d5f5ae0e | ||
|
|
3676fd324a | ||
|
|
28c0f8895e | ||
|
|
87378bc21d | ||
|
|
6c6f7d105a | ||
|
|
6842c58adc | ||
|
|
a6fc80300f | ||
|
|
5e8b45c436 | ||
|
|
6dd99ca9c8 | ||
|
|
52ee167644 | ||
|
|
eb6767273a | ||
|
|
9f734b13f4 | ||
|
|
3cec1a16f5 | ||
|
|
50bd1abdb1 | ||
|
|
2dd5630eae | ||
|
|
b9155ce3fd | ||
|
|
2c0aee56a0 | ||
|
|
301f7a1429 | ||
|
|
386707c6d1 | ||
|
|
216387f6f7 | ||
|
|
b9e811fa99 | ||
|
|
cdbb8ec7aa | ||
|
|
72fa126446 | ||
|
|
5df8e982e2 | ||
|
|
a40189cf88 | ||
|
|
8da8257d0b | ||
|
|
27e8b99287 | ||
|
|
62a56d4fcc | ||
|
|
3342fafa60 | ||
|
|
3f0f1d5579 | ||
|
|
dcefbc7dcd | ||
|
|
1f0221fad7 | ||
|
|
a627bd26a3 | ||
|
|
82ae623ec9 | ||
|
|
9c0d5c77bf | ||
|
|
8439534daa | ||
|
|
70d122aac4 | ||
|
|
0a882b5787 | ||
|
|
fef895aa28 | ||
|
|
43b4141839 | ||
|
|
6a94d14567 | ||
|
|
0e13545712 | ||
|
|
eddf902320 | ||
|
|
85acd919b9 | ||
|
|
e79085a172 | ||
|
|
81a65de25d | ||
|
|
702a07e716 | ||
|
|
7b2224cb6e | ||
|
|
ee7967eea4 | ||
|
|
a54a0562c5 | ||
|
|
94429a335b | ||
|
|
1ceaa83a84 | ||
|
|
b66ed71131 | ||
|
|
7734cda20c | ||
|
|
2fc5ddff18 | ||
|
|
8033c96f32 | ||
|
|
d3d1baadb4 | ||
|
|
a294c1bcb6 | ||
|
|
ceb327789b | ||
|
|
1ef8882814 | ||
|
|
58eedced25 | ||
|
|
1d89a5db66 | ||
|
|
43446b735d | ||
|
|
6c059f8f5b | ||
|
|
f5d48df418 | ||
|
|
9730362202 | ||
|
|
7cb7afb43d | ||
|
|
1bd4214a42 | ||
|
|
6d55a14c58 | ||
|
|
8440326590 | ||
|
|
b729fff4a3 | ||
|
|
c36c09f004 | ||
|
|
a873893279 | ||
|
|
47f18784e4 | ||
|
|
d4fb621429 | ||
|
|
fb6312a9f9 | ||
|
|
ddc842bf06 | ||
|
|
46924bd877 | ||
|
|
8da397423e | ||
|
|
c17d164b44 | ||
|
|
46aedd8961 | ||
|
|
2471434d29 | ||
|
|
8a05766cb7 | ||
|
|
a74aa9a002 | ||
|
|
916117d970 | ||
|
|
7784cd3f6f | ||
|
|
cde1e1fe79 | ||
|
|
0e06b5948c | ||
|
|
3fecfeada1 | ||
|
|
140f3aa280 | ||
|
|
eb91c0e4ed | ||
|
|
d5e4915ebe | ||
|
|
fe669f6f38 | ||
|
|
84e6e35675 | ||
|
|
28d0ee757d | ||
|
|
f07b985ddb | ||
|
|
d532334ef5 | ||
|
|
7292c861b1 | ||
|
|
fc32eb1662 | ||
|
|
7ca2f0e078 | ||
|
|
babae66b48 | ||
|
|
3403a6e387 | ||
|
|
b196bd6566 | ||
|
|
f23b41d7b1 | ||
|
|
7125401411 | ||
|
|
4b52ef8e76 | ||
|
|
5d7b4ab289 | ||
|
|
7ee802a5a2 | ||
|
|
2f8b82ebca | ||
|
|
aea0ec4346 | ||
|
|
af08094ba6 | ||
|
|
9bddba26de | ||
|
|
3b5bcea010 | ||
|
|
adefba1b03 | ||
|
|
48a2460393 | ||
|
|
2be0f33e7c | ||
|
|
ccc77d2a8d | ||
|
|
f648294931 | ||
|
|
83f27f018c | ||
|
|
fefe0affc1 | ||
|
|
a3d1057a73 | ||
|
|
12384eae6f | ||
|
|
357af1f095 | ||
|
|
ab791fc9d6 | ||
|
|
f5f8b98dbb | ||
|
|
293b6aaa59 | ||
|
|
98a3b2a5c2 | ||
|
|
78ad1208d6 | ||
|
|
477a241c10 | ||
|
|
edb1f47139 | ||
|
|
0f9f170e9f | ||
|
|
99d4a62c9a | ||
|
|
2227793efc | ||
|
|
b78804f9a2 | ||
|
|
345fc37fdc | ||
|
|
c1effe1bbf | ||
|
|
2ee8cb0559 | ||
|
|
414de98047 | ||
|
|
0512c63533 | ||
|
|
cae11e3e43 | ||
|
|
4f0a0b9a94 | ||
|
|
dc22583aca | ||
|
|
346cbf2c2a | ||
|
|
8eb79b3435 | ||
|
|
13a158690f | ||
|
|
e4c8312d31 | ||
|
|
3d2d0b52a3 | ||
|
|
073fe76f6a | ||
|
|
4b7635ce72 | ||
|
|
96333b6bea | ||
|
|
90dd185aed | ||
|
|
8746d57184 | ||
|
|
0165badb9d | ||
|
|
60d297d592 | ||
|
|
2da37077db | ||
|
|
e1220aefc4 | ||
|
|
5efa483265 | ||
|
|
5f0c9fabbc | ||
|
|
397c7eea38 | ||
|
|
066cb34268 | ||
|
|
721b96ef90 | ||
|
|
562a68513e | ||
|
|
a7722aee32 | ||
|
|
413de0a56a | ||
|
|
04e16d2817 | ||
|
|
d1a0937cae | ||
|
|
1c98b85886 | ||
|
|
4de130c255 | ||
|
|
4ddead1e1c | ||
|
|
d7edcc40e4 | ||
|
|
7d40b53fbf | ||
|
|
76b269b1f4 | ||
|
|
61d29bfc80 | ||
|
|
0f2adc19eb | ||
|
|
1aabcfdbae | ||
|
|
b5ae93d72e | ||
|
|
6a2a762914 | ||
|
|
50c9e15a7d | ||
|
|
c0f02a8078 | ||
|
|
3789cba2f2 | ||
|
|
8592873f24 | ||
|
|
051dcaf877 | ||
|
|
95046512a4 | ||
|
|
4e9839d453 | ||
|
|
d17041f052 | ||
|
|
cbcb39932c | ||
|
|
52a566af97 | ||
|
|
9050c32365 | ||
|
|
4911714f74 | ||
|
|
c77de19ba9 | ||
|
|
051d6cc19b | ||
|
|
61e0a38091 | ||
|
|
fca1862ac9 | ||
|
|
c2c8b398a9 | ||
|
|
9495ab477b | ||
|
|
62a2463211 | ||
|
|
dcd3edaf87 | ||
|
|
b47e0f5ceb | ||
|
|
84a5bf83ff | ||
|
|
f3a22d396a | ||
|
|
eb2f42aa97 | ||
|
|
47aa798127 | ||
|
|
5c27e93f51 | ||
|
|
efaf42e5df | ||
|
|
d3220babe2 | ||
|
|
a1b5be044f | ||
|
|
58720d3c06 | ||
|
|
d64c5ea1a8 | ||
|
|
50d2d49220 | ||
|
|
d2b9af04ac | ||
|
|
321c24b0d7 | ||
|
|
14a8996fe6 | ||
|
|
ef76b1f688 | ||
|
|
5c616548a0 | ||
|
|
da923d334d | ||
|
|
e06ec26906 | ||
|
|
f6ca33d42c | ||
|
|
f8110669f0 | ||
|
|
df7e9dae0c | ||
|
|
4760bac13d | ||
|
|
737f347f23 | ||
|
|
1257369169 | ||
|
|
de315dfaad | ||
|
|
ba5f7f6a3e | ||
|
|
b0d14c7d13 | ||
|
|
735fde494a | ||
|
|
d2533b96f3 | ||
|
|
ddabd0c70a | ||
|
|
945759162e | ||
|
|
bcb739a864 | ||
|
|
90b437e372 | ||
|
|
ab3ea490fd | ||
|
|
d19e8b9a4b | ||
|
|
c5f801c82b | ||
|
|
7b8b7115d9 | ||
|
|
646fad9d55 | ||
|
|
06ec4252a4 | ||
|
|
33848546a3 | ||
|
|
fa2f72258a | ||
|
|
7653aaa4b1 | ||
|
|
c362a8c80e | ||
|
|
c339da7fc2 | ||
|
|
33787340a4 | ||
|
|
cf713fb0ab | ||
|
|
c82ae40e9f | ||
|
|
099558d100 | ||
|
|
8ed418b042 | ||
|
|
39d84f4f6a | ||
|
|
c5c778bcfc | ||
|
|
1ebe4f75cc | ||
|
|
13bc0b6b1f | ||
|
|
fcd1bb9312 | ||
|
|
c33d624988 | ||
|
|
0ec733ce61 | ||
|
|
dbdeb1f3fa | ||
|
|
3d7f3e57b5 | ||
|
|
a64c8ca9e9 | ||
|
|
378e926d78 | ||
|
|
3a957dd96f | ||
|
|
554d4400ab | ||
|
|
2037030d50 | ||
|
|
207392821d | ||
|
|
2dca15686f | ||
|
|
469317d9bd | ||
|
|
894a9869dd | ||
|
|
c14be73428 | ||
|
|
2dbef2f2a9 | ||
|
|
4ac8b5e0d6 | ||
|
|
9d4215e6c0 | ||
|
|
d683af0f12 | ||
|
|
095b4ce16b | ||
|
|
bfdabdacff | ||
|
|
6f89dff45e | ||
|
|
d930d36155 | ||
|
|
a1fe2c9848 | ||
|
|
6b53a5ed7b | ||
|
|
70041f4038 | ||
|
|
96b65b3644 | ||
|
|
347538efbd | ||
|
|
2b37d46564 | ||
|
|
2df5c96352 | ||
|
|
3fa1df48a1 | ||
|
|
f30f1ae3ea | ||
|
|
7c709f039f | ||
|
|
f8de55da04 | ||
|
|
fd6b87253c | ||
|
|
821b1dcf34 | ||
|
|
611b29acd8 | ||
|
|
71a56180e5 | ||
|
|
cb628b2e4e | ||
|
|
bc68c41d5f | ||
|
|
4aad3c0eb0 | ||
|
|
68a80b10fe | ||
|
|
c17b7b38b0 | ||
|
|
91540c56af | ||
|
|
90d3ff290f | ||
|
|
619cf868e6 | ||
|
|
3524b0d201 | ||
|
|
3e753f5cbe | ||
|
|
c77274ffa9 | ||
|
|
323c8655cf | ||
|
|
40afb68570 | ||
|
|
4ab78af90a | ||
|
|
b73c891891 | ||
|
|
fbff8986e7 | ||
|
|
9fcb846402 | ||
|
|
136b3203f4 | ||
|
|
1ed0b3f7ca | ||
|
|
a354e5c1ff | ||
|
|
3de6fa1122 | ||
|
|
db16b27d11 | ||
|
|
d2fcc41eec | ||
|
|
cd37210184 | ||
|
|
a5b6751bbd | ||
|
|
cd8eb93ecb | ||
|
|
68cb0aaee3 | ||
|
|
40943eb67a | ||
|
|
f78a3e7326 | ||
|
|
72d07d3202 | ||
|
|
ecea632c4c | ||
|
|
fd9c48fd9c | ||
|
|
f2621c5137 | ||
|
|
a947052ec2 | ||
|
|
0a9d2719c5 | ||
|
|
aa6e0482fa | ||
|
|
77a063af16 | ||
|
|
5cc23552a7 | ||
|
|
76b3a7e78f | ||
|
|
2b80b401be | ||
|
|
f16c3406cd | ||
|
|
918a6ac2b4 | ||
|
|
bd5a826d37 | ||
|
|
50b6df5389 | ||
|
|
857ef82edf | ||
|
|
f380ae5243 | ||
|
|
23b51990e3 | ||
|
|
77417b8ea0 | ||
|
|
eed9efec4e | ||
|
|
b5c16f8bfc | ||
|
|
89b8c133e7 | ||
|
|
54126d5c59 | ||
|
|
660ce58597 | ||
|
|
9f7134c3fc | ||
|
|
145361aaac | ||
|
|
8c552ddf5b | ||
|
|
58649f19cb | ||
|
|
14be73c8a3 | ||
|
|
87cd2dc07d | ||
|
|
2d306c4b15 | ||
|
|
5aaf6e889c | ||
|
|
c548328904 | ||
|
|
11629b1c1a | ||
|
|
774922da91 | ||
|
|
7da2ea45b9 | ||
|
|
95f3c07d6f | ||
|
|
a315efe3b2 | ||
|
|
6155c6629d | ||
|
|
d40ac082ef | ||
|
|
d2ac910a53 | ||
|
|
a1577bf965 | ||
|
|
e486c76253 | ||
|
|
30d1f909ed | ||
|
|
8359b90057 | ||
|
|
11c25c0e9e | ||
|
|
b99308a33c | ||
|
|
170a44b222 | ||
|
|
0808d75851 | ||
|
|
2eff8ef504 | ||
|
|
60d8ae1003 | ||
|
|
53f22aed41 | ||
|
|
13370c536c | ||
|
|
054be18721 | ||
|
|
64f81108db | ||
|
|
ead7079f1d | ||
|
|
82add753e5 | ||
|
|
b3ffdc5991 | ||
|
|
e744ee1338 | ||
|
|
ab8dbdcce5 | ||
|
|
7bbd665b34 | ||
|
|
dce241c107 | ||
|
|
8c50acb9d2 | ||
|
|
92fcd25e9d | ||
|
|
9b0170dd03 | ||
|
|
2239961279 | ||
|
|
18834ff62b | ||
|
|
03a6f3f9c9 | ||
|
|
b363e01e6b | ||
|
|
d42e88d5b3 | ||
|
|
fae874c8ca | ||
|
|
0b1f7e412b | ||
|
|
a8de1a70d1 | ||
|
|
7db98a18fe | ||
|
|
a7029a5b4c | ||
|
|
4f31b7f242 | ||
|
|
b475d0593c | ||
|
|
862a2858b0 | ||
|
|
364450bf8d | ||
|
|
f6d358ff42 | ||
|
|
7980c79d69 | ||
|
|
5e8c50cc8d | ||
|
|
7218761fe1 | ||
|
|
3644db298b | ||
|
|
29775cef5e | ||
|
|
a343882c74 | ||
|
|
6f6c396604 | ||
|
|
483bcad21d | ||
|
|
310dee21f7 | ||
|
|
d1c12e85c1 | ||
|
|
99d7285f20 | ||
|
|
d4bdca45b3 | ||
|
|
58e9d5d59d | ||
|
|
7428ca944d | ||
|
|
ae15e839d9 | ||
|
|
8a242668fd | ||
|
|
b42e8bce3a | ||
|
|
b1be78460a | ||
|
|
d57bed7838 | ||
|
|
b8afc73b73 | ||
|
|
19425d32f3 | ||
|
|
9bd58f9387 | ||
|
|
f2b829166d | ||
|
|
ab2a639a2a | ||
|
|
0aa1b967f0 | ||
|
|
80041d15b2 | ||
|
|
2cc569eab7 | ||
|
|
bea573d370 | ||
|
|
d0d310f1cb | ||
|
|
3907feb306 | ||
|
|
acb155d893 | ||
|
|
c47ddcf22b | ||
|
|
565d4beea2 | ||
|
|
c43aaa8b20 | ||
|
|
6ddcd33daa | ||
|
|
24b27e5948 | ||
|
|
f604c74a5f | ||
|
|
c3f4e5fb1a | ||
|
|
adbf1d6d1c | ||
|
|
9b0311a4d8 | ||
|
|
b455622aa8 | ||
|
|
ccef5edbfe | ||
|
|
91acd4baf8 | ||
|
|
6ff408d423 | ||
|
|
ee5804fa14 | ||
|
|
2b6e59d968 | ||
|
|
ae794eefaa | ||
|
|
dd24a6ca15 | ||
|
|
a0e3160ad4 | ||
|
|
4c0740c8de | ||
|
|
8c6c9e6d56 | ||
|
|
f8fe5f8560 | ||
|
|
eaca53a2d9 | ||
|
|
bef76802de | ||
|
|
ebede25ceb | ||
|
|
4ddac468c4 | ||
|
|
0a181e1665 | ||
|
|
17ad597dba | ||
|
|
b784934049 | ||
|
|
93b3476358 | ||
|
|
6df2225c55 | ||
|
|
562751dcc9 | ||
|
|
3785125faf | ||
|
|
edef058e18 | ||
|
|
16fe975928 | ||
|
|
24dfd3f2d7 | ||
|
|
f8bdbd4d8f | ||
|
|
f981826204 | ||
|
|
14e885a54c | ||
|
|
dd8aa3e939 | ||
|
|
29b9fd605e | ||
|
|
aa5bb2c3dd | ||
|
|
993bd61329 | ||
|
|
b9b490c7f5 | ||
|
|
09fae1b5d3 | ||
|
|
e4b59e5583 | ||
|
|
e9c3d83d5a | ||
|
|
812768d7a9 | ||
|
|
a3b5edc934 | ||
|
|
aaed6782e8 | ||
|
|
fd3a683b2a | ||
|
|
08d00b25d8 | ||
|
|
61a9a054fd | ||
|
|
bf90247a63 | ||
|
|
4708ca268e | ||
|
|
7bb00afec3 | ||
|
|
13a354f81e | ||
|
|
8187ba1518 | ||
|
|
dbb5fce3d8 | ||
|
|
d65a92b951 | ||
|
|
a69dd76eac | ||
|
|
e36003e9b8 | ||
|
|
2accfbd6f3 | ||
|
|
858cb585d7 | ||
|
|
35cbe7640b | ||
|
|
0c440812db | ||
|
|
436ce2c6e9 | ||
|
|
a1312f7b19 | ||
|
|
01e99bbac1 | ||
|
|
dd6d7f031f | ||
|
|
f7fe4db91b | ||
|
|
a106899acd | ||
|
|
ffaeff82d3 | ||
|
|
13bdd8bcdf | ||
|
|
7d7694ae6a | ||
|
|
b3540f9932 | ||
|
|
a5084f1522 | ||
|
|
565a751ca2 | ||
|
|
f6497e03d1 | ||
|
|
b7b59b7fe9 | ||
|
|
890611200a | ||
|
|
ce45f85c61 | ||
|
|
761d833372 | ||
|
|
3875d9af4c | ||
|
|
ad3318ddc8 | ||
|
|
7184475a98 | ||
|
|
c180e7a437 | ||
|
|
fbe3e002bc | ||
|
|
b5b77a72b4 | ||
|
|
97dfccb632 | ||
|
|
319c9852bf | ||
|
|
1b363fa6b0 | ||
|
|
fa24421216 | ||
|
|
d84fd77bf8 | ||
|
|
04dab1e82d | ||
|
|
394be58371 | ||
|
|
217546ae43 | ||
|
|
8aa1638ccc | ||
|
|
89ea081433 | ||
|
|
7835716cef | ||
|
|
cb1787f033 | ||
|
|
1842d7c865 | ||
|
|
bc2bb96cd7 | ||
|
|
5cb1700702 | ||
|
|
7dc0329250 | ||
|
|
90ea4af4a1 | ||
|
|
a744b11975 | ||
|
|
597b1a1b5e | ||
|
|
f0b453bc3e | ||
|
|
c9d7b865b6 | ||
|
|
eb5cdf0c64 | ||
|
|
e3a6631123 | ||
|
|
434aecf327 | ||
|
|
abd88841ef | ||
|
|
42e5441888 | ||
|
|
01b6ca34b7 | ||
|
|
4ade4e8a0d | ||
|
|
d1f14c829a | ||
|
|
b43133b361 | ||
|
|
2e2330bf25 | ||
|
|
0a2d496d58 | ||
|
|
000f07bfbe | ||
|
|
2e7c3a6e70 | ||
|
|
05a4db1fcd | ||
|
|
ee5e39835c | ||
|
|
143434ac78 | ||
|
|
4dc4b2efac | ||
|
|
e175eb1ffb | ||
|
|
4be85e1b37 | ||
|
|
9cab7a24fd | ||
|
|
39df0ced18 | ||
|
|
2705f55221 | ||
|
|
4679be7c2b | ||
|
|
935676cdad | ||
|
|
8ff2ed2fe1 | ||
|
|
6bdaf38d12 | ||
|
|
e018ab98be | ||
|
|
92a7c79db2 | ||
|
|
19fefd3a4b | ||
|
|
cdc0e74ee6 | ||
|
|
0c29ab2b31 | ||
|
|
b50d5cea2b | ||
|
|
3d3c23b39f | ||
|
|
2bb9ee89fa | ||
|
|
96db0fff50 | ||
|
|
99663e95f8 | ||
|
|
1153ddccb6 | ||
|
|
8d091a640b | ||
|
|
2c0b7a8ff6 | ||
|
|
faa3e537e1 | ||
|
|
0a5e99d7ee | ||
|
|
d1f9149d8a | ||
|
|
ee079481c9 | ||
|
|
639b48625f | ||
|
|
dd70604cec | ||
|
|
34c783e2fe | ||
|
|
82d0009885 | ||
|
|
baed0e32f9 | ||
|
|
3c7c436303 | ||
|
|
9b14f5f85a | ||
|
|
0fd9a249de | ||
|
|
7a18a2de59 | ||
|
|
5d7c7d5132 | ||
|
|
192e92d681 | ||
|
|
1b9f4817c8 | ||
|
|
d9940f6207 | ||
|
|
f7d5419816 | ||
|
|
9928ee0a52 | ||
|
|
66f796e74c | ||
|
|
a3eac818d5 | ||
|
|
cfc19ff1b6 | ||
|
|
80495124b2 | ||
|
|
2c21a4778d | ||
|
|
14b8dee96f | ||
|
|
11c88033d4 | ||
|
|
25bb30c9b8 | ||
|
|
54feb0ad2a | ||
|
|
b733c50bc0 | ||
|
|
a93744423d | ||
|
|
9957c45073 | ||
|
|
0ac91cc657 | ||
|
|
d9779744f9 | ||
|
|
ed5a01d922 | ||
|
|
d43f93ff93 | ||
|
|
3f2879bf60 | ||
|
|
ee1e535298 | ||
|
|
4b4a9583b4 | ||
|
|
da2ba024a5 | ||
|
|
e5d468ea9c | ||
|
|
21d9e6e0fb | ||
|
|
98af505439 | ||
|
|
1df0ace0b4 | ||
|
|
4af267c07b | ||
|
|
6c7c5a04b8 | ||
|
|
42069e9432 | ||
|
|
36762ac4b4 | ||
|
|
147dc568da | ||
|
|
29135161d7 | ||
|
|
9c04f57cab | ||
|
|
e1123aa80c | ||
|
|
4a8105e925 | ||
|
|
51df269afe | ||
|
|
bf2613b975 | ||
|
|
5c6b7e177c | ||
|
|
428f5ddabd | ||
|
|
a4b26efa1f | ||
|
|
5a8b04137f | ||
|
|
ed6db9d86b | ||
|
|
ee3c4e43ae | ||
|
|
6d4e4d0cce | ||
|
|
89158b9ad1 | ||
|
|
1fdac25f66 | ||
|
|
1017744c94 | ||
|
|
f757d74898 | ||
|
|
bd2370c054 | ||
|
|
dbfd68ae3a | ||
|
|
801b925edf | ||
|
|
a201f859cd | ||
|
|
84cc738166 | ||
|
|
81f0273d54 | ||
|
|
3f46c67c69 | ||
|
|
6c7459e455 | ||
|
|
8d16725373 | ||
|
|
4e34fd3b8a | ||
|
|
87c14c528a | ||
|
|
ac43a87820 | ||
|
|
474751e6b2 | ||
|
|
37ab4d946c | ||
|
|
d6e5a72c84 | ||
|
|
add4581894 | ||
|
|
45ad37b31b | ||
|
|
f6ca49c863 | ||
|
|
7fa1b5b26c | ||
|
|
0794fee913 | ||
|
|
319a7b842b | ||
|
|
50d41533d2 | ||
|
|
8e89b13c47 | ||
|
|
f962ee9dc6 | ||
|
|
a271625928 | ||
|
|
9f642c1bbc | ||
|
|
21939d36ec | ||
|
|
8c754b1834 | ||
|
|
2b9f68631c | ||
|
|
830608b4b8 | ||
|
|
eefd9127ca | ||
|
|
0392e36e94 | ||
|
|
a967818235 | ||
|
|
8eaa434163 | ||
|
|
af9d06e06a | ||
|
|
703944c39d | ||
|
|
e81f16bf5d | ||
|
|
7572840cd0 | ||
|
|
569a1d27b4 | ||
|
|
d642eede9a | ||
|
|
5b0a0ded05 | ||
|
|
819b125e6e | ||
|
|
fa551df95e | ||
|
|
76531da252 | ||
|
|
daf2169797 | ||
|
|
e0acad59cb | ||
|
|
5765a22249 | ||
|
|
f47e1d4995 | ||
|
|
8f506d3257 | ||
|
|
d960ced6e1 | ||
|
|
7cf9a34ade | ||
|
|
5ef8d1bfbf | ||
|
|
6ee90f06ab | ||
|
|
46861bc41e | ||
|
|
12e63e91af | ||
|
|
edad4639cf | ||
|
|
1a3fa1e091 | ||
|
|
9295264b6f | ||
|
|
46c47291e8 | ||
|
|
e25323e81b | ||
|
|
2a25fc41f6 | ||
|
|
4b4700ceca | ||
|
|
0df91242a2 | ||
|
|
9821954ecc | ||
|
|
e2d113cadf | ||
|
|
b4f9f5d041 | ||
|
|
6c3d5bd2a0 | ||
|
|
da9d1d7aa6 | ||
|
|
52846504da | ||
|
|
d06d66e899 | ||
|
|
cdd9a23fd4 | ||
|
|
4233766b1d | ||
|
|
f78d1cd47a | ||
|
|
c3a45944e2 | ||
|
|
342c4eab2a | ||
|
|
fb375429b5 | ||
|
|
9a308a3344 | ||
|
|
0348a407e5 | ||
|
|
5bc58a0ebc | ||
|
|
577c1f0305 | ||
|
|
f84f957881 | ||
|
|
9c946e22fc | ||
|
|
1099cdcb5a | ||
|
|
0c27c8633e | ||
|
|
baf301d122 | ||
|
|
08bd7654bc | ||
|
|
7684bcae7d | ||
|
|
461c7e45b5 | ||
|
|
a4a54aa1bf | ||
|
|
337c694971 | ||
|
|
05591abeb1 | ||
|
|
196a50a4bd | ||
|
|
84a5b7a0f8 | ||
|
|
ed23815985 | ||
|
|
f1eafe8b01 | ||
|
|
2d3bd021d0 | ||
|
|
2a28a4320a | ||
|
|
8fb55653d1 | ||
|
|
e717842a54 | ||
|
|
74e481c743 | ||
|
|
98c6fa2495 | ||
|
|
4dac51d260 | ||
|
|
ac796d3f9a | ||
|
|
e0ce90ea0a | ||
|
|
f6a23fe205 | ||
|
|
d2b8d46658 | ||
|
|
93a3bc7343 | ||
|
|
7f576964d8 | ||
|
|
0873ae8242 | ||
|
|
571abc9a67 | ||
|
|
c68f20cecc | ||
|
|
94f4e972b5 | ||
|
|
175a126a1a | ||
|
|
95d2726ecc | ||
|
|
b8dbd78de8 | ||
|
|
777dbf46dc | ||
|
|
e8558d2160 | ||
|
|
5031c77d85 | ||
|
|
5756fcab2f | ||
|
|
fc0786a442 | ||
|
|
780079e771 | ||
|
|
253326c52d | ||
|
|
81dfc2163b | ||
|
|
9b54f0037a | ||
|
|
b416dc5fc8 | ||
|
|
ecc022ee5f | ||
|
|
092b8d7bf3 | ||
|
|
912f030532 | ||
|
|
66db757dd4 | ||
|
|
9616bf6882 | ||
|
|
dea53bb460 | ||
|
|
35a5a6c16d | ||
|
|
42b438b7dc | ||
|
|
18765d0032 | ||
|
|
4aa590288b | ||
|
|
315b39c73a | ||
|
|
2225ca0a54 | ||
|
|
ad29c03711 | ||
|
|
0a4967ce0c | ||
|
|
b3d3a5ed6a | ||
|
|
4d8de33979 | ||
|
|
32629bb522 | ||
|
|
0bc972fbc2 | ||
|
|
6cc84b3c44 | ||
|
|
c5e81c51d9 | ||
|
|
cbe5d34f6f | ||
|
|
975cbbb029 | ||
|
|
f3da771890 | ||
|
|
2edfd187f2 | ||
|
|
2c8a90ef52 | ||
|
|
0de0101fdd | ||
|
|
1dbfb07c08 | ||
|
|
047737496a | ||
|
|
5b6a6f914b | ||
|
|
4fa5f90346 | ||
|
|
ebeca5bd9b | ||
|
|
9dcf45c65c | ||
|
|
030e12ec39 | ||
|
|
12bebfe0f9 | ||
|
|
28a1cdfc2e | ||
|
|
e7092bc59c | ||
|
|
87049cbf84 | ||
|
|
19ffb62903 | ||
|
|
f5778c8fbb | ||
|
|
92ec30a3b1 | ||
|
|
8a08b6457a | ||
|
|
9a2065c5ee | ||
|
|
27f08ac11d | ||
|
|
0a9afc12de | ||
|
|
a1a2ae2a25 | ||
|
|
26942c818e | ||
|
|
8ba160ba94 | ||
|
|
1ceedd0bf6 | ||
|
|
4db6127658 | ||
|
|
c4b2282fee | ||
|
|
001513c9ca | ||
|
|
162f9f87f9 | ||
|
|
9965f63a44 | ||
|
|
070a0eb58f | ||
|
|
0b4e7deab1 | ||
|
|
f1cdf4e1ca | ||
|
|
b9c62013ef | ||
|
|
415d26805a | ||
|
|
83f4c735c8 | ||
|
|
64fef09b67 | ||
|
|
9f2ad4928e | ||
|
|
0e30044094 | ||
|
|
fc8450833a | ||
|
|
6761aacbfa | ||
|
|
408dbac801 | ||
|
|
b00d986d54 | ||
|
|
305ada6672 | ||
|
|
1bef8e9799 | ||
|
|
a901eb3ce6 | ||
|
|
896c3cfb76 | ||
|
|
06509be841 | ||
|
|
81f44665cc | ||
|
|
9c7ed35a65 | ||
|
|
05e81e18d2 | ||
|
|
6ca8ee1518 | ||
|
|
59e655b020 | ||
|
|
5bd9d66098 | ||
|
|
2163c930b0 | ||
|
|
18f0bd1d63 | ||
|
|
5b9c044332 | ||
|
|
dc3069bcb1 | ||
|
|
9517f7b636 | ||
|
|
b77d929217 | ||
|
|
b939ce06be | ||
|
|
f9e37f54eb | ||
|
|
04402a9126 | ||
|
|
068cb3a64c | ||
|
|
f4302a73ac | ||
|
|
23ddeb58a5 | ||
|
|
956f295d48 | ||
|
|
61257bc2de | ||
|
|
6297297708 | ||
|
|
fd42ef9b06 | ||
|
|
a2671a7f49 | ||
|
|
fa5ba2e026 | ||
|
|
01a0e8062d | ||
|
|
5b038f83e7 | ||
|
|
efe4e5d10d | ||
|
|
d6eb4b71ac | ||
|
|
4c9c43d4d4 | ||
|
|
0cc11b86ba | ||
|
|
93b4568fc0 | ||
|
|
f6cd8f2d65 | ||
|
|
8bfcb4c7a7 | ||
|
|
eb0bf4f468 | ||
|
|
e8c554661c | ||
|
|
c3e7e7d715 | ||
|
|
1e16e8829d | ||
|
|
33a97c5c8a | ||
|
|
39be3b81da | ||
|
|
4c02a5930a | ||
|
|
2d62f7406f | ||
|
|
6530e3898d | ||
|
|
5a26171dd7 | ||
|
|
167b5e4c27 | ||
|
|
a8242fe6fb | ||
|
|
15e69748f1 | ||
|
|
268c7bf68b | ||
|
|
d8b93c29a7 | ||
|
|
b9ba8d6a57 | ||
|
|
751cee5ef1 | ||
|
|
8ba4b13c55 | ||
|
|
8b83ff3704 | ||
|
|
a472858297 | ||
|
|
682f4ba2d5 | ||
|
|
656720fb42 | ||
|
|
fd8ef4c428 | ||
|
|
4e1d299e6b | ||
|
|
0e9cd91609 | ||
|
|
52d159a784 | ||
|
|
67806d44c1 | ||
|
|
8510247b5f | ||
|
|
77becc566f | ||
|
|
e1b505cd1d | ||
|
|
e485a09e0e | ||
|
|
1fa62ae734 | ||
|
|
262c396666 | ||
|
|
59a82b40b0 | ||
|
|
e10b7e73db | ||
|
|
476250ebd2 | ||
|
|
287fb89248 | ||
|
|
e6172809bd | ||
|
|
db8704e1f4 | ||
|
|
1a73305ac2 | ||
|
|
285a9b22c7 | ||
|
|
be55943d45 | ||
|
|
e0874e1934 | ||
|
|
4cb6607c89 | ||
|
|
751eb368a8 | ||
|
|
f7654a0c61 | ||
|
|
d78eb10f29 | ||
|
|
d2a35c6088 | ||
|
|
b9e5e5f5a8 | ||
|
|
a390897ba4 | ||
|
|
4e5ac72254 | ||
|
|
9d4ea3014b | ||
|
|
f86720c6c0 | ||
|
|
c6f629ffdd | ||
|
|
81487c8b54 | ||
|
|
f6e7551f06 | ||
|
|
4293254bef | ||
|
|
867f2ec058 | ||
|
|
b26b51d154 | ||
|
|
f50b593ac0 | ||
|
|
7023d871e8 | ||
|
|
2dfcf65981 | ||
|
|
b780eba4e4 | ||
|
|
25bfb13770 | ||
|
|
1a6841c99c | ||
|
|
1d4f804bc1 | ||
|
|
89edbf8317 | ||
|
|
a008dd8344 | ||
|
|
20a2f9b9be | ||
|
|
1088f4925f | ||
|
|
b66de48b3b | ||
|
|
e6877671f1 | ||
|
|
9fbdce8fb5 | ||
|
|
f6b9c993e1 | ||
|
|
d46b570919 | ||
|
|
918d23f658 | ||
|
|
d2fedd629d | ||
|
|
2d069831fb | ||
|
|
8ee821e69a | ||
|
|
279dc3f0bf | ||
|
|
846357d592 | ||
|
|
d8d18fbb02 | ||
|
|
74428df2fd | ||
|
|
d6b1375bf5 | ||
|
|
0f12df19a1 | ||
|
|
cde3078963 | ||
|
|
216ab04994 | ||
|
|
e0f0d05938 | ||
|
|
23da29af91 | ||
|
|
ecc391bbcf | ||
|
|
c861dc8923 | ||
|
|
507a8cdc5e | ||
|
|
bd85b5713c | ||
|
|
a21a5b22c1 | ||
|
|
d344589703 | ||
|
|
218a6fe9e5 | ||
|
|
2b667e4923 | ||
|
|
c98f7fb4e3 | ||
|
|
f17e6c3046 | ||
|
|
6eecfe3886 | ||
|
|
b383798ac9 | ||
|
|
ea037b01eb | ||
|
|
04445235f1 | ||
|
|
778ccbbafa | ||
|
|
c5370ede95 | ||
|
|
2b66107abb | ||
|
|
0aabfe2a4c | ||
|
|
16f9246853 | ||
|
|
c9fd075c89 | ||
|
|
47e1315459 | ||
|
|
49fa8d4cdd | ||
|
|
a60de343a9 | ||
|
|
f2c37d0abf | ||
|
|
bc27b2f432 | ||
|
|
3645008e22 | ||
|
|
06ee532286 | ||
|
|
bbe2be3f54 | ||
|
|
bb098218ca | ||
|
|
217d38cdea | ||
|
|
377fb53944 | ||
|
|
7f85da8df7 | ||
|
|
3e0bef6da4 | ||
|
|
82511341d7 | ||
|
|
4029db9aac | ||
|
|
7011a8cec3 | ||
|
|
9a3de48b48 | ||
|
|
494e75ac83 | ||
|
|
3f49c1e42a | ||
|
|
68f4ea7423 | ||
|
|
c6b29ff896 | ||
|
|
76f93293a0 | ||
|
|
d375ca5e0d | ||
|
|
60a7506744 | ||
|
|
d3ff44f0d5 | ||
|
|
43d90b1610 | ||
|
|
de23a49231 | ||
|
|
4b65a89cf4 | ||
|
|
471b38aa00 | ||
|
|
b6c9ac6304 | ||
|
|
8cd78da8b3 | ||
|
|
8f0e2729dd | ||
|
|
c73d6219f2 | ||
|
|
6ef579df50 | ||
|
|
bd76965879 | ||
|
|
070a616b82 | ||
|
|
7a015b92b2 | ||
|
|
2f56fe4071 | ||
|
|
9d6cab3b21 | ||
|
|
04affde6a1 | ||
|
|
018b4fccb9 | ||
|
|
bba3aa9533 | ||
|
|
b6788ccaff | ||
|
|
cde8cd6b30 | ||
|
|
19ec55f40e | ||
|
|
6a6eb354ff | ||
|
|
6b5abbe58e | ||
|
|
66c1ec5a26 | ||
|
|
ecd074945c | ||
|
|
88dd30b232 | ||
|
|
10569a452f | ||
|
|
dc294204b6 | ||
|
|
06ee38423b | ||
|
|
6d8c88177a | ||
|
|
f43b5e3709 | ||
|
|
a00ea0aeae | ||
|
|
0659cddd21 | ||
|
|
66d846b0cc | ||
|
|
d040886dc4 | ||
|
|
91f9e0370d | ||
|
|
86a7eef997 | ||
|
|
530eec311d | ||
|
|
7c5d037032 | ||
|
|
ee16fc4a6f | ||
|
|
2d24cbdd98 | ||
|
|
da7a1e79af | ||
|
|
e8ef689cb9 | ||
|
|
aebb7585c9 | ||
|
|
5b9ac20297 | ||
|
|
9c05216461 | ||
|
|
d4965b4014 | ||
|
|
b8eb945946 | ||
|
|
6df21524cd | ||
|
|
fa49aae286 | ||
|
|
05e11008c0 | ||
|
|
40656e9855 | ||
|
|
7cee075a32 | ||
|
|
985dc00f1f | ||
|
|
cda68df8c1 | ||
|
|
70cb8f9a7e | ||
|
|
674c3e5816 | ||
|
|
61ea3eacb0 | ||
|
|
8e7c35fc81 | ||
|
|
234fe626af | ||
|
|
03df189954 | ||
|
|
6f2c50e7fc | ||
|
|
c9720568d0 | ||
|
|
5be76ae252 | ||
|
|
a2fe24d186 | ||
|
|
97dd654ba4 | ||
|
|
f1b547a509 | ||
|
|
5efb1327df | ||
|
|
b5113f4e70 | ||
|
|
445475a166 | ||
|
|
2eb712e519 | ||
|
|
736c8e8773 | ||
|
|
3278452323 | ||
|
|
bd3818eb1b | ||
|
|
b75c3cc415 | ||
|
|
b963feeec6 | ||
|
|
f2d4167fee | ||
|
|
5d713fe123 | ||
|
|
6b9a20e7f9 | ||
|
|
11d4a2a451 | ||
|
|
c6a8cb7d10 | ||
|
|
7f6826368a | ||
|
|
bf95fad5f5 | ||
|
|
ebba0746bc | ||
|
|
67152e75e6 | ||
|
|
4aa3f403f1 | ||
|
|
56e9307d8f | ||
|
|
eed640dbe8 | ||
|
|
edb772fd6d | ||
|
|
e557fd7c44 | ||
|
|
8ba743d8d2 | ||
|
|
279205664f | ||
|
|
f7a7bb0384 | ||
|
|
3922544139 | ||
|
|
bea9784db0 | ||
|
|
6cae24c265 | ||
|
|
06ec570881 | ||
|
|
25d240dc6e | ||
|
|
470d64c2dd | ||
|
|
d7eff5d864 | ||
|
|
a11cd84160 | ||
|
|
f56c00f050 | ||
|
|
f1a22bf9b3 | ||
|
|
a4fa1c57f4 | ||
|
|
27f0332cae | ||
|
|
9127138a30 | ||
|
|
ca9c3a601b | ||
|
|
91e3a7d735 | ||
|
|
cb4823d91f | ||
|
|
d752225d05 | ||
|
|
f1eacc08e6 | ||
|
|
6147fae405 | ||
|
|
c5dc456afd | ||
|
|
f633a4eb9c | ||
|
|
6c48f77bba | ||
|
|
4c0ded3c4e | ||
|
|
36b246a571 | ||
|
|
48e6fad71c | ||
|
|
1b3a9fd6bf | ||
|
|
b4ef94559d | ||
|
|
af557d98e1 | ||
|
|
551019baf6 | ||
|
|
77145bf678 | ||
|
|
91685564d1 | ||
|
|
44bda93154 | ||
|
|
baa95a2d49 | ||
|
|
996046aed5 | ||
|
|
e4489f1db2 | ||
|
|
3fe1616c45 | ||
|
|
0df3198719 | ||
|
|
3a05d2df0f | ||
|
|
de5e34f3ce | ||
|
|
0a3c788b51 | ||
|
|
664bd637b5 | ||
|
|
3669467347 | ||
|
|
bcd3209a42 | ||
|
|
17fba0f7d1 | ||
|
|
d55c4f32fc | ||
|
|
259fb7761d | ||
|
|
3ac41798c3 | ||
|
|
26a94ab06f | ||
|
|
83fb26e38d | ||
|
|
9782cced3a | ||
|
|
ff649a0710 | ||
|
|
389e5cbabf | ||
|
|
72e25f9583 | ||
|
|
a243ec06b0 | ||
|
|
37c3b082a7 | ||
|
|
5e6931e10a | ||
|
|
0ece631b37 | ||
|
|
3efbecab92 | ||
|
|
ae991771ad | ||
|
|
071a17f194 | ||
|
|
398b00734c | ||
|
|
8661906769 | ||
|
|
91319c67d5 | ||
|
|
c45f1223cb | ||
|
|
910aaadddb | ||
|
|
fc932f7b03 | ||
|
|
83ae6fc266 | ||
|
|
33ebeec0b5 | ||
|
|
225af8f363 | ||
|
|
151eb95305 | ||
|
|
f36a94207c | ||
|
|
212fd5745d | ||
|
|
238e7646a8 | ||
|
|
e429c66cea | ||
|
|
1a4c0144da | ||
|
|
db1a0e763f | ||
|
|
41694dcaea | ||
|
|
ff3fb08157 | ||
|
|
79b7e4e621 | ||
|
|
b41a37d403 | ||
|
|
b7afba6a0b | ||
|
|
da7b692ce0 | ||
|
|
d21eae44e7 | ||
|
|
c4e0f3de64 | ||
|
|
ee6050ecb4 | ||
|
|
165f072144 | ||
|
|
7acfe50855 | ||
|
|
5808e7b8c8 | ||
|
|
f85092bc7b | ||
|
|
d1c5f48c05 | ||
|
|
e95ce2c517 | ||
|
|
0d5ac5d809 | ||
|
|
f30aa7ed92 | ||
|
|
ab9736a647 | ||
|
|
5a1d1b5369 | ||
|
|
d5201df56b | ||
|
|
be19c07dd9 | ||
|
|
0ace9f589f | ||
|
|
72855fb11e | ||
|
|
9f1aa186e6 | ||
|
|
7a0ca967b4 | ||
|
|
478062d9b5 | ||
|
|
86b8016ee9 | ||
|
|
f169806b7b | ||
|
|
c4b3718856 | ||
|
|
fa26eb1678 | ||
|
|
d17313e075 | ||
|
|
6b570f11e1 | ||
|
|
804c76b47b | ||
|
|
247d262d3a | ||
|
|
9ab7b4ca58 | ||
|
|
ae6eaa89e5 | ||
|
|
82200daec2 | ||
|
|
6572c7dab5 | ||
|
|
372cad05a9 | ||
|
|
010222c55d | ||
|
|
d74d82137b | ||
|
|
a518abd582 | ||
|
|
23646318e4 | ||
|
|
149eea29b6 | ||
|
|
2ca2a0b222 | ||
|
|
7017c4078d | ||
|
|
c2a15d01af | ||
|
|
0464b436b6 | ||
|
|
2f5fb84cc4 | ||
|
|
33e2bd910f | ||
|
|
05670156f3 | ||
|
|
b65b3412b1 | ||
|
|
71d23c4d6e | ||
|
|
1cc02f0395 | ||
|
|
a710317d2f | ||
|
|
339ef1ec97 | ||
|
|
0e60f06b7c | ||
|
|
a066d49b01 | ||
|
|
05f3788b7a | ||
|
|
90e288241d | ||
|
|
fca68966b2 | ||
|
|
a4f7ea0d11 | ||
|
|
41db297e63 | ||
|
|
0da9cf38cd | ||
|
|
d14caad2e9 | ||
|
|
c2ac10b502 | ||
|
|
c86cf4b7e4 | ||
|
|
981560ae60 | ||
|
|
d5a80e0944 | ||
|
|
5a13159bfc | ||
|
|
ae1b45a046 | ||
|
|
187694b9ec | ||
|
|
3484a760f4 | ||
|
|
715423c8d6 | ||
|
|
d57dc304c4 | ||
|
|
8a2033d77f | ||
|
|
932d7ac5e9 | ||
|
|
f9accb9df2 | ||
|
|
7a4e497b62 | ||
|
|
0207529f27 | ||
|
|
a08f60352c | ||
|
|
0bddb27e75 | ||
|
|
a67ddd4b9f | ||
|
|
a7e9d7bfc2 | ||
|
|
28c3a2f9f9 | ||
|
|
df0773c1b9 | ||
|
|
902dbe619e | ||
|
|
0f59bbb5b6 | ||
|
|
9ca5f1bdc8 | ||
|
|
9f01d0d665 | ||
|
|
da544d7d3e | ||
|
|
ea8d0b9408 | ||
|
|
9287447cef | ||
|
|
d35a3a826e | ||
|
|
e23fedc9de | ||
|
|
cd3f5bb507 | ||
|
|
b0270a9e47 | ||
|
|
52cbf46f30 | ||
|
|
d61b42c81d | ||
|
|
8fd9c16642 | ||
|
|
e22ea758e4 | ||
|
|
f22c0ac2a5 | ||
|
|
4f547b7177 | ||
|
|
c4fe32016c | ||
|
|
1be5c22e5c | ||
|
|
956c0599e6 | ||
|
|
97c8fbb949 | ||
|
|
a50ce74850 | ||
|
|
8973ee17bb | ||
|
|
2e31b96a5a | ||
|
|
0222124801 | ||
|
|
61b23d59b1 | ||
|
|
cc1fa5df3a | ||
|
|
cc5664ddad | ||
|
|
e209df47c4 | ||
|
|
585f8b49b5 | ||
|
|
4491fa237f | ||
|
|
59d3ef11ed | ||
|
|
6bc7fc80da | ||
|
|
5b03469a93 | ||
|
|
f5b9abde98 | ||
|
|
340c9b237b | ||
|
|
fb2bd00859 | ||
|
|
5109688803 | ||
|
|
8fdd2fcef6 | ||
|
|
e7625063dc | ||
|
|
24f40e321c | ||
|
|
0bb898a885 | ||
|
|
61a2d8a2a7 | ||
|
|
af96543688 | ||
|
|
34f5449736 | ||
|
|
484a48e221 | ||
|
|
cc5226bf2a | ||
|
|
8fbb563f4e | ||
|
|
65e6d5a34f | ||
|
|
47be2e7c3a | ||
|
|
4d694dadd8 | ||
|
|
59397f985e | ||
|
|
cc1d4d0dbc | ||
|
|
070434c045 | ||
|
|
0dc882d7c3 | ||
|
|
c3ac9a507a | ||
|
|
a6afebc718 | ||
|
|
d41915dc2a | ||
|
|
5a5ad7a5fa | ||
|
|
9dad5e37ae | ||
|
|
adde7b5c1e | ||
|
|
3bdde42e40 | ||
|
|
6b4dee12f5 | ||
|
|
355b90387b | ||
|
|
f512ca7625 | ||
|
|
16ee3e9870 | ||
|
|
c8444775b1 | ||
|
|
784d80b509 | ||
|
|
98aacb16c3 | ||
|
|
8a35e25852 | ||
|
|
97eb073189 | ||
|
|
28534bd47a | ||
|
|
2053a26873 | ||
|
|
736a230890 | ||
|
|
3926448598 | ||
|
|
11130874d4 | ||
|
|
ef5a57119a | ||
|
|
31f4e52842 | ||
|
|
0e1aad158a | ||
|
|
5f5d6d637b | ||
|
|
a2336bcf05 | ||
|
|
20e6003290 | ||
|
|
54c633b810 | ||
|
|
f0c2cc32b1 | ||
|
|
8709982e22 | ||
|
|
686d45dcfd | ||
|
|
8502e1ff25 | ||
|
|
603c9fd959 | ||
|
|
86946fdc03 | ||
|
|
af4c99b21a | ||
|
|
97d2d68428 | ||
|
|
ce5d7cb7aa | ||
|
|
c4ff4e7167 | ||
|
|
b94d24eb25 | ||
|
|
379d0160ea | ||
|
|
23c2ea38a6 | ||
|
|
d486eb18c5 | ||
|
|
a10d488a32 | ||
|
|
25d754e86d | ||
|
|
bba85637d7 | ||
|
|
94c3a45f4c | ||
|
|
221be3def1 | ||
|
|
1daf8980dd | ||
|
|
5945408a93 | ||
|
|
9a8c568e3c | ||
|
|
fb05477e11 | ||
|
|
df68ef4d5e | ||
|
|
d857ed275e | ||
|
|
14181b7f48 | ||
|
|
6916ec5fa9 | ||
|
|
acb4822f6b | ||
|
|
79fb836d66 | ||
|
|
010110a0be | ||
|
|
756f873a25 | ||
|
|
e2d740ae04 | ||
|
|
ff244b6181 | ||
|
|
d3494d172c | ||
|
|
2922c07e67 | ||
|
|
c03a949a0d | ||
|
|
377e3ca5e6 | ||
|
|
f320728911 | ||
|
|
b4a5d88e0a | ||
|
|
7ea0b3b9e2 | ||
|
|
aa3725c860 | ||
|
|
8aa84c7fce | ||
|
|
453ceae85f | ||
|
|
1f5a0b9fa6 | ||
|
|
820a8d1de9 | ||
|
|
6bb02b28a1 | ||
|
|
60ba227d57 | ||
|
|
175e21f5e1 | ||
|
|
97db6709e4 | ||
|
|
c0fc0dfc45 | ||
|
|
f3eadd1737 | ||
|
|
c4ec48281c | ||
|
|
1a006390d9 | ||
|
|
953f265513 | ||
|
|
468877578a | ||
|
|
ff14eeb4f2 | ||
|
|
5f3eabf4cd | ||
|
|
bbc70d2471 | ||
|
|
a0cafa3d0b | ||
|
|
58219ca22f | ||
|
|
50b28f3bf2 | ||
|
|
0f8345abf7 | ||
|
|
4f213e08aa | ||
|
|
8493de3cee | ||
|
|
fee6e7428f | ||
|
|
d10616d364 | ||
|
|
85d143a273 | ||
|
|
6e72bc46d3 | ||
|
|
b8eed1d830 | ||
|
|
a64ecdfa5b | ||
|
|
bcfc0ce5f6 | ||
|
|
8bc0719dde | ||
|
|
185cd6c058 | ||
|
|
afb77541b4 | ||
|
|
c4a5c2de26 | ||
|
|
87bc4b08ff | ||
|
|
65cdb3dfa8 | ||
|
|
cc411ae004 | ||
|
|
f521b99b09 | ||
|
|
b08f330d62 | ||
|
|
41ffb1c950 | ||
|
|
ebe3ea3204 | ||
|
|
d94c4516c6 | ||
|
|
b0f8d9bb97 | ||
|
|
04dfe7b3f6 | ||
|
|
547afcfc74 | ||
|
|
48afdb4eef | ||
|
|
9ee96e3ba9 | ||
|
|
0311f5412e | ||
|
|
e734eba51e | ||
|
|
7ed40716cb | ||
|
|
155889b318 | ||
|
|
4dd011f6d0 | ||
|
|
e45a5d3a32 | ||
|
|
80a1050237 | ||
|
|
54592bba4d | ||
|
|
902d4d109a | ||
|
|
d8daacf157 | ||
|
|
0da5bcb414 | ||
|
|
ac6555fa3c | ||
|
|
2af7ef63c3 | ||
|
|
6da5b35fca | ||
|
|
abd68eb92b | ||
|
|
bf451ffc9a | ||
|
|
be734f5592 | ||
|
|
9f0c080847 | ||
|
|
3a1ba773b0 | ||
|
|
849a1ab845 | ||
|
|
940de5ab02 | ||
|
|
dd9578f379 | ||
|
|
0ce807691b | ||
|
|
4f8ea5eede | ||
|
|
7869e676af | ||
|
|
af0a726689 | ||
|
|
8d9263fca6 | ||
|
|
d6a0cbaade | ||
|
|
2302a4d04f | ||
|
|
8f9a2d08ea | ||
|
|
30c73195b5 | ||
|
|
097485195c | ||
|
|
c5f6fa110a | ||
|
|
90cfcecc09 | ||
|
|
dee0e2ed0f | ||
|
|
5ad9884ff1 | ||
|
|
188eb6b426 | ||
|
|
8361f64dbf | ||
|
|
2a6227941e | ||
|
|
a582b8f840 | ||
|
|
5316f66005 | ||
|
|
f86905457a | ||
|
|
abb211c4e8 | ||
|
|
bb56c39d16 | ||
|
|
77237196c7 | ||
|
|
a310a3b398 | ||
|
|
e0f6c7d90b | ||
|
|
a1587302aa | ||
|
|
cc0bff446b | ||
|
|
9b8ddff5b7 | ||
|
|
ac4942e26b | ||
|
|
2c55e3e917 | ||
|
|
db082802c6 | ||
|
|
b367fb5ac6 | ||
|
|
e9ab2f8d94 | ||
|
|
a845cca037 | ||
|
|
3ab6ef0aa1 | ||
|
|
198ed18b9e | ||
|
|
9110473f93 | ||
|
|
97313e0aab | ||
|
|
8876e74e43 | ||
|
|
510227e39e | ||
|
|
7a1f214166 | ||
|
|
5913dd10f1 | ||
|
|
087ebd80da | ||
|
|
bc9267e3a6 | ||
|
|
a019c335c9 | ||
|
|
ed49c8c1b6 | ||
|
|
2a243fc074 | ||
|
|
47045ce402 | ||
|
|
d6e67586bf | ||
|
|
6e9783bd25 | ||
|
|
8dc3729522 | ||
|
|
7aad4e7fb4 | ||
|
|
930af7d50b | ||
|
|
0f544f62d6 | ||
|
|
398c212955 | ||
|
|
2ec1fc60c3 | ||
|
|
c01ee053b1 | ||
|
|
b0baee5e36 | ||
|
|
b55295cb12 | ||
|
|
5928ee97ca | ||
|
|
2445ad4331 | ||
|
|
93d6d9d835 | ||
|
|
d207e6a6ad | ||
|
|
df6f3f404a | ||
|
|
357c1c8c53 | ||
|
|
44827ccad8 | ||
|
|
0d1a2dd7a9 | ||
|
|
471c9b47fe | ||
|
|
23b9a2fda0 | ||
|
|
7d6103ad6c | ||
|
|
ec39f8f8d7 | ||
|
|
a2cde53c87 | ||
|
|
13714e87f2 | ||
|
|
9101d75316 | ||
|
|
233edbf415 | ||
|
|
bd209f75fa | ||
|
|
27854a478e | ||
|
|
f12a87a96c | ||
|
|
cb4358ddbb | ||
|
|
c4819d78ba | ||
|
|
0b721cd4c4 | ||
|
|
b025757328 | ||
|
|
4bd73b6947 | ||
|
|
f3c42680db | ||
|
|
c10066205d | ||
|
|
21b7aaa428 | ||
|
|
d7225fdfce | ||
|
|
deb870c77d | ||
|
|
c05538959b | ||
|
|
f6c761dda1 | ||
|
|
877b08d6d2 | ||
|
|
a69064328b | ||
|
|
01b9566e50 | ||
|
|
ca3a100be6 | ||
|
|
1655e4ddb0 | ||
|
|
526f839764 | ||
|
|
1a86bd2a09 | ||
|
|
610e7b5bd6 | ||
|
|
86f6c04d84 | ||
|
|
fb3a1da4bb | ||
|
|
525efcbb7b | ||
|
|
ea4340e1ec | ||
|
|
91f3864fbd | ||
|
|
14fa704caf | ||
|
|
ad1f8180a5 | ||
|
|
e364f899af | ||
|
|
40683870ea | ||
|
|
7569d7c069 | ||
|
|
c87ddbb3ce | ||
|
|
793fedcf57 | ||
|
|
74fd86a69e | ||
|
|
f234091207 | ||
|
|
772b72139a | ||
|
|
6e6a844baf | ||
|
|
2f2f80273b | ||
|
|
353d8860ac | ||
|
|
fab96cb72a | ||
|
|
2203e41900 | ||
|
|
e16f2bc5f7 | ||
|
|
2381cf3269 | ||
|
|
7e3a82cd9c | ||
|
|
115817d118 | ||
|
|
5cfea4fc98 | ||
|
|
a87c870f99 | ||
|
|
b9d671326b | ||
|
|
8e4e070151 | ||
|
|
4607e1386f | ||
|
|
9686172872 | ||
|
|
8563ac1664 | ||
|
|
9a80a35f4b | ||
|
|
4cde19b0c9 | ||
|
|
230e8b436f | ||
|
|
dbb86efac3 | ||
|
|
e8d28e1b1c | ||
|
|
a3a5d0d1f4 | ||
|
|
4cf1ca4338 | ||
|
|
f174f27096 | ||
|
|
1a15762c59 | ||
|
|
fec6a4ca4e | ||
|
|
bcc878bb81 | ||
|
|
df61a00acc | ||
|
|
878fea5403 | ||
|
|
804cc98cd1 | ||
|
|
6e00020a9f | ||
|
|
2aac9a1fa3 | ||
|
|
5aa8676122 | ||
|
|
ea88d94dcf | ||
|
|
eaa1b0a5f2 | ||
|
|
de5c932283 | ||
|
|
3b673e0fb0 | ||
|
|
83b84d65c2 | ||
|
|
c31e04e2f8 | ||
|
|
a460e00574 | ||
|
|
c593d488f9 | ||
|
|
44a7c89e02 | ||
|
|
88bbbfa567 | ||
|
|
e3f9ce59eb | ||
|
|
12f0c2f580 | ||
|
|
6099e57b07 | ||
|
|
e53ecd35c0 | ||
|
|
8397b45b20 | ||
|
|
bcb1b414ed | ||
|
|
bef02a89ea | ||
|
|
1aae1bf9fd | ||
|
|
078f2aecfb | ||
|
|
c87f913eb9 | ||
|
|
a5fc3eb9d4 | ||
|
|
780dc06584 | ||
|
|
365cddf35f | ||
|
|
c099ea497a | ||
|
|
336b43d278 | ||
|
|
08e585d948 | ||
|
|
7aacd895ee | ||
|
|
3130af0e2b | ||
|
|
02a58af3c0 | ||
|
|
86645a3f19 | ||
|
|
edc3994cfd | ||
|
|
71f29b701d | ||
|
|
b4b853b4c5 | ||
|
|
d5483f3352 | ||
|
|
2522de8594 | ||
|
|
e5e60564cf | ||
|
|
bf2dabe6f1 | ||
|
|
70c873bcac | ||
|
|
5aabf5b8eb | ||
|
|
20e82ae2a2 | ||
|
|
e890cb118c | ||
|
|
275d1aa94e | ||
|
|
f748fda0ed | ||
|
|
87480bf6d4 | ||
|
|
bd6f1edea8 | ||
|
|
ed4c9fc4e9 | ||
|
|
8f8be84024 | ||
|
|
ead562ed05 | ||
|
|
8cf8726c7c | ||
|
|
b83df4e711 | ||
|
|
7e64470a71 | ||
|
|
fd3d717df5 | ||
|
|
d4ebb803fa | ||
|
|
5d276731e6 | ||
|
|
6dcfbc479d | ||
|
|
d8bf20d9ac | ||
|
|
38453101f0 | ||
|
|
8e46375186 | ||
|
|
c75d7fb32e | ||
|
|
6e0cf087ad | ||
|
|
af9a41d770 | ||
|
|
d6dc43db7d | ||
|
|
4c49647788 | ||
|
|
3de7bde0e1 | ||
|
|
dc38e24fed | ||
|
|
a61724c004 | ||
|
|
29b738b4e6 | ||
|
|
602d314ba0 | ||
|
|
a68974409c | ||
|
|
5d67107c79 | ||
|
|
da9b591621 | ||
|
|
2e8aa25844 | ||
|
|
6611322a8b | ||
|
|
948c6ee88d | ||
|
|
b7a9d80f28 | ||
|
|
277f6fbe49 | ||
|
|
e05080f5a8 | ||
|
|
4de250dd75 | ||
|
|
8f2f7f431c | ||
|
|
4f67b78853 | ||
|
|
4b14b35208 | ||
|
|
bc2ab12f99 | ||
|
|
c3166b2a48 | ||
|
|
1eef1e5b2f | ||
|
|
8191965555 | ||
|
|
f1c9244dfd | ||
|
|
58155a9921 | ||
|
|
5d398a69fb | ||
|
|
4560de58f4 | ||
|
|
7f9f605781 | ||
|
|
41cad5fbed | ||
|
|
e4f15b0f0e | ||
|
|
d4e3ef6eae | ||
|
|
eda90ace80 | ||
|
|
0c127348e1 | ||
|
|
eb6b59af64 | ||
|
|
11066e33f8 | ||
|
|
51a32d64d8 | ||
|
|
77a9f59487 | ||
|
|
1814c4e45b | ||
|
|
722f5fd8d4 | ||
|
|
e9c8dcf96c | ||
|
|
89e0d95883 | ||
|
|
aeb9906717 | ||
|
|
368971ec8b | ||
|
|
0112826daf | ||
|
|
9023e8f7bb | ||
|
|
48fac4e8ce | ||
|
|
edeccce619 | ||
|
|
60668aa210 | ||
|
|
455e8a4281 | ||
|
|
5d7fe7a718 | ||
|
|
64ca95e375 | ||
|
|
837eecbc91 | ||
|
|
26cc10a00c | ||
|
|
f12abe957d | ||
|
|
caaf688582 | ||
|
|
3dfd0cd62a | ||
|
|
18bd86f154 | ||
|
|
338f465019 | ||
|
|
ac13f5e6f9 | ||
|
|
1b6f6d80ea | ||
|
|
18b078414a | ||
|
|
f6ce318061 | ||
|
|
a21c94e3dc | ||
|
|
38b92d56e7 | ||
|
|
a08d95b971 | ||
|
|
339416b38b | ||
|
|
7e2f07486a | ||
|
|
a3e569cdda | ||
|
|
d68d8d82e6 | ||
|
|
997b4a544d | ||
|
|
176d2b622e | ||
|
|
3a9ab23713 | ||
|
|
9e88fcd58c | ||
|
|
39ffc1c3c7 | ||
|
|
69d0e44295 | ||
|
|
d2d5e540ac | ||
|
|
d7bd2d2b2c | ||
|
|
ddf5fc8a42 | ||
|
|
0841c63e0d | ||
|
|
a4d439b975 | ||
|
|
8de509a837 | ||
|
|
219760639a | ||
|
|
38ed8795ab | ||
|
|
55697d7dc9 | ||
|
|
a7fb782aea | ||
|
|
d91c64e428 | ||
|
|
4aa911abc6 | ||
|
|
64c72bb919 | ||
|
|
fec191d3cc | ||
|
|
7430bcbc44 | ||
|
|
eba11d2ba5 | ||
|
|
a3a724f805 | ||
|
|
a770d71890 | ||
|
|
1de866cd09 | ||
|
|
54380f53a2 | ||
|
|
7d870524d3 | ||
|
|
d28aad9a58 | ||
|
|
8be63adbc8 | ||
|
|
7d8f352e0a | ||
|
|
587382c0ba | ||
|
|
0f714ca6bc | ||
|
|
63da1df6fe | ||
|
|
bbe589da44 | ||
|
|
b278e91338 | ||
|
|
f2609e133d | ||
|
|
e14fdbbddb | ||
|
|
a162155919 | ||
|
|
4d7ae382a8 | ||
|
|
0c86eb2dc7 | ||
|
|
70c2db8b9f | ||
|
|
c1dd118d2c | ||
|
|
2d21d91abd | ||
|
|
e5ee05dc0d | ||
|
|
c0d53e176b | ||
|
|
b26d188190 | ||
|
|
0a6382e2af | ||
|
|
1214d8cd26 | ||
|
|
65a30ab0a2 | ||
|
|
61616abef2 | ||
|
|
bb1fcd1ba8 | ||
|
|
6d65121993 | ||
|
|
ecf0bffb79 | ||
|
|
af2ea0a1f2 | ||
|
|
286467db82 | ||
|
|
6b60a31ebf | ||
|
|
54028e5943 | ||
|
|
0c062e839d | ||
|
|
0fcbf05b6d | ||
|
|
f4276c36c9 | ||
|
|
ba05bddf92 | ||
|
|
7a63d75a83 | ||
|
|
da3f74a70e | ||
|
|
5f26656fc5 | ||
|
|
2f76e90d1a | ||
|
|
1296329f02 | ||
|
|
e38b432846 | ||
|
|
549a5101e7 | ||
|
|
031a8648cb | ||
|
|
a8476a8404 | ||
|
|
25c8491fc8 | ||
|
|
d0d637dd47 | ||
|
|
977c6bd44c | ||
|
|
89ad3aa168 | ||
|
|
55b921dab2 | ||
|
|
92d0fe938f | ||
|
|
d07e9b03c4 | ||
|
|
6cbd1cba68 | ||
|
|
3b8df1f143 | ||
|
|
85f7d0a8d5 | ||
|
|
556450a2ff | ||
|
|
6048b12510 | ||
|
|
8cafc1e1ac | ||
|
|
51807d7608 | ||
|
|
e104df5bb7 | ||
|
|
c6df7e5899 | ||
|
|
d0a4300dde | ||
|
|
d8865433f9 | ||
|
|
9c2bd642ba | ||
|
|
09883db208 | ||
|
|
f7f68f7160 | ||
|
|
31f744a8c0 | ||
|
|
bc66c96275 | ||
|
|
87c2acdeae | ||
|
|
6b90023764 | ||
|
|
e502bca962 | ||
|
|
c4d44b72e8 | ||
|
|
e7324bb94f | ||
|
|
8431b2c190 | ||
|
|
7d376ccd8c | ||
|
|
382410249d | ||
|
|
bfb5132362 | ||
|
|
4489dbc630 | ||
|
|
5c31bc8ffc | ||
|
|
baee5f46cf | ||
|
|
66ab7ffa15 | ||
|
|
32df7eb346 | ||
|
|
576b532b45 | ||
|
|
b520414d5a | ||
|
|
b54fd5c588 | ||
|
|
d9b4c01719 | ||
|
|
84d5d968a6 | ||
|
|
9c8717e42f | ||
|
|
3215e97b17 | ||
|
|
975e721432 | ||
|
|
b8bccdd081 | ||
|
|
4310a4d813 | ||
|
|
b96b342561 | ||
|
|
eb1cd11d57 | ||
|
|
a55c72890d | ||
|
|
247e230581 | ||
|
|
1586ea6fe9 | ||
|
|
ae505c50b0 | ||
|
|
fce1b4b1fb | ||
|
|
c6bcbf4951 | ||
|
|
6ed6086da5 | ||
|
|
9f7b16ad19 | ||
|
|
fc70a92071 | ||
|
|
ccaaab2898 | ||
|
|
8d36e630f2 | ||
|
|
eb1f347bca | ||
|
|
7db798186c | ||
|
|
a1cd94bfbb | ||
|
|
d9d2a6f6d9 | ||
|
|
b8c4b82d18 | ||
|
|
b8f615d7a1 | ||
|
|
35d97eb5c5 | ||
|
|
fc15b2e479 | ||
|
|
936df0d290 | ||
|
|
3236beddf8 | ||
|
|
c13f8f10e6 | ||
|
|
d8b530b93c | ||
|
|
2296f211e8 | ||
|
|
a5136b8863 | ||
|
|
913bc38217 | ||
|
|
4b7dca3d2c | ||
|
|
5c58e3ee31 | ||
|
|
49f304bd07 | ||
|
|
c95be42221 | ||
|
|
dbc07e13bb | ||
|
|
5ca40ebc22 | ||
|
|
a8e07274ae | ||
|
|
af99dba018 | ||
|
|
03dfa028d2 | ||
|
|
541b47ac2a | ||
|
|
507a35a9be | ||
|
|
1eddb5463e | ||
|
|
d91769efd4 | ||
|
|
134a8eb272 | ||
|
|
930be98598 | ||
|
|
28e3cb3e93 | ||
|
|
6328671ef8 | ||
|
|
fab1959d00 | ||
|
|
5ab788cd84 | ||
|
|
ce2a6d3739 | ||
|
|
40dd10dfb2 | ||
|
|
e41076e082 | ||
|
|
582fec4e11 | ||
|
|
42ae02aa08 | ||
|
|
79e3fc64c4 | ||
|
|
b188d671d1 | ||
|
|
5ecf1b53ea | ||
|
|
0636311d37 | ||
|
|
219d3b449f | ||
|
|
22eaa89c5a | ||
|
|
79e28a4c2e | ||
|
|
db05b1eb2b | ||
|
|
d20666a228 | ||
|
|
9cc7b03503 | ||
|
|
b38f12d519 | ||
|
|
e736f1ead9 | ||
|
|
b56c1f6023 | ||
|
|
268f0d64fc | ||
|
|
b3ea17736b | ||
|
|
963daeaec5 | ||
|
|
249bd44ebc | ||
|
|
04a1b1c123 | ||
|
|
3922e7afc3 | ||
|
|
f0a97a0d80 | ||
|
|
88713fd590 | ||
|
|
394759e0c8 | ||
|
|
c229f65dcf | ||
|
|
f929861609 | ||
|
|
f024ce7675 | ||
|
|
f3fcf00392 | ||
|
|
08313ef870 | ||
|
|
911c469d69 | ||
|
|
07c089ee04 | ||
|
|
dadc944810 | ||
|
|
80663032a9 | ||
|
|
67c75ee7f0 | ||
|
|
62626737a5 | ||
|
|
e404eed318 | ||
|
|
3c115428ea | ||
|
|
db40ca4aca | ||
|
|
f456d0d6bb | ||
|
|
06fe17eb9f | ||
|
|
7945bdb88f | ||
|
|
f7794ec181 | ||
|
|
16851b3eb3 | ||
|
|
c72d8d4d29 | ||
|
|
2b7436558e | ||
|
|
e59c47d5b1 | ||
|
|
c1523ad16d | ||
|
|
d0be8e27de | ||
|
|
5c66b81289 | ||
|
|
1a42cb2013 | ||
|
|
cf2978cbbb | ||
|
|
8a9733e777 | ||
|
|
ba880c5501 | ||
|
|
788f962fbd | ||
|
|
12f8283560 | ||
|
|
4d27f6b77b | ||
|
|
413ed28246 | ||
|
|
ad084f559a | ||
|
|
3832ab1c21 | ||
|
|
999bceb413 | ||
|
|
e8f6605642 | ||
|
|
3148c65323 | ||
|
|
0a3d2cc68b | ||
|
|
11cf76edb3 | ||
|
|
8833ad415c | ||
|
|
bc290d8e6c | ||
|
|
9c5b3a4060 | ||
|
|
04bbba55c7 | ||
|
|
40b70d5373 | ||
|
|
833d32646e | ||
|
|
6cdefb3cac | ||
|
|
f959d3ee7a | ||
|
|
b0952eabc7 | ||
|
|
43bb4ba4bf | ||
|
|
c2de22abeb | ||
|
|
a0113ee049 | ||
|
|
05db10fda3 | ||
|
|
948ee23a2a | ||
|
|
271a2931b6 | ||
|
|
9fe05edd47 | ||
|
|
c2573702cf | ||
|
|
b8e76b586e | ||
|
|
11a89964b9 | ||
|
|
b5bfcbae59 | ||
|
|
efe95a6953 | ||
|
|
e88a5eca8b | ||
|
|
2e3980e1de | ||
|
|
0ff85c6923 | ||
|
|
e3358d1839 | ||
|
|
f5eac0c7fa | ||
|
|
6034592a27 | ||
|
|
7b00d826d3 | ||
|
|
52ef3586b9 | ||
|
|
4118fcdd14 | ||
|
|
d9e18047d3 | ||
|
|
734f320ade | ||
|
|
79f25cdeb2 | ||
|
|
413f3db617 | ||
|
|
4db11d5143 | ||
|
|
78d28c6b96 | ||
|
|
24df7333a2 | ||
|
|
8694cd8bf5 |
78
.appveyor.yml
Normal file
78
.appveyor.yml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
version: 1.6.x-{build}
|
||||||
|
|
||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /libpng[0-1][0-7]/
|
||||||
|
|
||||||
|
image:
|
||||||
|
- Visual Studio 2022
|
||||||
|
|
||||||
|
shallow_clone: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- TOOLCHAIN: vstudio
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: x86
|
||||||
|
- TOOLCHAIN: vstudio
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: x64
|
||||||
|
- TOOLCHAIN: vstudio
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: arm64
|
||||||
|
- TOOLCHAIN: llvm
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: x64
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: i686
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: cmake
|
||||||
|
ARCH: x86_64
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: configure
|
||||||
|
ARCH: i686
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: configure
|
||||||
|
ARCH: x86_64
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: makefiles
|
||||||
|
ARCH: i686
|
||||||
|
- TOOLCHAIN: msys2
|
||||||
|
AUTOMATION: makefiles
|
||||||
|
ARCH: x86_64
|
||||||
|
|
||||||
|
install:
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe integrate install'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe integrate install'
|
||||||
|
|
||||||
|
before_build:
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_GENERATOR=Visual Studio 17 2022'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x86" set CI_CMAKE_GENERATOR_PLATFORM=Win32'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x64" set CI_CMAKE_GENERATOR_PLATFORM=x64'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_GENERATOR_PLATFORM=ARM64'
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_VARS=-DPNG_TESTS=0'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_GENERATOR=Ninja'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" set CI_CC=clang.exe'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" set CI_CMAKE_GENERATOR=Unix Makefiles'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="i686" set PATH=C:\msys64\mingw32\bin;%PATH%'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="x86_64" set PATH=C:\msys64\mingw64\bin;%PATH%'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" set CI_CC=%ARCH%-w64-mingw32-gcc.exe'
|
||||||
|
- 'set CI_CMAKE_BUILD_FLAGS=-j2'
|
||||||
|
- 'set CI_CTEST_FLAGS=-j2'
|
||||||
|
- 'set CI_MAKE_FLAGS=-j2'
|
||||||
|
- 'set CI_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std'
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
|
||||||
|
- 'if "%TOOLCHAIN%"=="llvm" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="configure" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_configure.sh"'
|
||||||
|
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"'
|
||||||
|
|
||||||
|
cache:
|
||||||
|
- C:\tools\vcpkg\installed
|
||||||
79
.gitignore
vendored
Normal file
79
.gitignore
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Precompiled headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.obj
|
||||||
|
|
||||||
|
# Linker output files
|
||||||
|
*.exp
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
|
||||||
|
# Compiled dynamic libraries
|
||||||
|
*.dll
|
||||||
|
*.dylib
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
|
||||||
|
# Compiled static libraries
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lai
|
||||||
|
*.lib
|
||||||
|
|
||||||
|
# Compiled executables
|
||||||
|
*.app/
|
||||||
|
*.exe
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
*.su
|
||||||
|
|
||||||
|
# Libpng configuration and build artifacts
|
||||||
|
*.out
|
||||||
|
.deps/
|
||||||
|
.dirstamp
|
||||||
|
/Makefile
|
||||||
|
/autom4te.cache/
|
||||||
|
/config.guess~
|
||||||
|
/config.h.in~
|
||||||
|
/config.log
|
||||||
|
/config.status
|
||||||
|
/config.sub~
|
||||||
|
/configure~
|
||||||
|
/install-sh~
|
||||||
|
/libpng-config
|
||||||
|
/libpng.pc
|
||||||
|
/libpng.vers
|
||||||
|
/libpng16-config
|
||||||
|
/libpng16.pc
|
||||||
|
/libtool
|
||||||
|
/stamp-h1
|
||||||
|
pnglibconf.[ch]
|
||||||
|
pnglibconf.dfn
|
||||||
|
pnglibconf.pre
|
||||||
|
pngprefix.h
|
||||||
|
|
||||||
|
# Libpng test artifacts
|
||||||
|
png-fix-itxt
|
||||||
|
pngcp
|
||||||
|
pngfix
|
||||||
|
pngimage
|
||||||
|
pngstest
|
||||||
|
pngtest
|
||||||
|
pngunknown
|
||||||
|
pngvalid
|
||||||
|
timepng
|
||||||
|
pngout.png
|
||||||
|
|
||||||
|
# Libpng CI artifacts
|
||||||
|
out/
|
||||||
33
.travis.yml
Normal file
33
.travis.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
branches:
|
||||||
|
except:
|
||||||
|
- /libpng[0-1][0-7]/
|
||||||
|
|
||||||
|
language: c
|
||||||
|
|
||||||
|
os:
|
||||||
|
- freebsd
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
|
env:
|
||||||
|
- AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=ON"
|
||||||
|
- AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=OFF"
|
||||||
|
- AUTOMATION=configure CI_CONFIGURE_FLAGS="--enable-hardware-optimizations"
|
||||||
|
- AUTOMATION=configure CI_CONFIGURE_FLAGS="--disable-hardware-optimizations"
|
||||||
|
- AUTOMATION=makefiles
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: osx
|
||||||
|
env: AUTOMATION=cmake CI_CMAKE_GENERATOR=Xcode
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- 'if test "$TRAVIS_OS_NAME" = "linux"; then export CI_CC="gcc"; else export CI_CC="clang"; fi'
|
||||||
|
- 'if test "$TRAVIS_OS_NAME" != "osx"; then export CI_SANITIZERS="address,undefined"; fi'
|
||||||
|
- 'export CI_MAKEFILES="scripts/makefile.$CI_CC scripts/makefile.std"'
|
||||||
|
- 'export CI_MAKE_FLAGS=-j2'
|
||||||
|
- 'export CI_CMAKE_BUILD_FLAGS=-j2'
|
||||||
|
- 'export CI_CTEST_FLAGS=-j2'
|
||||||
|
|
||||||
|
script:
|
||||||
|
- './ci/ci_verify_$AUTOMATION.sh'
|
||||||
5
.yamllint.yml
Normal file
5
.yamllint.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
extends: default
|
||||||
|
rules:
|
||||||
|
document-start: disable
|
||||||
|
document-end: disable
|
||||||
|
line-length: disable
|
||||||
133
ANNOUNCE
133
ANNOUNCE
@@ -1,93 +1,66 @@
|
|||||||
|
libpng 1.6.41 - January 24, 2024
|
||||||
|
================================
|
||||||
|
|
||||||
Libpng 1.6.10 - March 6, 2014
|
This is a public release of libpng, intended for use in production code.
|
||||||
|
|
||||||
This is a public release of libpng, intended for use in production codes.
|
|
||||||
|
|
||||||
Files available for download:
|
Files available for download
|
||||||
|
----------------------------
|
||||||
|
|
||||||
Source files with LF line endings (for Unix/Linux) and with a
|
Source files with LF line endings (for Unix/Linux):
|
||||||
"configure" script
|
|
||||||
|
|
||||||
libpng-1.6.10.tar.xz (LZMA-compressed, recommended)
|
* libpng-1.6.41.tar.xz (LZMA-compressed, recommended)
|
||||||
libpng-1.6.10.tar.gz
|
* libpng-1.6.41.tar.gz (deflate-compressed)
|
||||||
|
|
||||||
Source files with CRLF line endings (for Windows), without the
|
Source files with CRLF line endings (for Windows):
|
||||||
"configure" script
|
|
||||||
|
|
||||||
lpng1610.7z (LZMA-compressed, recommended)
|
* lpng1641.7z (LZMA-compressed, recommended)
|
||||||
lpng1610.zip
|
* lpng1641.zip (deflate-compressed)
|
||||||
|
|
||||||
Other information:
|
Other information:
|
||||||
|
|
||||||
libpng-1.6.10-README.txt
|
* README.md
|
||||||
libpng-1.6.10-LICENSE.txt
|
* LICENSE.md
|
||||||
libpng-1.6.10-*.asc (armored detached GPG signatures)
|
* AUTHORS.md
|
||||||
|
* TRADEMARK.md
|
||||||
|
|
||||||
Changes since the last public release (1.6.9):
|
|
||||||
Backported changes from libpng-1.7.0beta30 and beta31:
|
|
||||||
Fixed a large number of instances where PNGCBAPI was omitted from
|
|
||||||
function definitions.
|
|
||||||
Added pngimage test program for png_read_png() and png_write_png()
|
|
||||||
with two new test scripts.
|
|
||||||
Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
|
|
||||||
png_set_packing() in png_read_png().
|
|
||||||
Fixed combination of ~alpha with shift. On read invert alpha, processing
|
|
||||||
occurred after shift processing, which causes the final values to be
|
|
||||||
outside the range that should be produced by the shift. Reversing the
|
|
||||||
order on read makes the two transforms work together correctly and mirrors
|
|
||||||
the order used on write.
|
|
||||||
Do not read invalid sBIT chunks. Previously libpng only checked sBIT
|
|
||||||
values on write, so a malicious PNG writer could therefore cause
|
|
||||||
the read code to return an invalid sBIT chunk, which might lead to
|
|
||||||
application errors or crashes. Such chunks are now skipped (with
|
|
||||||
chunk_benign_error).
|
|
||||||
Make png_read_png() and png_write_png() prototypes in png.h depend
|
|
||||||
upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
|
|
||||||
Support builds with unsupported PNG_TRANSFORM_* values. All of the
|
|
||||||
PNG_TRANSFORM_* values are always defined in png.h and, because they
|
|
||||||
are used for both read and write in some cases, it is not reliable
|
|
||||||
to #if out ones that are totally unsupported. This change adds error
|
|
||||||
detection in png_read_image() and png_write_image() to do a
|
|
||||||
png_app_error() if the app requests something that cannot be done
|
|
||||||
and it adds corresponding code to pngimage.c to handle such options
|
|
||||||
by not attempting to test them.
|
|
||||||
Moved redefines of png_error(), png_warning(), png_chunk_error(),
|
|
||||||
and png_chunk_warning() from pngpriv.h to png.h to make them visible
|
|
||||||
to libpng-calling applications.
|
|
||||||
Moved OS dependent code from arm/arm_init.c, to allow the included
|
|
||||||
implementation of the ARM NEON discovery function to be set at
|
|
||||||
build-time and provide sample implementations from the current code in the
|
|
||||||
contrib/arm-neon subdirectory. The __linux__ code has also been changed to
|
|
||||||
compile and link on Android by using /proc/cpuinfo, and the old linux code
|
|
||||||
is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux
|
|
||||||
dependencies apart from opening /proc/cpuinfo and is C90 compliant.
|
|
||||||
Check for info_ptr == NULL early in png_read_end() so we don't need to
|
|
||||||
run all the png_handle_*() and depend on them to return if info_ptr == NULL.
|
|
||||||
This improves the performance of png_read_end(png_ptr, NULL) and makes
|
|
||||||
it more robust against future programming errors.
|
|
||||||
Check for __has_extension before using it in pngconf.h, to
|
|
||||||
support older Clang versions (Jeremy Sequoia).
|
|
||||||
Treat CRC error handling with png_set_crc_action(), instead of with
|
|
||||||
png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
|
|
||||||
Use a user warning handler in contrib/gregbook/readpng2.c instead of default,
|
|
||||||
so warnings will be put on stderr even if libpng has CONSOLE_IO disabled.
|
|
||||||
Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk
|
|
||||||
after recognizing the IDAT chunk, which avoids an infinite loop while
|
|
||||||
reading a datastream whose first IDAT chunk is of zero-length.
|
|
||||||
This fixes CERT VU#684412 and CVE-2014-0333.
|
|
||||||
Don't recognize known sRGB profiles as sRGB if they have been hacked,
|
|
||||||
but don't reject them and don't issue a copyright violation warning.
|
|
||||||
Moved some documentation from png.h to libpng.3 and libpng-manual.txt
|
|
||||||
Minor editing of contrib/arm-neon/README and contrib/examples/*.c
|
|
||||||
Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS
|
|
||||||
and PNG_USR_CONFIG -> PNG_USER_CONFIG).
|
|
||||||
Un-deprecated png_data_freer().
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Changes from version 1.6.40 to version 1.6.41
|
||||||
(subscription required; visit
|
---------------------------------------------
|
||||||
|
|
||||||
|
* Added SIMD-optimized code for the Loongarch LSX hardware.
|
||||||
|
(Contributed by GuXiWei, JinBo and ZhangLixia)
|
||||||
|
* Fixed the run-time discovery of MIPS MSA hardware.
|
||||||
|
(Contributed by Sui Jingfeng)
|
||||||
|
* Fixed an off-by-one error in the function `png_do_check_palette_indexes`,
|
||||||
|
which failed to recognize errors that might have existed in the first
|
||||||
|
column of a broken palette-encoded image. This was a benign regression
|
||||||
|
accidentally introduced in libpng-1.6.33. No pixel was harmed.
|
||||||
|
(Contributed by Adam Richter; reviewed by John Bowler)
|
||||||
|
* Fixed, improved and modernized the contrib/pngminus programs, i.e.,
|
||||||
|
png2pnm.c and pnm2png.c
|
||||||
|
* Removed old and peculiar portability hacks that were meant to silence
|
||||||
|
warnings issued by gcc version 7.1 alone.
|
||||||
|
(Contributed by John Bowler)
|
||||||
|
* Fixed and modernized the CMake file, and raised the minimum required
|
||||||
|
CMake version from 3.1 to 3.6.
|
||||||
|
(Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
|
||||||
|
* Allowed the configure script to disable the building of auxiliary tools
|
||||||
|
and tests, thus catching up with the CMake file.
|
||||||
|
(Contributed by Carlo Bramini)
|
||||||
|
* Fixed a build issue on Mac.
|
||||||
|
(Contributed by Zixu Wang)
|
||||||
|
* Moved the Autoconf macro files to scripts/autoconf.
|
||||||
|
* Moved the CMake files (except for the main CMakeLists.txt) to
|
||||||
|
scripts/cmake and moved the list of their contributing authors to
|
||||||
|
scripts/cmake/AUTHORS.md
|
||||||
|
* Updated the CI configurations and scripts.
|
||||||
|
* Relicensed the CI scripts to the MIT License.
|
||||||
|
* Improved the test coverage.
|
||||||
|
(Contributed by John Bowler)
|
||||||
|
|
||||||
|
|
||||||
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
|
||||||
|
Subscription is required; visit
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
to subscribe)
|
to subscribe.
|
||||||
or to glennrp at users.sourceforge.net
|
|
||||||
|
|
||||||
Glenn R-P
|
|
||||||
#endif
|
|
||||||
|
|||||||
60
AUTHORS
Normal file
60
AUTHORS
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
PNG REFERENCE LIBRARY AUTHORS
|
||||||
|
=============================
|
||||||
|
|
||||||
|
This is the list of PNG Reference Library ("libpng") Contributing
|
||||||
|
Authors, for copyright and licensing purposes.
|
||||||
|
|
||||||
|
* Adam Richter
|
||||||
|
* Andreas Dilger
|
||||||
|
* Cosmin Truta
|
||||||
|
* Dave Martindale
|
||||||
|
* Eric S. Raymond
|
||||||
|
* Gilles Vollant
|
||||||
|
* Glenn Randers-Pehrson
|
||||||
|
* Greg Roelofs
|
||||||
|
* Guy Eric Schalnat
|
||||||
|
* James Yu
|
||||||
|
* John Bowler
|
||||||
|
* Kevin Bracey
|
||||||
|
* Magnus Holmgren
|
||||||
|
* Mandar Sahastrabuddhe
|
||||||
|
* Mans Rullgard
|
||||||
|
* Matt Sarett
|
||||||
|
* Mike Klein
|
||||||
|
* Pascal Massimino
|
||||||
|
* Paul Schmidt
|
||||||
|
* Philippe Antoine
|
||||||
|
* Qiang Zhou
|
||||||
|
* Sam Bushell
|
||||||
|
* Samuel Williams
|
||||||
|
* Simon-Pierre Cadieux
|
||||||
|
* Tim Wegner
|
||||||
|
* Tom Lane
|
||||||
|
* Tom Tanner
|
||||||
|
* Vadim Barkov
|
||||||
|
* Willem van Schaik
|
||||||
|
* Zhijie Liang
|
||||||
|
* Apple Inc.
|
||||||
|
- Zixu Wang (王子旭)
|
||||||
|
* Arm Holdings
|
||||||
|
- Richard Townsend
|
||||||
|
* Google Inc.
|
||||||
|
- Dan Field
|
||||||
|
- Leon Scroggins III
|
||||||
|
- Matt Sarett
|
||||||
|
- Mike Klein
|
||||||
|
- Sami Boukortt
|
||||||
|
- Wan-Teh Chang
|
||||||
|
* Loongson Technology Corporation Ltd.
|
||||||
|
- GuXiWei (顾希伟)
|
||||||
|
- JinBo (金波)
|
||||||
|
- ZhangLixia (张利霞)
|
||||||
|
|
||||||
|
The build projects, the build scripts, the test scripts, and other
|
||||||
|
files in the "projects", "scripts" and "tests" directories, have
|
||||||
|
other copyright owners, but are released under the libpng license.
|
||||||
|
|
||||||
|
Some files in the "ci" and "contrib" directories, as well as some
|
||||||
|
of the tools-generated files that are distributed with libpng, have
|
||||||
|
other copyright owners, and are released under other open source
|
||||||
|
licenses.
|
||||||
1267
CMakeLists.txt
1267
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
426
INSTALL
426
INSTALL
@@ -1,5 +1,28 @@
|
|||||||
|
|
||||||
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. Enabling or disabling hardware optimizations
|
||||||
|
XV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||||
|
XVI. Setjmp/longjmp issues
|
||||||
|
XVII. Common linking failures
|
||||||
|
XVIII. 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
|
||||||
|
|
||||||
@@ -7,13 +30,28 @@ On Unix/Linux and similar systems, you can simply type
|
|||||||
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 you downloaded a GIT clone, you will need to run ./autogen.sh before
|
||||||
|
running ./configure, to create "configure" and "Makefile.in" which are
|
||||||
|
not included in the GIT repository.
|
||||||
|
|
||||||
|
Note that "configure" is only included in the "*.tar" distributions and not
|
||||||
|
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
|
||||||
|
distributions, see "Building with project files" or "Building with makefiles",
|
||||||
|
below.
|
||||||
|
|
||||||
|
II. Rebuilding the configure scripts
|
||||||
|
|
||||||
If configure does not work on your system, or if you have a need to
|
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
|
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
|
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
|
running ./configure may fix the problem. To be really sure that you
|
||||||
aren't using any of the included pre-built scripts, you can do this:
|
aren't using any of the included pre-built scripts, especially if you
|
||||||
|
are building from a tar distribution instead of a git distribution,
|
||||||
|
do this:
|
||||||
|
|
||||||
./configure --enable-maintainer-mode
|
./configure --enable-maintainer-mode
|
||||||
make maintainer-clean
|
make maintainer-clean
|
||||||
@@ -24,9 +62,12 @@ aren't using any of the included pre-built scripts, you can do this:
|
|||||||
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 +79,8 @@ 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 https://zlib.net/. You can
|
||||||
at the same level as libpng.
|
place zlib in the same directory as libpng or in another directory.
|
||||||
|
|
||||||
If your system already has a preinstalled zlib you will still need
|
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
|
to have access to the zlib.h and zconf.h include files that
|
||||||
@@ -50,49 +91,55 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
|
|||||||
and LD_LIBRARY_PATH in your environment before running "make test"
|
and LD_LIBRARY_PATH in your environment before running "make test"
|
||||||
or "make distcheck":
|
or "make distcheck":
|
||||||
|
|
||||||
ZLIBLIB=/path/to/lib export ZLIBLIB
|
ZLIBLIB=/path/to/lib export ZLIBLIB
|
||||||
ZLIBINC=/path/to/include export ZLIBINC
|
ZLIBINC=/path/to/include export ZLIBINC
|
||||||
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
|
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
|
||||||
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
|
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
|
||||||
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
|
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
|
||||||
|
|
||||||
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
||||||
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
|
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
|
||||||
|
|
||||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
|
As when using the simple configure method described above, "/path" points to
|
||||||
|
the installation directory where you want to put the libpng "lib", "include",
|
||||||
|
and "bin" subdirectories.
|
||||||
|
|
||||||
|
V. Directory structure
|
||||||
|
|
||||||
You can rename the directories that you downloaded (they
|
You can rename the directories that you downloaded (they
|
||||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
|
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
||||||
or "zlib127") 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:
|
||||||
|
|
||||||
.. (the parent directory)
|
.. (the parent directory)
|
||||||
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
|
||||||
|
ci
|
||||||
|
ci_*.sh
|
||||||
configuration files:
|
configuration files:
|
||||||
configure.ac, configure, Makefile.am, Makefile.in,
|
configure.ac, configure, Makefile.am, Makefile.in,
|
||||||
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
|
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
|
||||||
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, etc.
|
||||||
contrib
|
contrib
|
||||||
gregbook
|
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||||
libtests
|
pngminus, pngsuite, tools, visupng
|
||||||
pngminim
|
|
||||||
pngminus
|
|
||||||
pngsuite
|
|
||||||
visupng
|
|
||||||
projects
|
projects
|
||||||
visualc71
|
owatcom, visualc71, vstudio
|
||||||
vstudio
|
|
||||||
scripts
|
scripts
|
||||||
makefile.*
|
makefile.*
|
||||||
*.def (module definition files)
|
*.def (module definition files)
|
||||||
@@ -100,29 +147,35 @@ 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.
|
||||||
|
|
||||||
If you are building libpng with MSVC, you can enter the
|
VI. Building with project files
|
||||||
libpng projects\visualc6 or visualc71 directory and follow the instructions
|
|
||||||
in README.txt.
|
|
||||||
|
|
||||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
If you are building libpng with Microsoft Visual Studio, you can enter
|
||||||
then come back here and run "configure" or choose the appropriate
|
the directory projects\visualc71 or projects\vstudio and follow the
|
||||||
makefile.sys in the scripts directory.
|
instructions in README.txt.
|
||||||
|
|
||||||
|
Otherwise, enter the zlib directory and follow the instructions in
|
||||||
|
zlib/README, then come back here and run "configure" or choose the
|
||||||
|
appropriate makefile 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
|
UNIX example:
|
||||||
UNIX example: cp scripts/makefile.std makefile
|
|
||||||
|
cp scripts/makefile.std Makefile
|
||||||
|
make
|
||||||
|
|
||||||
|
Windows example:
|
||||||
|
|
||||||
|
nmake -f scripts\makefile.vcwin32
|
||||||
|
|
||||||
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.
|
||||||
@@ -139,32 +192,273 @@ test. For more confidence, you can run another test by typing
|
|||||||
Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
|
Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
|
||||||
your output with the result shown in contrib/pngsuite/README.
|
your output with the result shown in contrib/pngsuite/README.
|
||||||
|
|
||||||
Most of the makefiles will allow you to run "make install" to
|
Most of the makefiles used to allow you to run "make install" to put
|
||||||
put the library in its final resting place (if you want to
|
the library in its final resting place, but that feature is no longer
|
||||||
do that, run "make install" in the zlib directory first if necessary).
|
supported. The only tested and supported manners to install libpng are
|
||||||
Some also allow you to run "make test-installed" after you have
|
the conventional build and install procedures driven by the configure
|
||||||
run "make install".
|
script or by the CMake file.
|
||||||
|
|
||||||
|
VIII. Configuring for DOS and other 16-bit platforms
|
||||||
|
|
||||||
|
Officially, the support for 16-bit platforms has been removed.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
You may be or may not be in luck if you target the "large" memory model,
|
||||||
|
but all the smaller models ("small", "compact" and "medium") are known
|
||||||
|
to be unworkable. For DOS users who have access beyond the lower 640K,
|
||||||
|
a "flat" 32-bit DOS model (such as DJGPP) is strongly recommended.
|
||||||
|
|
||||||
|
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.
|
||||||
|
You will also have 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. Therefore, you should limit zlib and libpng
|
||||||
|
to 64K by defining MAXSEG_64K.
|
||||||
|
|
||||||
|
IX. 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.
|
||||||
|
|
||||||
|
X. 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.
|
||||||
|
|
||||||
|
XI. 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.
|
||||||
|
|
||||||
|
XII. Enabling or disabling hardware optimizations
|
||||||
|
|
||||||
|
Certain hardware capabilities, such as the Intel SSE instructions,
|
||||||
|
are normally detected at run time. Enable them with configure options
|
||||||
|
such as one of
|
||||||
|
|
||||||
|
--enable-arm-neon=yes
|
||||||
|
--enable-mips-msa=yes
|
||||||
|
--enable-intel-sse=yes
|
||||||
|
--enable-powerpc-vsx=yes
|
||||||
|
|
||||||
|
or enable them all at once with
|
||||||
|
|
||||||
|
--enable-hardware-optimizations=yes
|
||||||
|
|
||||||
|
or, if you are not using "configure", you can use one
|
||||||
|
or more of
|
||||||
|
|
||||||
|
CPPFLAGS += "-DPNG_ARM_NEON"
|
||||||
|
CPPFLAGS += "-DPNG_MIPS_MSA"
|
||||||
|
CPPFLAGS += "-DPNG_INTEL_SSE"
|
||||||
|
CPPFLAGS += "-DPNG_POWERPC_VSX"
|
||||||
|
|
||||||
|
See for example scripts/makefile.linux-opt
|
||||||
|
|
||||||
|
If you wish to avoid using them,
|
||||||
|
you can disable them via the configure option
|
||||||
|
|
||||||
|
--disable-hardware-optimizations
|
||||||
|
|
||||||
|
to disable them all, or
|
||||||
|
|
||||||
|
--enable-intel-sse=no
|
||||||
|
|
||||||
|
to disable a particular one,
|
||||||
|
or via compiler-command options such as
|
||||||
|
|
||||||
|
CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,
|
||||||
|
-DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"
|
||||||
|
|
||||||
|
If you are using cmake, hardware optimizations are "on"
|
||||||
|
by default. To disable them, use
|
||||||
|
|
||||||
|
cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \
|
||||||
|
-DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no
|
||||||
|
|
||||||
|
or disable them all at once with
|
||||||
|
|
||||||
|
cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
|
||||||
|
|
||||||
|
XIII. 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.
|
||||||
|
|
||||||
|
XIV. 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.
|
||||||
|
|
||||||
|
XV. Common linking failures
|
||||||
|
|
||||||
|
If your application fails to find libpng or zlib entries while linking:
|
||||||
|
|
||||||
|
Be sure "-lz" appears after "-lpng" on your linking command.
|
||||||
|
|
||||||
|
Be sure you have built libpng, zlib, and your application for the
|
||||||
|
same platform (e.g., 32-bit or 64-bit).
|
||||||
|
|
||||||
|
If you are using the vstudio project, observe the WARNING in
|
||||||
|
project/vstudio/README.txt.
|
||||||
|
|
||||||
|
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.
|
Copyright (c) 2022 Cosmin Truta
|
||||||
=================================================
|
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
|
||||||
|
This document is released under the libpng license.
|
||||||
The ./configure script should work compatibly with what scripts/makefile.*
|
For conditions of distribution and use, see the disclaimer
|
||||||
did, however there are some options you might need to add to configure
|
and license in png.h.
|
||||||
explicitly, which previously was done semi-automatically (if you didn't edit
|
|
||||||
scripts/makefile.* yourself, that is)
|
|
||||||
|
|
||||||
CFLAGS="-Wall -O -funroll-loops \
|
|
||||||
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
|
|
||||||
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
|
||||||
|
|
||||||
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
|
||||||
/usr/include/libpng%NN%, or whatever.
|
|
||||||
|
|
||||||
If you find that the configure script is out-of-date or is not supporting
|
|
||||||
your platform properly, try running autogen.sh to regenerate "configure",
|
|
||||||
"Makefile.in", and the other configuration files. Then try configure again.
|
|
||||||
|
|
||||||
|
|||||||
181
LICENSE
181
LICENSE
@@ -1,111 +1,134 @@
|
|||||||
|
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||||
|
=========================================
|
||||||
|
|
||||||
This copy of the libpng notices is provided for your convenience. In case of
|
PNG Reference Library License version 2
|
||||||
any discrepancy between this copy and the notices in the file png.h that is
|
---------------------------------------
|
||||||
included in the libpng distribution, the latter shall prevail.
|
|
||||||
|
|
||||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
* Copyright (c) 1995-2024 The PNG Reference Library Authors.
|
||||||
|
* Copyright (c) 2018-2024 Cosmin Truta.
|
||||||
|
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
|
||||||
|
* Copyright (c) 1996-1997 Andreas Dilger.
|
||||||
|
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
|
|
||||||
If you modify libpng you may insert additional notices immediately following
|
The software is supplied "as is", without warranty of any kind,
|
||||||
this sentence.
|
express or implied, including, without limitation, the warranties
|
||||||
|
of merchantability, fitness for a particular purpose, title, and
|
||||||
|
non-infringement. In no event shall the Copyright owners, or
|
||||||
|
anyone distributing the software, be liable for any damages or
|
||||||
|
other liability, whether in contract, tort or otherwise, arising
|
||||||
|
from, out of, or in connection with the software, or the use or
|
||||||
|
other dealings in the software, even if advised of the possibility
|
||||||
|
of such damage.
|
||||||
|
|
||||||
This code is released under the libpng license.
|
Permission is hereby granted to use, copy, modify, and distribute
|
||||||
|
this software, or portions hereof, for any purpose, without fee,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
libpng versions 1.2.6, August 15, 2004, through 1.6.10, March 6, 2014, are
|
1. The origin of this software must not be misrepresented; you
|
||||||
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
|
must not claim that you wrote the original software. If you
|
||||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
use this software in a product, an acknowledgment in the product
|
||||||
with the following individual added to the list of Contributing Authors
|
documentation would be appreciated, but is not required.
|
||||||
|
|
||||||
Cosmin Truta
|
2. Altered source versions must be plainly marked as such, and must
|
||||||
|
not be misrepresented as being the original software.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
3. This Copyright notice may not be removed or altered from any
|
||||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
source or altered source distribution.
|
||||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
|
||||||
with the following individuals added to the list of Contributing Authors
|
|
||||||
|
|
||||||
Simon-Pierre Cadieux
|
|
||||||
Eric S. Raymond
|
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
|
||||||
Gilles Vollant
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
|
||||||
|
Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
|
||||||
|
derived from libpng-1.0.6, and are distributed according to the same
|
||||||
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
|
added to the list of Contributing Authors:
|
||||||
|
|
||||||
|
Simon-Pierre Cadieux
|
||||||
|
Eric S. Raymond
|
||||||
|
Mans Rullgard
|
||||||
|
Cosmin Truta
|
||||||
|
Gilles Vollant
|
||||||
|
James Yu
|
||||||
|
Mandar Sahastrabuddhe
|
||||||
|
Google Inc.
|
||||||
|
Vadim Barkov
|
||||||
|
|
||||||
and with the following additions to the disclaimer:
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
There is no warranty against interference with your enjoyment of the
|
There is no warranty against interference with your enjoyment of
|
||||||
library or against infringement. There is no warranty that our
|
the library or against infringement. There is no warranty that our
|
||||||
efforts or the library will fulfill any of your particular purposes
|
efforts or the library will fulfill any of your particular purposes
|
||||||
or needs. This library is provided with all faults, and the entire
|
or needs. This library is provided with all faults, and the entire
|
||||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
risk of satisfactory quality, performance, accuracy, and effort is
|
||||||
the user.
|
with the user.
|
||||||
|
|
||||||
|
Some files in the "contrib" directory and some configure-generated
|
||||||
|
files that are distributed with libpng have other copyright owners, and
|
||||||
|
are released under other open source licenses.
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
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, are derived from
|
||||||
distributed according to the same disclaimer and license as libpng-0.96,
|
libpng-0.96, and are distributed according to the same disclaimer and
|
||||||
with the following individuals added to the list of Contributing Authors:
|
license as libpng-0.96, with the following 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, are derived from libpng-0.88,
|
||||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
and are distributed according to the same disclaimer and license as
|
||||||
with the following individuals added to the list of Contributing Authors:
|
libpng-0.88, with the following individuals added to the list of
|
||||||
|
Contributing Authors:
|
||||||
|
|
||||||
John Bowler
|
John Bowler
|
||||||
Kevin Bracey
|
Kevin Bracey
|
||||||
Sam Bushell
|
Sam Bushell
|
||||||
Magnus Holmgren
|
Magnus Holmgren
|
||||||
Greg Roelofs
|
Greg Roelofs
|
||||||
Tom Tanner
|
Tom Tanner
|
||||||
|
|
||||||
|
Some files in the "scripts" directory have other copyright owners,
|
||||||
|
but are released under this license.
|
||||||
|
|
||||||
libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
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:
|
||||||
|
|
||||||
Andreas Dilger
|
Andreas Dilger
|
||||||
Dave Martindale
|
Dave Martindale
|
||||||
Guy Eric Schalnat
|
Guy Eric Schalnat
|
||||||
Paul Schmidt
|
Paul Schmidt
|
||||||
Tim Wegner
|
Tim Wegner
|
||||||
|
|
||||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
The PNG Reference Library is supplied "AS IS". The Contributing
|
||||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
Authors and Group 42, Inc. disclaim all warranties, expressed or
|
||||||
including, without limitation, the warranties of merchantability and of
|
implied, including, without limitation, the warranties of
|
||||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
merchantability and of fitness for any purpose. The Contributing
|
||||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
Authors and Group 42, Inc. assume no liability for direct, indirect,
|
||||||
or consequential damages, which may result from the use of the PNG
|
incidental, special, exemplary, or consequential damages, which may
|
||||||
Reference Library, even if advised of the possibility of such damage.
|
result from the use of the PNG Reference Library, even if advised of
|
||||||
|
the possibility of such damage.
|
||||||
|
|
||||||
Permission is hereby granted to use, copy, modify, and distribute this
|
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,
|
||||||
fee, and encourage the use of this source code as a component to
|
without fee, and encourage the use of this source code as a component
|
||||||
supporting the PNG file format in commercial products. If you use this
|
to supporting the PNG file format in commercial products. If you use
|
||||||
source code in a product, acknowledgment is not required but would be
|
this source code in a product, acknowledgment is not required but would
|
||||||
appreciated.
|
be appreciated.
|
||||||
|
|
||||||
|
|
||||||
A "png_get_copyright" function is available, for convenient use in "about"
|
|
||||||
boxes and the like:
|
|
||||||
|
|
||||||
printf("%s",png_get_copyright(NULL));
|
|
||||||
|
|
||||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
|
||||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
|
||||||
|
|
||||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
|
||||||
certification mark of the Open Source Initiative.
|
|
||||||
|
|
||||||
Glenn Randers-Pehrson
|
|
||||||
glennrp at users.sourceforge.net
|
|
||||||
March 6, 2014
|
|
||||||
|
|||||||
119
Makefile.am
119
Makefile.am
@@ -1,16 +1,32 @@
|
|||||||
# Makefile.am:
|
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||||
# Source file for Makefile.in (and hence Makefile)
|
|
||||||
#
|
#
|
||||||
|
# Copyright (c) 2018-2024 Cosmin Truta
|
||||||
|
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||||
|
#
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I scripts
|
ACLOCAL_AMFLAGS = -I scripts/autoconf
|
||||||
|
|
||||||
# test programs - run on make check, make distcheck
|
# test programs - run on make check, make distcheck
|
||||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage
|
if ENABLE_TESTS
|
||||||
|
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
|
||||||
|
if HAVE_CLOCK_GETTIME
|
||||||
|
check_PROGRAMS += timepng
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
check_PROGRAMS=
|
||||||
|
endif
|
||||||
|
|
||||||
# Utilities - installed
|
# Utilities - installed
|
||||||
|
if ENABLE_TOOLS
|
||||||
bin_PROGRAMS= pngfix png-fix-itxt
|
bin_PROGRAMS= pngfix png-fix-itxt
|
||||||
|
else
|
||||||
|
bin_PROGRAMS=
|
||||||
|
endif
|
||||||
|
|
||||||
# This ensures that pnglibconf.h gets built at the start of 'make all' or
|
# 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,
|
# 'make check', but it does not add dependencies to the individual programs,
|
||||||
@@ -22,6 +38,7 @@ bin_PROGRAMS= pngfix png-fix-itxt
|
|||||||
# always wrong and always very confusing.
|
# always wrong and always very confusing.
|
||||||
BUILT_SOURCES = pnglibconf.h
|
BUILT_SOURCES = pnglibconf.h
|
||||||
|
|
||||||
|
if ENABLE_TESTS
|
||||||
pngtest_SOURCES = pngtest.c
|
pngtest_SOURCES = pngtest.c
|
||||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
@@ -37,36 +54,41 @@ pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
|||||||
pngimage_SOURCES = contrib/libtests/pngimage.c
|
pngimage_SOURCES = contrib/libtests/pngimage.c
|
||||||
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
timepng_SOURCES = contrib/libtests/timepng.c
|
||||||
|
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
pngcp_SOURCES = contrib/tools/pngcp.c
|
||||||
|
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ENABLE_TOOLS
|
||||||
pngfix_SOURCES = contrib/tools/pngfix.c
|
pngfix_SOURCES = contrib/tools/pngfix.c
|
||||||
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Generally these are single line shell scripts to run a test with a particular
|
# Generally these are single line shell scripts to run a test with a particular
|
||||||
# set of parameters:
|
# set of parameters:
|
||||||
|
if ENABLE_TESTS
|
||||||
TESTS =\
|
TESTS =\
|
||||||
tests/pngtest\
|
tests/pngtest-all\
|
||||||
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
||||||
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
||||||
tests/pngvalid-gamma-expand16-background\
|
tests/pngvalid-gamma-expand16-background\
|
||||||
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
|
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
|
||||||
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
|
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
|
||||||
tests/pngvalid-progressive-interlace-size\
|
tests/pngvalid-progressive-size\
|
||||||
tests/pngvalid-progressive-interlace-standard\
|
tests/pngvalid-progressive-interlace-standard\
|
||||||
tests/pngvalid-progressive-interlace-transform\
|
tests/pngvalid-transform\
|
||||||
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||||
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
|
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
|
||||||
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
|
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
|
||||||
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
|
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
|
||||||
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-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
||||||
tests/pngimage-quick tests/pngimage-full
|
tests/pngimage-quick tests/pngimage-full
|
||||||
|
endif
|
||||||
# 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
|
||||||
@@ -86,7 +108,39 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
|||||||
|
|
||||||
if PNG_ARM_NEON
|
if PNG_ARM_NEON
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||||
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
arm/filter_neon.S arm/filter_neon_intrinsics.c \
|
||||||
|
arm/palette_neon_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_MIPS_MSA
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\
|
||||||
|
mips/filter_msa_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_MIPS_MMI
|
||||||
|
if !PNG_MIPS_MSA
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c
|
||||||
|
endif
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/filter_mmi_inline_assembly.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_INTEL_SSE
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
|
||||||
|
intel/filter_sse2_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_POWERPC_VSX
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
|
||||||
|
powerpc/filter_vsx_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_LOONGARCH_LSX
|
||||||
|
noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
|
||||||
|
loongarch/filter_lsx_intrinsics.c
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||||
|
# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||||
endif
|
endif
|
||||||
|
|
||||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||||
@@ -109,6 +163,10 @@ else
|
|||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if PNG_LOONGARCH_LSX
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||||
|
endif
|
||||||
|
|
||||||
#distribute headers in /usr/include/libpng/*
|
#distribute headers in /usr/include/libpng/*
|
||||||
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
|
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
|
||||||
pkginclude_HEADERS= png.h pngconf.h
|
pkginclude_HEADERS= png.h pngconf.h
|
||||||
@@ -123,17 +181,18 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
|||||||
# from those directories being included. This only works if the configure is
|
# from those directories being included. This only works if the configure is
|
||||||
# not done in the source directory!
|
# not done in the source directory!
|
||||||
EXTRA_DIST= \
|
EXTRA_DIST= \
|
||||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
|
||||||
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}/ci ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
$(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
|
||||||
|
|
||||||
CLEANFILES= *.tf? 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 \
|
||||||
check.new pnglibconf.* pngprefix.h symbols.new pngtest-log.txt \
|
check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \
|
||||||
|
pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \
|
||||||
$(SCRIPT_CLEANFILES)
|
$(SCRIPT_CLEANFILES)
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
||||||
@@ -152,7 +211,7 @@ AM_CFLAGS = ${PNG_COPTS}
|
|||||||
# checks for this and sets DFNCPP appropriately.
|
# checks for this and sets DFNCPP appropriately.
|
||||||
DFNCPP = @DFNCPP@
|
DFNCPP = @DFNCPP@
|
||||||
|
|
||||||
SUFFIXES = .chk .dfn .out
|
SUFFIXES = .chk .out
|
||||||
|
|
||||||
$(PNGLIB_BASENAME).pc: libpng.pc
|
$(PNGLIB_BASENAME).pc: libpng.pc
|
||||||
cp libpng.pc $@
|
cp libpng.pc $@
|
||||||
@@ -224,6 +283,7 @@ contrib/libtests/timepng.o: pnglibconf.h
|
|||||||
|
|
||||||
contrib/tools/makesRGB.o: pnglibconf.h
|
contrib/tools/makesRGB.o: pnglibconf.h
|
||||||
contrib/tools/pngfix.o: pnglibconf.h
|
contrib/tools/pngfix.o: pnglibconf.h
|
||||||
|
contrib/tools/pngcp.o: pnglibconf.h
|
||||||
|
|
||||||
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
|
# 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
|
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
|
||||||
@@ -237,18 +297,17 @@ if DO_PNG_PREFIX
|
|||||||
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.dfn.out:
|
.c.out:
|
||||||
rm -f $@ $*.c $*.tf[12]
|
rm -f $@ $*.tf[12]
|
||||||
test -d scripts || mkdir scripts || test -d scripts
|
test -d scripts || mkdir scripts || test -d scripts
|
||||||
echo '#include "$<"' >$*.c
|
|
||||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
$(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
|
||||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||||
rm -f $*.c $*.tf1
|
rm -f $*.tf1
|
||||||
mv $*.tf2 $@
|
mv $*.tf2 $@
|
||||||
|
|
||||||
# The .dfn file for pnglibconf.h is machine generated
|
# The .c file for pnglibconf.h is machine generated
|
||||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||||
rm -f $@ $*.tf[45]
|
rm -f $@ $*.tf[45]
|
||||||
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||||
@@ -268,7 +327,7 @@ scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.ou
|
|||||||
|
|
||||||
# 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 pngconf.h
|
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||||
rm -f $@ pnglibconf.tf[67]
|
rm -f $@ pnglibconf.tf[67]
|
||||||
test -z "$(CPPFLAGS)"
|
test -z "$(CPPFLAGS)"
|
||||||
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||||
|
|||||||
2550
Makefile.in
Normal file
2550
Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
336
README
336
README
@@ -1,49 +1,88 @@
|
|||||||
README for libpng version 1.6.10 - March 6, 2014 (shared library 16.0)
|
README for libpng version 1.6.41
|
||||||
See the note about version numbers near the top of png.h
|
================================
|
||||||
|
|
||||||
See INSTALL for instructions on how to install libpng.
|
See the note about version numbers near the top of `png.h`.
|
||||||
|
See `INSTALL` for instructions on how to install libpng.
|
||||||
|
|
||||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
Libpng comes in several distribution formats. Get `libpng-*.tar.gz`
|
||||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
|
||||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings.
|
||||||
|
|
||||||
Version 0.89 was the first official release of libpng. Don't let the
|
For a detailed description on using libpng, read `libpng-manual.txt`.
|
||||||
fact that it's the first release fool you. The libpng library has been in
|
For examples of libpng in a program, see `example.c` and `pngtest.c`.
|
||||||
extensive use and testing since mid-1995. By late 1997 it had
|
For usage information and restrictions (what little they are) on libpng,
|
||||||
finally gotten to the stage where there hadn't been significant
|
see `png.h`. For a description on using zlib (the compression library
|
||||||
changes to the API in some time, and people have a bad feeling about
|
used by libpng) and zlib's restrictions, see `zlib.h`.
|
||||||
libraries with versions < 1.0. Version 1.0.0 was released in
|
|
||||||
March 1998.
|
|
||||||
|
|
||||||
****
|
You should use zlib 1.0.4 or later to run this, but it _may_ work with
|
||||||
Note that some of the changes to the png_info structure render this
|
versions as old as zlib 0.95. Even so, there are bugs in older zlib
|
||||||
|
versions which can cause the output of invalid compression streams for
|
||||||
|
some images.
|
||||||
|
|
||||||
|
You should also note that zlib is a compression library that is useful
|
||||||
|
for more things than just PNG files. You can use zlib as a drop-in
|
||||||
|
replacement for `fread()` and `fwrite()`, if you are so inclined.
|
||||||
|
|
||||||
|
zlib should be available at the same place that libpng is, or at
|
||||||
|
https://zlib.net .
|
||||||
|
|
||||||
|
You may also want a copy of the PNG specification. It is available
|
||||||
|
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||||
|
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||||
|
|
||||||
|
This code is currently being archived at https://libpng.sourceforge.io
|
||||||
|
in the download area, and at http://libpng.download/src .
|
||||||
|
|
||||||
|
This release, based in a large way on Glenn's, Guy's and Andreas'
|
||||||
|
earlier work, was created and will be supported by myself and the PNG
|
||||||
|
development group.
|
||||||
|
|
||||||
|
Send comments, corrections and commendations to `png-mng-implement`
|
||||||
|
at `lists.sourceforge.net`. (Subscription is required; visit
|
||||||
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
|
to subscribe.)
|
||||||
|
|
||||||
|
Send general questions about the PNG specification to `png-mng-misc`
|
||||||
|
at `lists.sourceforge.net`. (Subscription is required; visit
|
||||||
|
https://lists.sourceforge.net/lists/listinfo/png-mng-misc
|
||||||
|
to subscribe.)
|
||||||
|
|
||||||
|
Historical notes
|
||||||
|
----------------
|
||||||
|
|
||||||
|
The libpng library has been in extensive use and testing since mid-1995.
|
||||||
|
Version 0.89, published a year later, was the first official release.
|
||||||
|
By late 1997, it had finally gotten to the stage where there hadn't
|
||||||
|
been significant changes to the API in some time, and people have a bad
|
||||||
|
feeling about libraries with versions below 1.0. Version 1.0.0 was
|
||||||
|
released in March 1998.
|
||||||
|
|
||||||
|
Note that some of the changes to the `png_info` structure render this
|
||||||
version of the library binary incompatible with libpng-0.89 or
|
version of the library binary incompatible with libpng-0.89 or
|
||||||
earlier versions if you are using a shared library. The type of the
|
earlier versions if you are using a shared library. The type of the
|
||||||
"filler" parameter for png_set_filler() has changed from png_byte to
|
`filler` parameter for `png_set_filler()` has changed from `png_byte`
|
||||||
png_uint_32, which will affect shared-library applications that use
|
to `png_uint_32`, which will affect shared-library applications that
|
||||||
this function.
|
use this function.
|
||||||
|
|
||||||
To avoid problems with changes to the internals of png_info_struct,
|
To avoid problems with changes to the internals of the `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
|
||||||
Additions since 0.90 include the ability to compile libpng as a
|
reside in private `pngstruct.h` and `pnginfo.h` header files that are
|
||||||
Windows DLL, and new APIs for accessing data in the info struct.
|
not accessible to applications. It is strongly suggested that new
|
||||||
Experimental functions include the ability to set weighting and cost
|
programs use the new APIs (as shown in `example.c` and `pngtest.c`),
|
||||||
factors for row filter selection, direct reads of integers from buffers
|
and older programs be converted to the new format, to facilitate
|
||||||
on big-endian processors that support misaligned data access, faster
|
upgrades in the future.
|
||||||
methods of doing alpha composition, and more accurate 16->8 bit color
|
|
||||||
conversion.
|
|
||||||
|
|
||||||
The additions since 0.89 include the ability to read from a PNG stream
|
The additions since 0.89 include the ability to read from a PNG stream
|
||||||
which has had some (or all) of the signature bytes read by the calling
|
which has had some (or all) of the signature bytes read by the calling
|
||||||
@@ -53,150 +92,91 @@ the library action on the detection of chunk CRC errors. It is possible
|
|||||||
to set different actions based on whether the CRC error occurred in a
|
to set different actions based on whether the CRC error occurred in a
|
||||||
critical or an ancillary chunk.
|
critical or an ancillary chunk.
|
||||||
|
|
||||||
The changes made to the library, and bugs fixed are based on discussions
|
The additions since 0.90 include the ability to compile libpng as a
|
||||||
on the PNG-implement mailing list and not on material submitted
|
Windows DLL, and new APIs for accessing data in the `info_struct`.
|
||||||
privately to Guy, Andreas, or Glenn. They will forward any good
|
Experimental functions included the ability to set weighting and cost
|
||||||
suggestions to the list.
|
factors for row filter selection, direct reads of integers from buffers
|
||||||
|
on big-endian processors that support misaligned data access, faster
|
||||||
|
methods of doing alpha composition, and more accurate 16-to-8 bit color
|
||||||
|
conversion. Some of these experimental functions, such as the weighted
|
||||||
|
filter heuristics, have since been removed.
|
||||||
|
|
||||||
For a detailed description on using libpng, read libpng-manual.txt. For
|
Files included in this distribution
|
||||||
examples of libpng in a program, see example.c and pngtest.c. For usage
|
-----------------------------------
|
||||||
information and restrictions (what little they are) on libpng, see
|
|
||||||
png.h. For a description on using zlib (the compression library used by
|
|
||||||
libpng) and zlib's restrictions, see zlib.h
|
|
||||||
|
|
||||||
I have included a general makefile, as well as several machine and
|
ANNOUNCE => Announcement of this version, with recent changes
|
||||||
compiler specific ones, but you may have to modify one for your own needs.
|
AUTHORS => List of contributing authors
|
||||||
|
CHANGES => Description of changes between libpng versions
|
||||||
|
INSTALL => Instructions to install libpng
|
||||||
|
LICENSE => License to use and redistribute libpng
|
||||||
|
README => This file
|
||||||
|
TODO => Things not implemented in the current library
|
||||||
|
TRADEMARK => Trademark information
|
||||||
|
example.c => Example code for using libpng functions
|
||||||
|
libpng.3 => Manual page for libpng (includes libpng-manual.txt)
|
||||||
|
libpng-manual.txt => Description of libpng and its functions
|
||||||
|
libpngpf.3 => Manual page for libpng's private functions (deprecated)
|
||||||
|
png.5 => Manual page for the PNG format
|
||||||
|
png.c => Basic interface functions common to library
|
||||||
|
png.h => Library function and interface declarations (public)
|
||||||
|
pngpriv.h => Library function and interface declarations (private)
|
||||||
|
pngconf.h => System specific library configuration (public)
|
||||||
|
pngstruct.h => png_struct declaration (private)
|
||||||
|
pnginfo.h => png_info struct declaration (private)
|
||||||
|
pngdebug.h => debugging macros (private)
|
||||||
|
pngerror.c => Error/warning message I/O functions
|
||||||
|
pngget.c => Functions for retrieving info from struct
|
||||||
|
pngmem.c => Memory handling functions
|
||||||
|
pngbar.png => PNG logo, 88x31
|
||||||
|
pngnow.png => PNG logo, 98x31
|
||||||
|
pngpread.c => Progressive reading functions
|
||||||
|
pngread.c => Read data/helper high-level functions
|
||||||
|
pngrio.c => Lowest-level data read I/O functions
|
||||||
|
pngrtran.c => Read data transformation functions
|
||||||
|
pngrutil.c => Read data utility functions
|
||||||
|
pngset.c => Functions for storing data into the info_struct
|
||||||
|
pngtest.c => Library test program
|
||||||
|
pngtest.png => Library test sample image
|
||||||
|
pngtrans.c => Common data transformation functions
|
||||||
|
pngwio.c => Lowest-level write I/O functions
|
||||||
|
pngwrite.c => High-level write functions
|
||||||
|
pngwtran.c => Write data transformations
|
||||||
|
pngwutil.c => Write utility functions
|
||||||
|
arm/ => Optimized code for the ARM platform
|
||||||
|
intel/ => Optimized code for the INTEL-SSE2 platform
|
||||||
|
mips/ => Optimized code for the MIPS platform
|
||||||
|
powerpc/ => Optimized code for the PowerPC platform
|
||||||
|
ci/ => Scripts for continuous integration
|
||||||
|
contrib/ => External contributions
|
||||||
|
arm-neon/ => Optimized code for the ARM-NEON platform
|
||||||
|
mips-msa/ => Optimized code for the MIPS-MSA platform
|
||||||
|
powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
|
||||||
|
examples/ => Examples of libpng usage
|
||||||
|
gregbook/ => Source code for PNG reading and writing, from
|
||||||
|
"PNG: The Definitive Guide" by Greg Roelofs,
|
||||||
|
O'Reilly, 1999
|
||||||
|
libtests/ => Test programs
|
||||||
|
oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing
|
||||||
|
libpng
|
||||||
|
pngminim/ => Minimal decoder, encoder, and progressive decoder
|
||||||
|
programs demonstrating the use of pngusr.dfa
|
||||||
|
pngminus/ => Simple pnm2png and png2pnm programs
|
||||||
|
pngsuite/ => Test images
|
||||||
|
testpngs/ => Test images
|
||||||
|
tools/ => Various tools
|
||||||
|
visupng/ => VisualPng, a Windows viewer for PNG images
|
||||||
|
projects/ => Project files and workspaces for various IDEs
|
||||||
|
owatcom/ => OpenWatcom project
|
||||||
|
visualc71/ => Microsoft Visual C++ 7.1 workspace
|
||||||
|
vstudio/ => Microsoft Visual Studio workspace
|
||||||
|
scripts/ => Scripts and makefiles for building libpng
|
||||||
|
(see scripts/README.txt for the complete list)
|
||||||
|
tests/ => Test scripts
|
||||||
|
|
||||||
You should use zlib 1.0.4 or later to run this, but it MAY work with
|
Good luck, and happy coding!
|
||||||
versions as old as zlib 0.95. Even so, there are bugs in older zlib
|
|
||||||
versions which can cause the output of invalid compression streams for
|
|
||||||
some images. You will definitely need zlib 1.0.4 or later if you are
|
|
||||||
taking advantage of the MS-DOS "far" structure allocation for the small
|
|
||||||
and medium memory models. You should also note that zlib is a
|
|
||||||
compression library that is useful for more things than just PNG files.
|
|
||||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
|
||||||
you are so inclined.
|
|
||||||
|
|
||||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
* Cosmin Truta (current maintainer, since 2018)
|
||||||
|
* Glenn Randers-Pehrson (former maintainer, 1998-2018)
|
||||||
You may also want a copy of the PNG specification. It is available
|
* Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||||
these at http://www.libpng.org/pub/png/documents/
|
(formerly of Group 42, Inc.)
|
||||||
|
|
||||||
This code is currently being archived at libpng.sf.net in the
|
|
||||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
|
||||||
in any of those places, e-mail me, and I'll help you find it.
|
|
||||||
|
|
||||||
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,
|
|
||||||
and any modifications you needed to make to get libpng to compile,
|
|
||||||
along with a #define variable to tell what compiler/system you are on.
|
|
||||||
If you needed to add transformations to libpng, or wish libpng would
|
|
||||||
provide the image in a different way, drop me a note (and code, if
|
|
||||||
possible), so I can consider supporting the transformation.
|
|
||||||
Finally, if you get any warning messages when compiling libpng
|
|
||||||
(note: not zlib), and they are easy to fix, I'd appreciate the
|
|
||||||
fix. Please mention "libpng" somewhere in the subject line. Thanks.
|
|
||||||
|
|
||||||
This release was created and will be supported by myself (of course
|
|
||||||
based in a large way on Guy's and Andreas' earlier work), and the PNG
|
|
||||||
development group.
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at
|
|
||||||
lists.sourceforge.net (subscription required; visit
|
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
|
||||||
to subscribe) or to glennrp at users.sourceforge.net
|
|
||||||
|
|
||||||
You can't reach Guy, the original libpng author, at the addresses
|
|
||||||
given in previous versions of this document. He and Andreas will
|
|
||||||
read mail addressed to the png-implement list, however.
|
|
||||||
|
|
||||||
Please do not send general questions about PNG. Send them to
|
|
||||||
png-mng-misc at lists.sf.net (subscription required; visit
|
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
|
||||||
subscribe). If you have a question about something
|
|
||||||
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,
|
|
||||||
and ...". If in doubt, send questions to me. I'll bounce them
|
|
||||||
to others, if necessary.
|
|
||||||
|
|
||||||
Please do not send suggestions on how to change PNG. We have
|
|
||||||
been discussing PNG for nineteen years now, and it is official and
|
|
||||||
finished. If you have suggestions for libpng, however, I'll
|
|
||||||
gladly listen. Even if your suggestion is not used immediately,
|
|
||||||
it may be used later.
|
|
||||||
|
|
||||||
Files in this distribution:
|
|
||||||
|
|
||||||
ANNOUNCE => Announcement of this version, with recent changes
|
|
||||||
CHANGES => Description of changes between libpng versions
|
|
||||||
KNOWNBUG => List of known bugs and deficiencies
|
|
||||||
LICENSE => License to use and redistribute libpng
|
|
||||||
README => This file
|
|
||||||
TODO => Things not implemented in the current library
|
|
||||||
Y2KINFO => Statement of Y2K compliance
|
|
||||||
example.c => Example code for using libpng functions
|
|
||||||
libpng.3 => manual page for libpng (includes libpng-manual.txt)
|
|
||||||
libpng-manual.txt => Description of libpng and its functions
|
|
||||||
libpngpf.3 => manual page for libpng's private functions
|
|
||||||
png.5 => manual page for the PNG format
|
|
||||||
png.c => Basic interface functions common to library
|
|
||||||
png.h => Library function and interface declarations (public)
|
|
||||||
pngpriv.h => Library function and interface declarations (private)
|
|
||||||
pngconf.h => System specific library configuration (public)
|
|
||||||
pngstruct.h => png_struct declaration (private)
|
|
||||||
pnginfo.h => png_info struct declaration (private)
|
|
||||||
pngdebug.h => debugging macros (private)
|
|
||||||
pngerror.c => Error/warning message I/O functions
|
|
||||||
pngget.c => Functions for retrieving info from struct
|
|
||||||
pngmem.c => Memory handling functions
|
|
||||||
pngbar.png => PNG logo, 88x31
|
|
||||||
pngnow.png => PNG logo, 98x31
|
|
||||||
pngpread.c => Progressive reading functions
|
|
||||||
pngread.c => Read data/helper high-level functions
|
|
||||||
pngrio.c => Lowest-level data read I/O functions
|
|
||||||
pngrtran.c => Read data transformation functions
|
|
||||||
pngrutil.c => Read data utility functions
|
|
||||||
pngset.c => Functions for storing data into the info_struct
|
|
||||||
pngtest.c => Library test program
|
|
||||||
pngtest.png => Library test sample image
|
|
||||||
pngtrans.c => Common data transformation functions
|
|
||||||
pngwio.c => Lowest-level write I/O functions
|
|
||||||
pngwrite.c => High-level write functions
|
|
||||||
pngwtran.c => Write data transformations
|
|
||||||
pngwutil.c => Write utility functions
|
|
||||||
arm => Contains optimized code for the ARM platform
|
|
||||||
contrib => Contributions
|
|
||||||
examples => Example programs
|
|
||||||
gregbook => source code for PNG reading and writing, from
|
|
||||||
Greg Roelofs' "PNG: The Definitive Guide",
|
|
||||||
O'Reilly, 1999
|
|
||||||
libtests => Test programs
|
|
||||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
|
||||||
programs demonstrating use of pngusr.dfa
|
|
||||||
pngminus => Simple pnm2png and png2pnm programs
|
|
||||||
pngsuite => Test images
|
|
||||||
tools => Various tools
|
|
||||||
visupng => Contains a MSVC workspace for VisualPng
|
|
||||||
projects => Contains project files and workspaces for
|
|
||||||
building a DLL
|
|
||||||
owatcom => Contains a WATCOM project for building libpng
|
|
||||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
|
||||||
workspace for building libpng and zlib
|
|
||||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
|
||||||
workspace for building libpng and zlib
|
|
||||||
scripts => Directory containing scripts for building libpng:
|
|
||||||
(see scripts/README.txt for the list of scripts)
|
|
||||||
|
|
||||||
Good luck, and happy coding.
|
|
||||||
|
|
||||||
-Glenn Randers-Pehrson (current maintainer, since 1998)
|
|
||||||
Internet: glennrp at users.sourceforge.net
|
|
||||||
|
|
||||||
-Andreas Eric Dilger (former maintainer, 1996-1997)
|
|
||||||
Internet: adilger at enel.ucalgary.ca
|
|
||||||
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
|
|
||||||
|
|
||||||
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
|
||||||
(formerly of Group 42, Inc)
|
|
||||||
Internet: gschal at infinet.com
|
|
||||||
|
|||||||
47
TODO
47
TODO
@@ -1,28 +1,23 @@
|
|||||||
/*
|
|
||||||
TODO - list of things to do for libpng:
|
TODO - list of things to do for libpng:
|
||||||
|
|
||||||
Final bug fixes.
|
* Fix all defects (duh!)
|
||||||
Better C++ wrapper/full C++ implementation?
|
* Better C++ wrapper / full C++ implementation (?)
|
||||||
Fix problem with C++ and EXTERN "C".
|
* Fix the problems with C++ and 'extern "C"'.
|
||||||
cHRM transformation.
|
* cHRM transformation.
|
||||||
Remove setjmp/longjmp usage in favor of returning error codes.
|
* Palette creation.
|
||||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
* "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. (Currently 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
|
(e.g., counting huffman bits/precompression; filter inertia; filter costs).
|
||||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
* Histogram creation.
|
||||||
Histogram creation.
|
* Text conversion between different code pages (e.g., Latin-1 -> Mac).
|
||||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
* Avoid building gamma tables whenever possible.
|
||||||
Avoid building gamma tables whenever possible.
|
* Greater precision in changing to linear gamma for compositing against
|
||||||
Use greater precision when changing to linear gamma for compositing against
|
background, and in doing rgb-to-gray transformations.
|
||||||
background and doing rgb-to-gray transformation.
|
* Investigate pre-incremented loop counters and other loop constructions.
|
||||||
Investigate pre-incremented loop counters and other loop constructions.
|
* Interpolated method of handling interlacing.
|
||||||
Add interpolated method of handling interlacing.
|
* More validations for libpng transformations.
|
||||||
Switch to the simpler zlib (zlib/libpng) license if legally possible.
|
|
||||||
Extend pngvalid.c to validate more of the libpng transformations.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|||||||
8
TRADEMARK
Normal file
8
TRADEMARK
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
TRADEMARK
|
||||||
|
=========
|
||||||
|
|
||||||
|
The name "libpng" has not been registered by the Copyright owners
|
||||||
|
as a trademark in any jurisdiction. However, because libpng has
|
||||||
|
been distributed and maintained world-wide, continually since 1995,
|
||||||
|
the Copyright owners claim "common-law trademark protection" in any
|
||||||
|
jurisdiction where common-law trademark is recognized.
|
||||||
1211
aclocal.m4
vendored
Normal file
1211
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,28 +1,28 @@
|
|||||||
|
|
||||||
/* arm_init.c - NEON optimised filter functions
|
/* arm_init.c - NEON optimised filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2018-2022 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||||
* Written by Mans Rullgard, 2011.
|
* Written by Mans Rullgard, 2011.
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
|
||||||
* called.
|
/* This module requires POSIX 1003.1 functions. */
|
||||||
*/
|
|
||||||
#define _POSIX_SOURCE 1
|
#define _POSIX_SOURCE 1
|
||||||
|
|
||||||
#include "../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
#if PNG_ARM_NEON_OPT > 0
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
/* 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
|
* 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
|
* NEON instructions there is no processor-specific way of detecting the
|
||||||
* presense of the required support, therefore run-time detectioon is extremely
|
* presence of the required support, therefore run-time detection is extremely
|
||||||
* OS specific.
|
* OS specific.
|
||||||
*
|
*
|
||||||
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
||||||
@@ -31,21 +31,26 @@
|
|||||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||||
* implementation which reads /proc/cpufino.
|
* implementation which reads /proc/cpufino.
|
||||||
*/
|
*/
|
||||||
|
#include <signal.h> /* for sig_atomic_t */
|
||||||
|
|
||||||
#ifndef PNG_ARM_NEON_FILE
|
#ifndef PNG_ARM_NEON_FILE
|
||||||
# ifdef __linux__
|
# if defined(__aarch64__) || defined(_M_ARM64)
|
||||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
/* ARM Neon is expected to be unconditionally available on ARM64. */
|
||||||
|
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64"
|
||||||
|
# elif defined(__ARM_NEON__) || defined(__ARM_NEON)
|
||||||
|
/* ARM Neon is expected to be available on the target CPU architecture. */
|
||||||
|
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
|
||||||
|
# elif defined(__linux__)
|
||||||
|
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||||
|
# else
|
||||||
|
# error "No support for run-time ARM Neon checking; use compile-time options"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_ARM_NEON_FILE
|
|
||||||
|
|
||||||
#include <signal.h> /* for sig_atomic_t */
|
|
||||||
static int png_have_neon(png_structp png_ptr);
|
static int png_have_neon(png_structp png_ptr);
|
||||||
#include PNG_ARM_NEON_FILE
|
#ifdef PNG_ARM_NEON_FILE
|
||||||
|
# include PNG_ARM_NEON_FILE
|
||||||
#else /* PNG_ARM_NEON_FILE */
|
#endif
|
||||||
# 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 */
|
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||||
|
|
||||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
@@ -65,6 +70,7 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
|||||||
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
|
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
|
||||||
* as documented in png.h
|
* as documented in png.h
|
||||||
*/
|
*/
|
||||||
|
png_debug(1, "in png_init_filter_functions_neon");
|
||||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||||
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
||||||
{
|
{
|
||||||
@@ -130,4 +136,4 @@ png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* READ */
|
||||||
|
|||||||
@@ -1,26 +1,27 @@
|
|||||||
|
|
||||||
/* filter_neon.S - NEON optimised filter functions
|
/* filter_neon.S - NEON optimised filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
* Copyright (c) 2018 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||||
* Written by Mans Rullgard, 2011.
|
* Written by Mans Rullgard, 2011.
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* This is required to get the symbol renames, which are #defines, and also
|
/* This is required to get the symbol renames, which are #defines, and the
|
||||||
* includes the definition (or not) of PNG_ARM_NEON_OPT and
|
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
|
||||||
* PNG_ARM_NEON_IMPLEMENTATION.
|
|
||||||
*/
|
*/
|
||||||
#define PNG_VERSION_INFO_ONLY
|
#define PNG_VERSION_INFO_ONLY
|
||||||
#include "../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#if defined(__linux__) && defined(__ELF__)
|
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
|
||||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
/* 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
|
* 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
|
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
*/
|
*/
|
||||||
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
|
||||||
#if PNG_ARM_NEON_OPT > 0
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
|
||||||
#ifdef __ELF__
|
#ifdef __ELF__
|
||||||
@@ -47,6 +47,13 @@ ELF .size \name, . - \name
|
|||||||
.purgem endfunc
|
.purgem endfunc
|
||||||
.endm
|
.endm
|
||||||
.text
|
.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
|
.if \export
|
||||||
.global \name
|
.global \name
|
||||||
.endif
|
.endif
|
||||||
@@ -242,5 +249,5 @@ func png_read_filter_row_paeth3_neon, export=1
|
|||||||
pop {r4,pc}
|
pop {r4,pc}
|
||||||
endfunc
|
endfunc
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
|
||||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||||
|
#endif /* READ */
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
|
|
||||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
* Copyright (c) 2018 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
|
||||||
*
|
|
||||||
* 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
|
||||||
@@ -14,10 +13,16 @@
|
|||||||
|
|
||||||
#include "../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
/* This code requires -mfpu=neon on the command line: */
|
/* This code requires -mfpu=neon on the command line: */
|
||||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||||
|
|
||||||
#include <arm_neon.h>
|
#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
|
||||||
|
# include <arm64_neon.h>
|
||||||
|
#else
|
||||||
|
# include <arm_neon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||||
@@ -31,11 +36,15 @@
|
|||||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
* '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
|
* warning; note that the code is safe because there never is an alias between
|
||||||
* the input and output pointers.
|
* the input and output pointers.
|
||||||
|
*
|
||||||
|
* When compiling with MSVC ARM64, the png_ldr macro can't be passed directly
|
||||||
|
* to vst4_lane_u32, because of an internal compiler error inside MSVC.
|
||||||
|
* To avoid this compiler bug, we use a temporary variable (vdest_val) to store
|
||||||
|
* the result of png_ldr.
|
||||||
*/
|
*/
|
||||||
#define png_ldr(type,pointer)\
|
#define png_ldr(type,pointer)\
|
||||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
|
||||||
#if PNG_ARM_NEON_OPT > 0
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -46,6 +55,8 @@ png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
|
|||||||
png_bytep rp_stop = row + row_info->rowbytes;
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
png_const_bytep pp = prev_row;
|
png_const_bytep pp = prev_row;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_up_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
{
|
{
|
||||||
uint8x16_t qrp, qpp;
|
uint8x16_t qrp, qpp;
|
||||||
@@ -71,6 +82,8 @@ png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
|
|||||||
uint8x8x4_t vdest;
|
uint8x8x4_t vdest;
|
||||||
vdest.val[3] = vdup_n_u8(0);
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_sub3_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop;)
|
for (; rp < rp_stop;)
|
||||||
{
|
{
|
||||||
uint8x8_t vtmp1, vtmp2;
|
uint8x8_t vtmp1, vtmp2;
|
||||||
@@ -112,18 +125,23 @@ png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
|||||||
uint8x8x4_t vdest;
|
uint8x8x4_t vdest;
|
||||||
vdest.val[3] = vdup_n_u8(0);
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_sub4_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; rp += 16)
|
for (; rp < rp_stop; rp += 16)
|
||||||
{
|
{
|
||||||
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
uint8x8x4_t vrp = *vrpt;
|
uint8x8x4_t vrp = *vrpt;
|
||||||
uint32x2x4_t *temp_pointer;
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
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);
|
|
||||||
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PNG_UNUSED(prev_row)
|
PNG_UNUSED(prev_row)
|
||||||
@@ -147,6 +165,8 @@ png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
|
|||||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
vrp = *vrpt;
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_avg3_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; pp += 12)
|
for (; rp < rp_stop; pp += 12)
|
||||||
{
|
{
|
||||||
uint8x8_t vtmp1, vtmp2, vtmp3;
|
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||||
@@ -206,12 +226,15 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
|||||||
uint8x8x4_t vdest;
|
uint8x8x4_t vdest;
|
||||||
vdest.val[3] = vdup_n_u8(0);
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_avg4_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
{
|
{
|
||||||
uint32x2x4_t vtmp;
|
uint32x2x4_t vtmp;
|
||||||
uint8x8x4_t *vrpt, *vppt;
|
uint8x8x4_t *vrpt, *vppt;
|
||||||
uint8x8x4_t vrp, vpp;
|
uint8x8x4_t vrp, vpp;
|
||||||
uint32x2x4_t *temp_pointer;
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
@@ -229,7 +252,8 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
|||||||
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||||
vdest.val[3] = vadd_u8(vdest.val[3], vrp.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);
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +303,8 @@ png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
|
|||||||
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
vrp = *vrpt;
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_paeth3_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; pp += 12)
|
for (; rp < rp_stop; pp += 12)
|
||||||
{
|
{
|
||||||
uint8x8x2_t *vppt;
|
uint8x8x2_t *vppt;
|
||||||
@@ -338,12 +364,15 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
|||||||
uint8x8x4_t vdest;
|
uint8x8x4_t vdest;
|
||||||
vdest.val[3] = vdup_n_u8(0);
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_paeth4_neon");
|
||||||
|
|
||||||
for (; rp < rp_stop; rp += 16, pp += 16)
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
{
|
{
|
||||||
uint32x2x4_t vtmp;
|
uint32x2x4_t vtmp;
|
||||||
uint8x8x4_t *vrpt, *vppt;
|
uint8x8x4_t *vrpt, *vppt;
|
||||||
uint8x8x4_t vrp, vpp;
|
uint8x8x4_t vrp, vpp;
|
||||||
uint32x2x4_t *temp_pointer;
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
@@ -363,10 +392,11 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
|||||||
|
|
||||||
vlast = vpp.val[3];
|
vlast = vpp.val[3];
|
||||||
|
|
||||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
|
||||||
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||||
|
#endif /* READ */
|
||||||
|
|||||||
151
arm/palette_neon_intrinsics.c
Normal file
151
arm/palette_neon_intrinsics.c
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
|
||||||
|
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018-2019 Cosmin Truta
|
||||||
|
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
|
||||||
|
* Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
|
||||||
|
*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
|
||||||
|
# include <arm64_neon.h>
|
||||||
|
#else
|
||||||
|
# include <arm_neon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
|
||||||
|
void
|
||||||
|
png_riffle_palette_neon(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
png_const_colorp palette = png_ptr->palette;
|
||||||
|
png_bytep riffled_palette = png_ptr->riffled_palette;
|
||||||
|
png_const_bytep trans_alpha = png_ptr->trans_alpha;
|
||||||
|
int num_trans = png_ptr->num_trans;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Initially black, opaque. */
|
||||||
|
uint8x16x4_t w = {{
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0xff),
|
||||||
|
}};
|
||||||
|
|
||||||
|
png_debug(1, "in png_riffle_palette_neon");
|
||||||
|
|
||||||
|
/* First, riffle the RGB colours into an RGBA8 palette.
|
||||||
|
* The alpha component is set to opaque for now.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < 256; i += 16)
|
||||||
|
{
|
||||||
|
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
|
||||||
|
w.val[0] = v.val[0];
|
||||||
|
w.val[1] = v.val[1];
|
||||||
|
w.val[2] = v.val[2];
|
||||||
|
vst4q_u8(riffled_palette + (i << 2), w);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix up the missing transparency values. */
|
||||||
|
for (i = 0; i < num_trans; i++)
|
||||||
|
riffled_palette[(i << 2) + 3] = trans_alpha[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expands a palettized row into RGBA8. */
|
||||||
|
int
|
||||||
|
png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||||
|
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||||
|
{
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
const png_uint_32 *riffled_palette =
|
||||||
|
(const png_uint_32 *)png_ptr->riffled_palette;
|
||||||
|
const png_uint_32 pixels_per_chunk = 4;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
png_debug(1, "in png_do_expand_palette_rgba8_neon");
|
||||||
|
|
||||||
|
PNG_UNUSED(row)
|
||||||
|
if (row_width < pixels_per_chunk)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* This function originally gets the last byte of the output row.
|
||||||
|
* The NEON part writes forward from a given position, so we have
|
||||||
|
* to seek this back by 4 pixels x 4 bytes.
|
||||||
|
*/
|
||||||
|
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||||
|
{
|
||||||
|
uint32x4_t cur;
|
||||||
|
png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
|
||||||
|
cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
|
||||||
|
vst1q_u32((void *)dp, cur);
|
||||||
|
}
|
||||||
|
if (i != row_width)
|
||||||
|
{
|
||||||
|
/* Remove the amount that wasn't processed. */
|
||||||
|
i -= pixels_per_chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decrement output pointers. */
|
||||||
|
*ssp = *ssp - i;
|
||||||
|
*ddp = *ddp - (i << 2);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expands a palettized row into RGB8. */
|
||||||
|
int
|
||||||
|
png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||||
|
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||||
|
{
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
|
||||||
|
const png_uint_32 pixels_per_chunk = 8;
|
||||||
|
png_uint_32 i;
|
||||||
|
|
||||||
|
png_debug(1, "in png_do_expand_palette_rgb8_neon");
|
||||||
|
|
||||||
|
PNG_UNUSED(row)
|
||||||
|
if (row_width <= pixels_per_chunk)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Seeking this back by 8 pixels x 3 bytes. */
|
||||||
|
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||||
|
{
|
||||||
|
uint8x8x3_t cur;
|
||||||
|
png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
|
||||||
|
cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
|
||||||
|
vst3_u8((void *)dp, cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != row_width)
|
||||||
|
{
|
||||||
|
/* Remove the amount that wasn't processed. */
|
||||||
|
i -= pixels_per_chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decrement output pointers. */
|
||||||
|
*ssp = *ssp - i;
|
||||||
|
*ddp = *ddp - ((i << 1) + i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION */
|
||||||
16
autogen.sh
16
autogen.sh
@@ -73,16 +73,18 @@ done
|
|||||||
# present bad things are happening.
|
# present bad things are happening.
|
||||||
#
|
#
|
||||||
# The autotools generated files:
|
# The autotools generated files:
|
||||||
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
|
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
|
||||||
config.sub configure depcomp install-sh ltmain.sh missing test-driver"
|
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
|
# Files generated by versions of autoconf >2.68 or automake >1.13 (i.e. later
|
||||||
# versions than those required by configure.ac):
|
# versions than those required by configure.ac):
|
||||||
libpng_autotools_extra="compile"
|
libpng_autotools_extra="compile config.h.in~"
|
||||||
#
|
#
|
||||||
# These are separate because 'maintainer-clean' does not remove them.
|
# These are separate because 'maintainer-clean' does not remove them.
|
||||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
libpng_libtool_files="scripts/autoconf/libtool.m4 scripts/autoconf/ltoptions.m4\
|
||||||
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
scripts/autoconf/ltsugar.m4 scripts/autoconf/ltversion.m4\
|
||||||
|
scripts/autoconf/lt~obsolete.m4"
|
||||||
|
|
||||||
libpng_autotools_dirs="autom4te.cache" # not required
|
libpng_autotools_dirs="autom4te.cache" # not required
|
||||||
#
|
#
|
||||||
@@ -193,7 +195,7 @@ case "$mode" in
|
|||||||
if test -d .git
|
if test -d .git
|
||||||
then
|
then
|
||||||
exec >&2
|
exec >&2
|
||||||
echo "ERROR: running autoreconf on an initialized sytem"
|
echo "ERROR: running autoreconf on an initialized system"
|
||||||
echo " This is not necessary; it is only necessary to remake the"
|
echo " This is not necessary; it is only necessary to remake the"
|
||||||
echo " autotools generated files if Makefile.am or configure.ac"
|
echo " autotools generated files if Makefile.am or configure.ac"
|
||||||
echo " change and make does the right thing with:"
|
echo " change and make does the right thing with:"
|
||||||
|
|||||||
11
ci/.shellcheckrc
Normal file
11
ci/.shellcheckrc
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Disable the "variable appears unused" warning caused by the use of getopts
|
||||||
|
# with an obligatory (but unused) variable name in the main function.
|
||||||
|
disable=SC2034
|
||||||
|
|
||||||
|
# Disable all the "quote to prevent globbing or word splitting" advice.
|
||||||
|
# We need word splitting for well-known variables like MAKEFLAGS and CFLAGS.
|
||||||
|
disable=SC2086,SC2206
|
||||||
|
|
||||||
|
# Disable the "possible misspelling" warnings that might be flagged, e.g.,
|
||||||
|
# inside function ci_trace_build.
|
||||||
|
disable=SC2153
|
||||||
19
ci/LICENSE_MIT.txt
Normal file
19
ci/LICENSE_MIT.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
88
ci/ci_lint_ci.sh
Executable file
88
ci/ci_lint_ci.sh
Executable file
@@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||||
|
#
|
||||||
|
# Use, modification and distribution are subject to the MIT License.
|
||||||
|
# Please see the accompanying file LICENSE_MIT.txt
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# shellcheck source="ci/lib/ci.lib.sh"
|
||||||
|
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||||
|
cd "$CI_TOPLEVEL_DIR"
|
||||||
|
|
||||||
|
CI_SHELLCHECK="$(command -v shellcheck || true)"
|
||||||
|
CI_YAMLLINT="$(command -v yamllint || true)"
|
||||||
|
CI_LINT_COUNTER=0
|
||||||
|
|
||||||
|
function ci_lint_ci_config_files {
|
||||||
|
ci_info "linting: CI config files"
|
||||||
|
local MY_FILE
|
||||||
|
if [[ -x $CI_YAMLLINT ]]
|
||||||
|
then
|
||||||
|
ci_spawn "$CI_YAMLLINT" --version
|
||||||
|
for MY_FILE in "$CI_TOPLEVEL_DIR"/.*.yml
|
||||||
|
do
|
||||||
|
ci_spawn "$CI_YAMLLINT" --strict "$MY_FILE" ||
|
||||||
|
CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ci_warn "program not found: 'yamllint'; skipping checks"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_lint_ci_scripts {
|
||||||
|
ci_info "linting: CI scripts"
|
||||||
|
local MY_FILE
|
||||||
|
if [[ -x $CI_SHELLCHECK ]]
|
||||||
|
then
|
||||||
|
ci_spawn "$CI_SHELLCHECK" --version
|
||||||
|
for MY_FILE in "$CI_SCRIPT_DIR"/*.sh
|
||||||
|
do
|
||||||
|
ci_spawn "$CI_SHELLCHECK" -x "$MY_FILE" ||
|
||||||
|
CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ci_warn "program not found: 'shellcheck'; skipping checks"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_lint_ci_scripts_license {
|
||||||
|
ci_info "linting: CI scripts license"
|
||||||
|
ci_spawn grep -F "MIT License" ci/LICENSE_MIT.txt || {
|
||||||
|
ci_warn "bad or missing CI license file: '$CI_SCRIPT_DIR/LICENSE_MIT.txt'"
|
||||||
|
CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "usage: $CI_SCRIPT_NAME"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local opt
|
||||||
|
while getopts ":" opt
|
||||||
|
do
|
||||||
|
# This ain't a while-loop. It only pretends to be.
|
||||||
|
[[ $1 == -[?h]* || $1 == --help ]] && usage
|
||||||
|
ci_err "unknown option: '$1'"
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
# And... go!
|
||||||
|
[[ $# -eq 0 ]] || ci_err "unexpected argument: '$1'"
|
||||||
|
ci_lint_ci_config_files
|
||||||
|
ci_lint_ci_scripts
|
||||||
|
ci_lint_ci_scripts_license
|
||||||
|
if [[ $CI_LINT_COUNTER -eq 0 ]]
|
||||||
|
then
|
||||||
|
ci_info "success!"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
ci_info "failed on $CI_LINT_COUNTER file(s)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
194
ci/ci_verify_cmake.sh
Executable file
194
ci/ci_verify_cmake.sh
Executable file
@@ -0,0 +1,194 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||||
|
#
|
||||||
|
# Use, modification and distribution are subject to the MIT License.
|
||||||
|
# Please see the accompanying file LICENSE_MIT.txt
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# shellcheck source="ci/lib/ci.lib.sh"
|
||||||
|
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||||
|
cd "$CI_TOPLEVEL_DIR"
|
||||||
|
|
||||||
|
CI_SRC_DIR="$CI_TOPLEVEL_DIR"
|
||||||
|
CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
|
||||||
|
CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
|
||||||
|
CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
|
||||||
|
|
||||||
|
# Keep the following relative paths in sync with the absolute paths.
|
||||||
|
# We use them for the benefit of native Windows tools that might be
|
||||||
|
# otherwise confused by the path encoding used by Bash-on-Windows.
|
||||||
|
CI_BUILD_TO_SRC_RELDIR="../.."
|
||||||
|
CI_BUILD_TO_INSTALL_RELDIR="../ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
|
||||||
|
|
||||||
|
function ci_init_build {
|
||||||
|
# Ensure that the mandatory variables are initialized.
|
||||||
|
CI_CMAKE="${CI_CMAKE:-cmake}"
|
||||||
|
CI_CTEST="${CI_CTEST:-ctest}"
|
||||||
|
CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}"
|
||||||
|
[[ -x $(command -v ninja) ]] &&
|
||||||
|
CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
|
||||||
|
if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]]
|
||||||
|
then
|
||||||
|
# Clean up incidental mixtures of Windows and Bash-on-Windows
|
||||||
|
# environment variables, to avoid confusing MSBuild.
|
||||||
|
[[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP
|
||||||
|
[[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP
|
||||||
|
# Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator.
|
||||||
|
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] ||
|
||||||
|
ci_err_internal "missing \$CI_CMAKE_GENERATOR_PLATFORM"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_trace_build {
|
||||||
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
|
ci_info "build arch: $CI_BUILD_ARCH"
|
||||||
|
ci_info "build system: $CI_BUILD_SYSTEM"
|
||||||
|
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
|
||||||
|
ci_info "target arch: $CI_TARGET_ARCH"
|
||||||
|
ci_info "target system: $CI_TARGET_SYSTEM"
|
||||||
|
}
|
||||||
|
ci_info "source directory: $CI_SRC_DIR"
|
||||||
|
ci_info "build directory: $CI_BUILD_DIR"
|
||||||
|
ci_info "install directory: $CI_INSTALL_DIR"
|
||||||
|
ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_TOOLCHAIN_FILE: '$CI_CMAKE_TOOLCHAIN_FILE'"
|
||||||
|
ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'"
|
||||||
|
ci_info "environment option: \$CI_CTEST: '$CI_CTEST'"
|
||||||
|
ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_CC: '$CI_CC'"
|
||||||
|
ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_AR: '$CI_AR'"
|
||||||
|
ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'"
|
||||||
|
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||||
|
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||||
|
ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
|
||||||
|
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||||
|
ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")"
|
||||||
|
ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")"
|
||||||
|
[[ $CI_CC ]] &&
|
||||||
|
ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
|
||||||
|
[[ $CI_AR ]] &&
|
||||||
|
ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
|
||||||
|
[[ $CI_RANLIB ]] &&
|
||||||
|
ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
|
||||||
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_build {
|
||||||
|
if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
|
||||||
|
then
|
||||||
|
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||||
|
ci_spawn rm -fr "$CI_BUILD_DIR"
|
||||||
|
ci_spawn rm -fr "$CI_INSTALL_DIR"
|
||||||
|
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_build {
|
||||||
|
ci_info "## START OF BUILD ##"
|
||||||
|
ci_spawn "$(command -v "$CI_CMAKE")" --version
|
||||||
|
ci_spawn "$(command -v "$CI_CTEST")" --version
|
||||||
|
[[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] &&
|
||||||
|
ci_spawn "$(command -v ninja)" --version
|
||||||
|
# Initialize ALL_CC_FLAGS as a string.
|
||||||
|
local ALL_CC_FLAGS="$CI_CC_FLAGS"
|
||||||
|
[[ $CI_SANITIZERS ]] &&
|
||||||
|
ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS"
|
||||||
|
# Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays.
|
||||||
|
local ALL_CMAKE_VARS=()
|
||||||
|
[[ $CI_CMAKE_TOOLCHAIN_FILE ]] &&
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE")
|
||||||
|
[[ $CI_CC ]] &&
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC")
|
||||||
|
[[ $ALL_CC_FLAGS ]] &&
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS")
|
||||||
|
[[ $CI_AR ]] && {
|
||||||
|
# Use the full path of CI_AR to work around a CMake error.
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_AR="$(command -v "$CI_AR")")
|
||||||
|
}
|
||||||
|
[[ $CI_RANLIB ]] && {
|
||||||
|
# Use the full path of CI_RANLIB to work around a CMake error.
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$(command -v "$CI_RANLIB")")
|
||||||
|
}
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE")
|
||||||
|
ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON)
|
||||||
|
ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
|
||||||
|
local ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
|
||||||
|
local ALL_CTEST_FLAGS=($CI_CTEST_FLAGS)
|
||||||
|
# Export the CMake environment variables.
|
||||||
|
[[ $CI_CMAKE_GENERATOR ]] &&
|
||||||
|
ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR"
|
||||||
|
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] &&
|
||||||
|
ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM"
|
||||||
|
# Build!
|
||||||
|
# Use $CI_BUILD_TO_SRC_RELDIR and $CI_BUILD_TO_INSTALL_RELDIR
|
||||||
|
# instead of $CI_SRC_DIR and $CI_INSTALL_DIR from this point onwards.
|
||||||
|
ci_spawn mkdir -p "$CI_BUILD_DIR"
|
||||||
|
ci_spawn cd "$CI_BUILD_DIR"
|
||||||
|
[[ $CI_BUILD_TO_SRC_RELDIR -ef $CI_SRC_DIR ]] ||
|
||||||
|
ci_err_internal "bad or missing \$CI_BUILD_TO_SRC_RELDIR"
|
||||||
|
ci_spawn mkdir -p "$CI_INSTALL_DIR"
|
||||||
|
[[ $CI_BUILD_TO_INSTALL_RELDIR -ef $CI_INSTALL_DIR ]] ||
|
||||||
|
ci_err_internal "bad or missing \$CI_BUILD_TO_INSTALL_RELDIR"
|
||||||
|
# Spawn "cmake ...".
|
||||||
|
ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_BUILD_TO_INSTALL_RELDIR" \
|
||||||
|
"${ALL_CMAKE_VARS[@]}" \
|
||||||
|
"$CI_BUILD_TO_SRC_RELDIR"
|
||||||
|
# Spawn "cmake --build ...".
|
||||||
|
ci_spawn "$CI_CMAKE" --build . \
|
||||||
|
--config "$CI_CMAKE_BUILD_TYPE" \
|
||||||
|
"${ALL_CMAKE_BUILD_FLAGS[@]}"
|
||||||
|
ci_expr $((CI_NO_TEST)) || {
|
||||||
|
# Spawn "ctest" if testing is not disabled.
|
||||||
|
ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \
|
||||||
|
"${ALL_CTEST_FLAGS[@]}"
|
||||||
|
}
|
||||||
|
ci_expr $((CI_NO_INSTALL)) || {
|
||||||
|
# Spawn "cmake --build ... --target install" if installation is not disabled.
|
||||||
|
ci_spawn "$CI_CMAKE" --build . \
|
||||||
|
--config "$CI_CMAKE_BUILD_TYPE" \
|
||||||
|
--target install \
|
||||||
|
"${ALL_CMAKE_BUILD_FLAGS[@]}"
|
||||||
|
}
|
||||||
|
ci_expr $((CI_NO_CLEAN)) || {
|
||||||
|
# Spawn "make --build ... --target clean" if cleaning is not disabled.
|
||||||
|
ci_spawn "$CI_CMAKE" --build . \
|
||||||
|
--config "$CI_CMAKE_BUILD_TYPE" \
|
||||||
|
--target clean \
|
||||||
|
"${ALL_CMAKE_BUILD_FLAGS[@]}"
|
||||||
|
}
|
||||||
|
ci_info "## END OF BUILD ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "usage: $CI_SCRIPT_NAME"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local opt
|
||||||
|
while getopts ":" opt
|
||||||
|
do
|
||||||
|
# This ain't a while-loop. It only pretends to be.
|
||||||
|
[[ $1 == -[?h]* || $1 == --help ]] && usage
|
||||||
|
ci_err "unknown option: '$1'"
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
ci_init_build
|
||||||
|
ci_trace_build
|
||||||
|
[[ $# -eq 0 ]] || {
|
||||||
|
ci_info "note: this program accepts environment options only"
|
||||||
|
ci_err "unexpected argument: '$1'"
|
||||||
|
}
|
||||||
|
ci_cleanup_old_build
|
||||||
|
ci_build
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
148
ci/ci_verify_configure.sh
Executable file
148
ci/ci_verify_configure.sh
Executable file
@@ -0,0 +1,148 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||||
|
#
|
||||||
|
# Use, modification and distribution are subject to the MIT License.
|
||||||
|
# Please see the accompanying file LICENSE_MIT.txt
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# shellcheck source="ci/lib/ci.lib.sh"
|
||||||
|
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||||
|
cd "$CI_TOPLEVEL_DIR"
|
||||||
|
|
||||||
|
CI_SRC_DIR="$CI_TOPLEVEL_DIR"
|
||||||
|
CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
|
||||||
|
CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
|
||||||
|
CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
|
||||||
|
|
||||||
|
function ci_init_build {
|
||||||
|
# Ensure that the mandatory variables are initialized.
|
||||||
|
CI_MAKE="${CI_MAKE:-make}"
|
||||||
|
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] || {
|
||||||
|
# For native builds, set CI_CC to "cc" by default if the cc command is available.
|
||||||
|
# The configure script defaults CC to "gcc", which is not always a good idea.
|
||||||
|
[[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
|
||||||
|
}
|
||||||
|
# Ensure that the CI_ variables that cannot be customized reliably are not initialized.
|
||||||
|
[[ ! $CI_CONFIGURE_VARS ]] ||
|
||||||
|
ci_err "unsupported: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
|
||||||
|
[[ ! $CI_MAKE_VARS ]] ||
|
||||||
|
ci_err "unsupported: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_trace_build {
|
||||||
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
|
ci_info "build arch: $CI_BUILD_ARCH"
|
||||||
|
ci_info "build system: $CI_BUILD_SYSTEM"
|
||||||
|
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
|
||||||
|
ci_info "target arch: $CI_TARGET_ARCH"
|
||||||
|
ci_info "target system: $CI_TARGET_SYSTEM"
|
||||||
|
}
|
||||||
|
ci_info "source directory: $CI_SRC_DIR"
|
||||||
|
ci_info "build directory: $CI_BUILD_DIR"
|
||||||
|
ci_info "install directory: $CI_INSTALL_DIR"
|
||||||
|
ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
|
||||||
|
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_CC: '$CI_CC'"
|
||||||
|
ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_CPP: '$CI_CPP'"
|
||||||
|
ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_AR: '$CI_AR'"
|
||||||
|
ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'"
|
||||||
|
ci_info "environment option: \$CI_LD: '$CI_LD'"
|
||||||
|
ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||||
|
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||||
|
ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
|
||||||
|
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||||
|
ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")"
|
||||||
|
[[ $CI_CC ]] &&
|
||||||
|
ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
|
||||||
|
[[ $CI_CPP ]] &&
|
||||||
|
ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")"
|
||||||
|
[[ $CI_AR ]] &&
|
||||||
|
ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
|
||||||
|
[[ $CI_RANLIB ]] &&
|
||||||
|
ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
|
||||||
|
[[ $CI_LD ]] &&
|
||||||
|
ci_info "executable: \$CI_LD: $(command -V "$CI_LD")"
|
||||||
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_build {
|
||||||
|
if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
|
||||||
|
then
|
||||||
|
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||||
|
ci_spawn rm -fr "$CI_BUILD_DIR"
|
||||||
|
ci_spawn rm -fr "$CI_INSTALL_DIR"
|
||||||
|
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_build {
|
||||||
|
ci_info "## START OF BUILD ##"
|
||||||
|
# Export the configure build environment.
|
||||||
|
[[ $CI_CC ]] && ci_spawn export CC="$CI_CC"
|
||||||
|
[[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS"
|
||||||
|
[[ $CI_CPP ]] && ci_spawn export CPP="$CI_CPP"
|
||||||
|
[[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS"
|
||||||
|
[[ $CI_AR ]] && ci_spawn export AR="$CI_AR"
|
||||||
|
[[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB"
|
||||||
|
[[ $CI_LD ]] && ci_spawn export LD="$CI_LD"
|
||||||
|
[[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS"
|
||||||
|
[[ $CI_SANITIZERS ]] && {
|
||||||
|
ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}"
|
||||||
|
ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
|
||||||
|
}
|
||||||
|
# Build!
|
||||||
|
ci_spawn mkdir -p "$CI_BUILD_DIR"
|
||||||
|
ci_spawn cd "$CI_BUILD_DIR"
|
||||||
|
# Spawn "configure".
|
||||||
|
ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
|
||||||
|
# Spawn "make".
|
||||||
|
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
|
||||||
|
ci_expr $((CI_NO_TEST)) || {
|
||||||
|
# Spawn "make test" if testing is not disabled.
|
||||||
|
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
|
||||||
|
}
|
||||||
|
ci_expr $((CI_NO_INSTALL)) || {
|
||||||
|
# Spawn "make install" if installation is not disabled.
|
||||||
|
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
|
||||||
|
}
|
||||||
|
ci_expr $((CI_NO_CLEAN)) || {
|
||||||
|
# Spawn "make clean" and "make distclean" if cleaning is not disabled.
|
||||||
|
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
|
||||||
|
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
|
||||||
|
}
|
||||||
|
ci_info "## END OF BUILD ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "usage: $CI_SCRIPT_NAME"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local opt
|
||||||
|
while getopts ":" opt
|
||||||
|
do
|
||||||
|
# This ain't a while-loop. It only pretends to be.
|
||||||
|
[[ $1 == -[?h]* || $1 == --help ]] && usage
|
||||||
|
ci_err "unknown option: '$1'"
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
# And... go!
|
||||||
|
ci_init_build
|
||||||
|
ci_trace_build
|
||||||
|
[[ $# -eq 0 ]] || {
|
||||||
|
ci_info "note: this program accepts environment options only"
|
||||||
|
ci_err "unexpected argument: '$1'"
|
||||||
|
}
|
||||||
|
ci_cleanup_old_build
|
||||||
|
ci_build
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
163
ci/ci_verify_makefiles.sh
Executable file
163
ci/ci_verify_makefiles.sh
Executable file
@@ -0,0 +1,163 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||||
|
#
|
||||||
|
# Use, modification and distribution are subject to the MIT License.
|
||||||
|
# Please see the accompanying file LICENSE_MIT.txt
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
# shellcheck source="ci/lib/ci.lib.sh"
|
||||||
|
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||||
|
cd "$CI_TOPLEVEL_DIR"
|
||||||
|
|
||||||
|
CI_SRC_DIR="$CI_TOPLEVEL_DIR"
|
||||||
|
|
||||||
|
function ci_init_build {
|
||||||
|
# Ensure that the mandatory variables are initialized.
|
||||||
|
CI_MAKE="${CI_MAKE:-make}"
|
||||||
|
case "$CI_CC" in
|
||||||
|
( *clang* )
|
||||||
|
CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.clang"}" ;;
|
||||||
|
( *gcc* )
|
||||||
|
CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.gcc"}" ;;
|
||||||
|
( * )
|
||||||
|
CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.std"}" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_trace_build {
|
||||||
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
|
ci_info "build arch: $CI_BUILD_ARCH"
|
||||||
|
ci_info "build system: $CI_BUILD_SYSTEM"
|
||||||
|
[[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
|
||||||
|
ci_info "target arch: $CI_TARGET_ARCH"
|
||||||
|
ci_info "target system: $CI_TARGET_SYSTEM"
|
||||||
|
}
|
||||||
|
ci_info "source directory: $CI_SRC_DIR"
|
||||||
|
ci_info "environment option: \$CI_MAKEFILES: '$CI_MAKEFILES'"
|
||||||
|
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
|
||||||
|
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_MAKE_VARS: '$CI_MAKE_VARS'"
|
||||||
|
ci_info "environment option: \$CI_CC: '$CI_CC'"
|
||||||
|
ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_CPP: '$CI_CPP'"
|
||||||
|
ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_AR: '$CI_AR'"
|
||||||
|
ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'"
|
||||||
|
ci_info "environment option: \$CI_LD: '$CI_LD'"
|
||||||
|
ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'"
|
||||||
|
ci_info "environment option: \$CI_LIBS: '$CI_LIBS'"
|
||||||
|
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||||
|
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||||
|
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||||
|
ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")"
|
||||||
|
[[ $CI_CC ]] &&
|
||||||
|
ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
|
||||||
|
[[ $CI_CPP ]] &&
|
||||||
|
ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")"
|
||||||
|
[[ $CI_AR ]] &&
|
||||||
|
ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
|
||||||
|
[[ $CI_RANLIB ]] &&
|
||||||
|
ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
|
||||||
|
[[ $CI_LD ]] &&
|
||||||
|
ci_info "executable: \$CI_LD: $(command -V "$CI_LD")"
|
||||||
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_build {
|
||||||
|
# Any old makefile-based build will most likely leave a mess
|
||||||
|
# of object files behind if interrupted, e.g., via Ctrl+C.
|
||||||
|
# There may be other files behind, depending on what makefile
|
||||||
|
# had been used. We cannot easily enumerate all of those.
|
||||||
|
# Fortunately, for a clean makefiles-based build, it should be
|
||||||
|
# sufficient to remove the old object files only.
|
||||||
|
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||||
|
local MY_FILE
|
||||||
|
find "$CI_SRC_DIR" -maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \) |
|
||||||
|
while IFS="" read -r MY_FILE
|
||||||
|
do
|
||||||
|
ci_spawn rm -fr "$MY_FILE"
|
||||||
|
done
|
||||||
|
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_build {
|
||||||
|
ci_info "## START OF BUILD ##"
|
||||||
|
# Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
|
||||||
|
local ALL_CC_FLAGS="$CI_CC_FLAGS"
|
||||||
|
local ALL_LD_FLAGS="$CI_LD_FLAGS"
|
||||||
|
[[ $CI_SANITIZERS ]] && {
|
||||||
|
ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}"
|
||||||
|
ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS"
|
||||||
|
}
|
||||||
|
# Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays.
|
||||||
|
local ALL_MAKE_FLAGS=($CI_MAKE_FLAGS)
|
||||||
|
local ALL_MAKE_VARS=()
|
||||||
|
[[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC")
|
||||||
|
[[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS")
|
||||||
|
[[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP")
|
||||||
|
[[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS")
|
||||||
|
[[ $CI_AR ]] && ALL_MAKE_VARS+=(
|
||||||
|
AR="${CI_AR:-ar}"
|
||||||
|
AR_RC="${CI_AR:-ar} rc"
|
||||||
|
)
|
||||||
|
[[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB")
|
||||||
|
[[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD")
|
||||||
|
[[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS")
|
||||||
|
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
|
||||||
|
ALL_MAKE_VARS+=($CI_MAKE_VARS)
|
||||||
|
# Build!
|
||||||
|
local MY_MAKEFILE
|
||||||
|
for MY_MAKEFILE in $CI_MAKEFILES
|
||||||
|
do
|
||||||
|
ci_info "using makefile: $MY_MAKEFILE"
|
||||||
|
# Spawn "make".
|
||||||
|
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
|
||||||
|
"${ALL_MAKE_FLAGS[@]}" \
|
||||||
|
"${ALL_MAKE_VARS[@]}"
|
||||||
|
ci_expr $((CI_NO_TEST)) || {
|
||||||
|
# Spawn "make test" if testing is not disabled.
|
||||||
|
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
|
||||||
|
"${ALL_MAKE_FLAGS[@]}" \
|
||||||
|
"${ALL_MAKE_VARS[@]}" \
|
||||||
|
test
|
||||||
|
}
|
||||||
|
ci_expr $((CI_NO_CLEAN)) || {
|
||||||
|
# Spawn "make clean" if cleaning is not disabled.
|
||||||
|
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
|
||||||
|
"${ALL_MAKE_FLAGS[@]}" \
|
||||||
|
"${ALL_MAKE_VARS[@]}" \
|
||||||
|
clean
|
||||||
|
}
|
||||||
|
done
|
||||||
|
ci_info "## END OF BUILD ##"
|
||||||
|
}
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo "usage: $CI_SCRIPT_NAME"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function main {
|
||||||
|
local opt
|
||||||
|
while getopts ":" opt
|
||||||
|
do
|
||||||
|
# This ain't a while-loop. It only pretends to be.
|
||||||
|
[[ $1 == -[?h]* || $1 == --help ]] && usage
|
||||||
|
ci_err "unknown option: '$1'"
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
# And... go!
|
||||||
|
ci_init_build
|
||||||
|
ci_trace_build
|
||||||
|
[[ $# -eq 0 ]] || {
|
||||||
|
ci_info "note: this program accepts environment options only"
|
||||||
|
ci_err "unexpected argument: '$1'"
|
||||||
|
}
|
||||||
|
ci_cleanup_old_build
|
||||||
|
ci_build
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
90
ci/lib/ci.lib.sh
Normal file
90
ci/lib/ci.lib.sh
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||||
|
#
|
||||||
|
# Use, modification and distribution are subject to the MIT License.
|
||||||
|
# Please see the accompanying file LICENSE_MIT.txt
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
test -f "$BASH_SOURCE" ||
|
||||||
|
echo >&2 "warning: this module requires Bash version 3 or newer"
|
||||||
|
test "${#BASH_SOURCE[@]}" -gt 1 ||
|
||||||
|
echo >&2 "warning: this module should be sourced from a Bash script"
|
||||||
|
|
||||||
|
# Reset the locale to avoid surprises from locale-dependent commands.
|
||||||
|
export LC_ALL=C
|
||||||
|
export LANG=C
|
||||||
|
export LANGUAGE=C
|
||||||
|
|
||||||
|
# Reset CDPATH to avoid surprises from the "cd" command.
|
||||||
|
export CDPATH=""
|
||||||
|
|
||||||
|
# Initialize the global constants CI_SCRIPT_{NAME,DIR} and CI_TOPLEVEL_DIR.
|
||||||
|
CI_SCRIPT_NAME="$(basename -- "$0")"
|
||||||
|
CI_SCRIPT_DIR="$(cd "$(dirname -- "$0")" && pwd)"
|
||||||
|
CI_TOPLEVEL_DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||||
|
|
||||||
|
# Initialize the global constants CI_BUILD_{...} for the host build platform.
|
||||||
|
CI_BUILD_ARCH="${CI_BUILD_ARCH:-"$(uname -m | tr 'A-Z/\.-' 'a-z____')"}"
|
||||||
|
CI_BUILD_SYSTEM="${CI_BUILD_SYSTEM:-"$(uname -s | tr 'A-Z/\.-' 'a-z____')"}"
|
||||||
|
|
||||||
|
# Initialize the global constants CI_TARGET_{...} for the target platform.
|
||||||
|
CI_TARGET_ARCH="${CI_TARGET_ARCH:-"$CI_BUILD_ARCH"}"
|
||||||
|
CI_TARGET_SYSTEM="${CI_TARGET_SYSTEM:-"$CI_BUILD_SYSTEM"}"
|
||||||
|
|
||||||
|
function ci_info {
|
||||||
|
printf >&2 "%s: %s\\n" "$CI_SCRIPT_NAME" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_warn {
|
||||||
|
printf >&2 "%s: warning: %s\\n" "$CI_SCRIPT_NAME" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_err {
|
||||||
|
printf >&2 "%s: error: %s\\n" "$CI_SCRIPT_NAME" "$*"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_err_internal {
|
||||||
|
printf >&2 "%s: internal error: %s\\n" "$CI_SCRIPT_NAME" "$*"
|
||||||
|
printf >&2 "ABORTED\\n"
|
||||||
|
# Exit with the conventional SIGABRT code.
|
||||||
|
exit 134
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_expr {
|
||||||
|
if [[ ${*:-0} == [0-9] ]]
|
||||||
|
then
|
||||||
|
# This is the same as in the else-branch below, albeit much faster
|
||||||
|
# for our intended use cases.
|
||||||
|
return $((!$1))
|
||||||
|
else
|
||||||
|
# The funny-looking compound command "... && return $? || return $?"
|
||||||
|
# allows the execution to continue uninterrupted under "set -e".
|
||||||
|
expr >/dev/null "$@" && return $? || return $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ci_spawn {
|
||||||
|
printf >&2 "%s: executing:" "$CI_SCRIPT_NAME"
|
||||||
|
printf >&2 " %q" "$@"
|
||||||
|
printf >&2 "\\n"
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure that the internal initialization is correct.
|
||||||
|
[[ $CI_TOPLEVEL_DIR/ci/lib/ci.lib.sh -ef ${BASH_SOURCE[0]} ]] ||
|
||||||
|
ci_err_internal "bad or missing \$CI_TOPLEVEL_DIR"
|
||||||
|
[[ $CI_SCRIPT_DIR/$CI_SCRIPT_NAME -ef $0 ]] ||
|
||||||
|
ci_err_internal "bad or missing \$CI_SCRIPT_DIR/\$CI_SCRIPT_NAME"
|
||||||
|
[[ $CI_BUILD_ARCH && $CI_BUILD_SYSTEM ]] ||
|
||||||
|
ci_err_internal "missing \$CI_BUILD_ARCH or \$CI_BUILD_SYSTEM"
|
||||||
|
[[ $CI_TARGET_ARCH && $CI_TARGET_SYSTEM ]] ||
|
||||||
|
ci_err_internal "missing \$CI_TARGET_ARCH or \$CI_TARGET_SYSTEM"
|
||||||
|
|
||||||
|
# Ensure that the user initialization is correct.
|
||||||
|
[[ ${CI_NO_TEST:-0} == [01] ]] ||
|
||||||
|
ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||||
|
[[ ${CI_NO_INSTALL:-0} == [01] ]] ||
|
||||||
|
ci_err "bad boolean option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
|
||||||
|
[[ ${CI_NO_CLEAN:-0} == [01] ]] ||
|
||||||
|
ci_err "bad boolean option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||||
348
compile
Executable file
348
compile
Executable file
@@ -0,0 +1,348 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
|
||||||
|
scriptversion=2018-03-07.03; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||||
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# This file is maintained in Automake, please report
|
||||||
|
# bugs to <bug-automake@gnu.org> or send patches to
|
||||||
|
# <automake-patches@gnu.org>.
|
||||||
|
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
|
||||||
|
# We need space, tab and new line, in precisely that order. Quoting is
|
||||||
|
# there to prevent tools from complaining about whitespace usage.
|
||||||
|
IFS=" "" $nl"
|
||||||
|
|
||||||
|
file_conv=
|
||||||
|
|
||||||
|
# func_file_conv build_file lazy
|
||||||
|
# Convert a $build file to $host form and store it in $file
|
||||||
|
# Currently only supports Windows hosts. If the determined conversion
|
||||||
|
# type is listed in (the comma separated) LAZY, no conversion will
|
||||||
|
# take place.
|
||||||
|
func_file_conv ()
|
||||||
|
{
|
||||||
|
file=$1
|
||||||
|
case $file in
|
||||||
|
/ | /[!/]*) # absolute file, and not a UNC file
|
||||||
|
if test -z "$file_conv"; then
|
||||||
|
# lazily determine how to convert abs files
|
||||||
|
case `uname -s` in
|
||||||
|
MINGW*)
|
||||||
|
file_conv=mingw
|
||||||
|
;;
|
||||||
|
CYGWIN* | MSYS*)
|
||||||
|
file_conv=cygwin
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
file_conv=wine
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
case $file_conv/,$2, in
|
||||||
|
*,$file_conv,*)
|
||||||
|
;;
|
||||||
|
mingw/*)
|
||||||
|
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||||
|
;;
|
||||||
|
cygwin/* | msys/*)
|
||||||
|
file=`cygpath -m "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
wine/*)
|
||||||
|
file=`winepath -w "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashL linkdir
|
||||||
|
# Make cl look for libraries in LINKDIR
|
||||||
|
func_cl_dashL ()
|
||||||
|
{
|
||||||
|
func_file_conv "$1"
|
||||||
|
if test -z "$lib_path"; then
|
||||||
|
lib_path=$file
|
||||||
|
else
|
||||||
|
lib_path="$lib_path;$file"
|
||||||
|
fi
|
||||||
|
linker_opts="$linker_opts -LIBPATH:$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashl library
|
||||||
|
# Do a library search-path lookup for cl
|
||||||
|
func_cl_dashl ()
|
||||||
|
{
|
||||||
|
lib=$1
|
||||||
|
found=no
|
||||||
|
save_IFS=$IFS
|
||||||
|
IFS=';'
|
||||||
|
for dir in $lib_path $LIB
|
||||||
|
do
|
||||||
|
IFS=$save_IFS
|
||||||
|
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.dll.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/$lib.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/lib$lib.a"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/lib$lib.a
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$save_IFS
|
||||||
|
|
||||||
|
if test "$found" != yes; then
|
||||||
|
lib=$lib.lib
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_wrapper cl arg...
|
||||||
|
# Adjust compile command to suit cl
|
||||||
|
func_cl_wrapper ()
|
||||||
|
{
|
||||||
|
# Assume a capable shell
|
||||||
|
lib_path=
|
||||||
|
shared=:
|
||||||
|
linker_opts=
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.[oO][bB][jJ])
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fo"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fe"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
-I)
|
||||||
|
eat=1
|
||||||
|
func_file_conv "$2" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-I*)
|
||||||
|
func_file_conv "${1#-I}" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashl "$2"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l*)
|
||||||
|
func_cl_dashl "${1#-l}"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-L)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashL "$2"
|
||||||
|
;;
|
||||||
|
-L*)
|
||||||
|
func_cl_dashL "${1#-L}"
|
||||||
|
;;
|
||||||
|
-static)
|
||||||
|
shared=false
|
||||||
|
;;
|
||||||
|
-Wl,*)
|
||||||
|
arg=${1#-Wl,}
|
||||||
|
save_ifs="$IFS"; IFS=','
|
||||||
|
for flag in $arg; do
|
||||||
|
IFS="$save_ifs"
|
||||||
|
linker_opts="$linker_opts $flag"
|
||||||
|
done
|
||||||
|
IFS="$save_ifs"
|
||||||
|
;;
|
||||||
|
-Xlinker)
|
||||||
|
eat=1
|
||||||
|
linker_opts="$linker_opts $2"
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||||
|
func_file_conv "$1"
|
||||||
|
set x "$@" -Tp"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||||
|
func_file_conv "$1" mingw
|
||||||
|
set x "$@" "$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if test -n "$linker_opts"; then
|
||||||
|
linker_opts="-link$linker_opts"
|
||||||
|
fi
|
||||||
|
exec "$@" $linker_opts
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
eat=
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
'')
|
||||||
|
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||||
|
exit 1;
|
||||||
|
;;
|
||||||
|
-h | --h*)
|
||||||
|
cat <<\EOF
|
||||||
|
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||||
|
|
||||||
|
Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||||
|
arguments, and rename the output as expected.
|
||||||
|
|
||||||
|
If you are trying to build a whole package this is not the
|
||||||
|
right script to run: please start by reading the file 'INSTALL'.
|
||||||
|
|
||||||
|
Report bugs to <bug-automake@gnu.org>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "compile $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||||
|
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||||
|
func_cl_wrapper "$@" # Doesn't return...
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
ofile=
|
||||||
|
cfile=
|
||||||
|
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
# So we strip '-o arg' only if arg is an object.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.obj)
|
||||||
|
ofile=$2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" -o "$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*.c)
|
||||||
|
cfile=$1
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z "$ofile" || test -z "$cfile"; then
|
||||||
|
# If no '-o' option was seen then we might have been invoked from a
|
||||||
|
# pattern rule where we don't need one. That is ok -- this is a
|
||||||
|
# normal compilation that the losing compiler can handle. If no
|
||||||
|
# '.c' file was seen then we are probably linking. That is also
|
||||||
|
# ok.
|
||||||
|
exec "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Name of file we expect compiler to create.
|
||||||
|
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||||
|
|
||||||
|
# Create the lock directory.
|
||||||
|
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||||
|
# that we are using for the .o file. Also, base the name on the expected
|
||||||
|
# object file name, since that is what matters with a parallel build.
|
||||||
|
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||||
|
while true; do
|
||||||
|
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
# FIXME: race condition here if user kills between mkdir and trap.
|
||||||
|
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||||
|
|
||||||
|
# Run the compile.
|
||||||
|
"$@"
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if test -f "$cofile"; then
|
||||||
|
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||||
|
elif test -f "${cofile}bj"; then
|
||||||
|
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmdir "$lockdir"
|
||||||
|
exit $ret
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC0"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
||||||
1807
config.guess
vendored
Executable file
1807
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
135
config.h.in
Normal file
135
config.h.in
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/* 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 'feenableexcept' function. */
|
||||||
|
#undef HAVE_FEENABLEEXCEPT
|
||||||
|
|
||||||
|
/* 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 '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 <stdio.h> header file. */
|
||||||
|
#undef HAVE_STDIO_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 where 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
|
||||||
|
|
||||||
|
/* Turn on ARM Neon optimizations at run-time */
|
||||||
|
#undef PNG_ARM_NEON_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for ARM Neon support at run-time */
|
||||||
|
#undef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable ARM Neon optimizations */
|
||||||
|
#undef PNG_ARM_NEON_OPT
|
||||||
|
|
||||||
|
/* Enable Intel SSE optimizations */
|
||||||
|
#undef PNG_INTEL_SSE_OPT
|
||||||
|
|
||||||
|
/* Enable LOONGARCH LSX optimizations */
|
||||||
|
#undef PNG_LOONGARCH_LSX_OPT
|
||||||
|
|
||||||
|
/* Turn on MIPS MMI optimizations at run-time */
|
||||||
|
#undef PNG_MIPS_MMI_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for MIPS MMI support at run-time */
|
||||||
|
#undef PNG_MIPS_MMI_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable MIPS MMI optimizations */
|
||||||
|
#undef PNG_MIPS_MMI_OPT
|
||||||
|
|
||||||
|
/* Turn on MIPS MSA optimizations at run-time */
|
||||||
|
#undef PNG_MIPS_MSA_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for MIPS MSA support at run-time */
|
||||||
|
#undef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable MIPS MSA optimizations */
|
||||||
|
#undef PNG_MIPS_MSA_OPT
|
||||||
|
|
||||||
|
/* Turn on POWERPC VSX optimizations at run-time */
|
||||||
|
#undef PNG_POWERPC_VSX_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for POWERPC VSX support at run-time */
|
||||||
|
#undef PNG_POWERPC_VSX_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable POWERPC VSX optimizations */
|
||||||
|
#undef PNG_POWERPC_VSX_OPT
|
||||||
|
|
||||||
|
/* Define to 1 if all of the C89 standard headers exist (not just the ones
|
||||||
|
required in a freestanding environment). This macro is provided for
|
||||||
|
backward compatibility; new code need not use it. */
|
||||||
|
#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 the equivalent of the C99 'restrict' keyword, or to
|
||||||
|
nothing if this is not supported. Do not define if restrict is
|
||||||
|
supported only directly. */
|
||||||
|
#undef restrict
|
||||||
|
/* Work around a bug in older versions of Sun C++, which did not
|
||||||
|
#define __restrict__ or support _Restrict or __restrict__
|
||||||
|
even though the corresponding Sun C compiler ended up with
|
||||||
|
"#define restrict _Restrict" or "#define restrict __restrict__"
|
||||||
|
in the previous line. This workaround can be removed once
|
||||||
|
we assume Oracle Developer Studio 12.5 (2016) or later. */
|
||||||
|
#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
|
||||||
|
# define _Restrict
|
||||||
|
# define __restrict__
|
||||||
|
#endif
|
||||||
1960
config.sub
vendored
Executable file
1960
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
395
configure.ac
395
configure.ac
@@ -1,5 +1,12 @@
|
|||||||
# configure.ac
|
# configure.ac
|
||||||
|
|
||||||
|
# Copyright (c) 2018-2024 Cosmin Truta
|
||||||
|
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
dnl
|
dnl
|
||||||
dnl Minor upgrades (compatible ABI): increment the package version
|
dnl Minor upgrades (compatible ABI): increment the package version
|
||||||
@@ -18,8 +25,8 @@ AC_PREREQ([2.68])
|
|||||||
|
|
||||||
dnl Version number stuff here:
|
dnl Version number stuff here:
|
||||||
|
|
||||||
AC_INIT([libpng],[1.6.10],[png-mng-implement@lists.sourceforge.net])
|
AC_INIT([libpng],[1.6.41],[png-mng-implement@lists.sourceforge.net])
|
||||||
AC_CONFIG_MACRO_DIR([scripts])
|
AC_CONFIG_MACRO_DIR([scripts/autoconf])
|
||||||
|
|
||||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||||
# color-tests requires automake 1.11 or later
|
# color-tests requires automake 1.11 or later
|
||||||
@@ -29,7 +36,7 @@ AC_CONFIG_MACRO_DIR([scripts])
|
|||||||
# 1.13 is required for parallel tests
|
# 1.13 is required for parallel tests
|
||||||
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
|
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
|
||||||
# The following line causes --disable-maintainer-mode to be the default to
|
# The following line causes --disable-maintainer-mode to be the default to
|
||||||
# configure, this is necessary because libpng distributions cannot rely on the
|
# configure. This is necessary because libpng distributions cannot rely on the
|
||||||
# time stamps of the autotools generated files being correct
|
# time stamps of the autotools generated files being correct
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
@@ -39,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
|||||||
dnl AM_PREREQ([1.11.2])
|
dnl AM_PREREQ([1.11.2])
|
||||||
dnl stop configure from automagically running automake
|
dnl stop configure from automagically running automake
|
||||||
|
|
||||||
PNGLIB_VERSION=1.6.10
|
PNGLIB_VERSION=1.6.41
|
||||||
PNGLIB_MAJOR=1
|
PNGLIB_MAJOR=1
|
||||||
PNGLIB_MINOR=6
|
PNGLIB_MINOR=6
|
||||||
PNGLIB_RELEASE=10
|
PNGLIB_RELEASE=41
|
||||||
|
|
||||||
dnl End of version number stuff
|
dnl End of version number stuff
|
||||||
|
|
||||||
@@ -60,7 +67,7 @@ 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.2 is the tested version, this or any
|
dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
|
||||||
dnl compatible later version may be used
|
dnl compatible later version may be used
|
||||||
LT_INIT([win32-dll])
|
LT_INIT([win32-dll])
|
||||||
LT_PREREQ([2.4.2])
|
LT_PREREQ([2.4.2])
|
||||||
@@ -82,9 +89,27 @@ fi
|
|||||||
DFNCPP="$CPP"
|
DFNCPP="$CPP"
|
||||||
AC_SUBST(DFNCPP)
|
AC_SUBST(DFNCPP)
|
||||||
|
|
||||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
AC_ARG_ENABLE([tests],
|
||||||
# checks the compiler with a program that generates a warning), add the
|
AS_HELP_STRING([--disable-tests],
|
||||||
# following option to deal with this
|
[do not build the test programs (default is to build)]),
|
||||||
|
[enable_tests="$enableval"],
|
||||||
|
[enable_tests=yes])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([ENABLE_TESTS],
|
||||||
|
[test "$enable_tests" != "no"])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([tools],
|
||||||
|
AS_HELP_STRING([--disable-tools],
|
||||||
|
[do not build the auxiliary tools (default is to build)]),
|
||||||
|
[enable_tools="$enableval"],
|
||||||
|
[enable_tools=yes])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([ENABLE_TOOLS],
|
||||||
|
[test "$enable_tools" != "no"])
|
||||||
|
|
||||||
|
# -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,
|
AC_ARG_VAR(PNG_COPTS,
|
||||||
[additional flags for the C compiler, use this for options that would]
|
[additional flags for the C compiler, use this for options that would]
|
||||||
[cause configure itself to fail])
|
[cause configure itself to fail])
|
||||||
@@ -107,26 +132,46 @@ AC_ARG_ENABLE(werror,
|
|||||||
CFLAGS="$sav_CFLAGS"
|
CFLAGS="$sav_CFLAGS"
|
||||||
fi],)
|
fi],)
|
||||||
|
|
||||||
# Checks for header files.
|
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89.
|
||||||
AC_HEADER_STDC
|
# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining
|
||||||
|
# _POSIX_SOURCE to 1. This is incompatible with the new default mode, so
|
||||||
|
# we test for that and force the "-std=c89" compiler option:
|
||||||
|
AC_MSG_CHECKING([if we need to force back C standard to C89])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
[#define _POSIX_SOURCE 1]
|
||||||
|
[#include <stdio.h>]
|
||||||
|
])],
|
||||||
|
AC_MSG_RESULT(no),[
|
||||||
|
if test "x$GCC" != "xyes"; then
|
||||||
|
AC_MSG_ERROR(
|
||||||
|
[Forcing back to C89 is required but the flags are only known for GCC])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
CFLAGS="$CFLAGS -std=c89"
|
||||||
|
])
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for structures and compiler characteristics.
|
||||||
AC_C_CONST
|
|
||||||
AC_TYPE_SIZE_T
|
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
AC_C_RESTRICT
|
AC_C_RESTRICT
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_STRTOD
|
AC_CHECK_FUNCS([pow], ,
|
||||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
[AC_CHECK_LIB([m], [pow], , [AC_MSG_ERROR([cannot find pow])])])
|
||||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
|
||||||
|
# Some later POSIX 1003.1 functions are required for test programs, failure
|
||||||
|
# here is soft (the corresponding test program is not built).
|
||||||
|
AC_CHECK_FUNC([clock_gettime], , [AC_MSG_WARN([not building timepng])])
|
||||||
|
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
|
||||||
|
|
||||||
AC_ARG_WITH(zlib-prefix,
|
AC_ARG_WITH(zlib-prefix,
|
||||||
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
||||||
[prefix that may have been used in installed zlib]),
|
[prefix that may have been used in installed zlib]),
|
||||||
[ZPREFIX=${withval}],
|
[ZPREFIX=${withval}],
|
||||||
[ZPREFIX='z_'])
|
[ZPREFIX='z_'])
|
||||||
AC_CHECK_LIB(z, zlibVersion, ,
|
AC_CHECK_LIB([z], [zlibVersion], ,
|
||||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
[AC_CHECK_LIB([z], [${ZPREFIX}zlibVersion], ,
|
||||||
|
[AC_MSG_ERROR([zlib not installed])])])
|
||||||
|
|
||||||
# The following is for pngvalid, to ensure it catches FP errors even on
|
# 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
|
# platforms that don't enable FP exceptions, the function appears in the math
|
||||||
@@ -265,9 +310,72 @@ AC_ARG_ENABLE([unversioned-libpng-config],
|
|||||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||||
[test "$enable_unversioned_libpng_config" != "no"])
|
[test "$enable_unversioned_libpng_config" != "no"])
|
||||||
|
|
||||||
# HOST SPECIFIC OPTIONS
|
# HOST-SPECIFIC OPTIONS
|
||||||
# =====================
|
# =====================
|
||||||
#
|
#
|
||||||
|
# DEFAULT
|
||||||
|
# =======
|
||||||
|
#
|
||||||
|
AC_ARG_ENABLE([hardware-optimizations],
|
||||||
|
AS_HELP_STRING([[[--enable-hardware-optimizations]]],
|
||||||
|
[Enable hardware optimizations: =no/off, yes/on:]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable hardware optimization on all systems:
|
||||||
|
enable_arm_neon=no
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||||
|
[Disable ARM_NEON optimizations])
|
||||||
|
enable_mips_msa=no
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||||
|
[Disable MIPS_MSA optimizations])
|
||||||
|
enable_mips_mmi=no
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
|
||||||
|
[Disable MIPS_MMI optimizations])
|
||||||
|
enable_powerpc_vsx=no
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
|
||||||
|
[Disable POWERPC VSX optimizations])
|
||||||
|
enable_intel_sse=no
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||||
|
[Disable INTEL_SSE optimizations])
|
||||||
|
enable_loongarch_lsx=no
|
||||||
|
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
|
||||||
|
[Disable LOONGARCH_LSX optimizations])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# allow enabling hardware optimization on any system:
|
||||||
|
case "$host_cpu" in
|
||||||
|
arm*|aarch64*)
|
||||||
|
enable_arm_neon=yes
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||||
|
[Enable ARM_NEON optimizations])
|
||||||
|
;;
|
||||||
|
mipsel*|mips64el*)
|
||||||
|
enable_mips_mmi=yes
|
||||||
|
enable_mips_msa=yes
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
|
||||||
|
[Enable MIPS_MMI optimizations])
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
|
||||||
|
[Enable MIPS_MSA optimizations])
|
||||||
|
;;
|
||||||
|
i?86|x86_64)
|
||||||
|
enable_intel_sse=yes
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
||||||
|
[Enable Intel SSE optimizations])
|
||||||
|
;;
|
||||||
|
powerpc*|ppc64*)
|
||||||
|
enable_powerpc_vsx=yes
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
|
||||||
|
[Enable POWERPC VSX optimizations])
|
||||||
|
;;
|
||||||
|
loongarch*)
|
||||||
|
enable_loongarch_lsx=yes
|
||||||
|
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
|
||||||
|
[Enable LOONGARCH_LSX optimizations])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac])
|
||||||
|
|
||||||
# ARM
|
# ARM
|
||||||
# ===
|
# ===
|
||||||
#
|
#
|
||||||
@@ -286,7 +394,7 @@ AC_ARG_ENABLE([arm-neon],
|
|||||||
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||||
[Disable ARM Neon optimizations])
|
[Disable ARM Neon optimizations])
|
||||||
# Prevent inclusion of the assembler files below:
|
# Prevent inclusion of the assembler files below:
|
||||||
enable_arm_neon=no;;
|
enable_arm_neon=no ;;
|
||||||
check)
|
check)
|
||||||
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||||
[Check for ARM Neon support at run-time]);;
|
[Check for ARM Neon support at run-time]);;
|
||||||
@@ -303,15 +411,250 @@ AC_ARG_ENABLE([arm-neon],
|
|||||||
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
|
# Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
|
||||||
# where ARM optimizations were explicitly requested (this allows a fallback if a
|
# where ARM optimizations were explicitly requested (this allows a fallback
|
||||||
# future host CPU does not match 'arm*')
|
# if a future host CPU does not match 'arm*')
|
||||||
|
|
||||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||||
[test "$enable_arm_neon" != 'no' &&
|
[test "$enable_arm_neon" != 'no' &&
|
||||||
case "$host_cpu" in
|
case "$host_cpu" in
|
||||||
arm*) :;;
|
arm*|aarch64*) : ;;
|
||||||
*) test "$enable_arm_neon" != '';;
|
*) test "$enable_arm_neon" != '' ;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# MIPS
|
||||||
|
# ====
|
||||||
|
#
|
||||||
|
# MIPS MSA (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([mips-msa],
|
||||||
|
AS_HELP_STRING([[[--enable-mips-msa]]],
|
||||||
|
[Enable MIPS MSA 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 __mips_msa systems:
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||||
|
[Disable MIPS MSA optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_mips_msa=no ;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
|
||||||
|
[Check for MIPS MSA support at run-time]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
|
||||||
|
[Turn on MIPS MSA optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
|
||||||
|
[Enable MIPS MSA optimizations])
|
||||||
|
AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass '-mmsa -mfp64']
|
||||||
|
[to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
|
||||||
|
# where MIPS optimizations were explicitly requested (this allows a fallback
|
||||||
|
# if a future host CPU does not match 'mips*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_MIPS_MSA],
|
||||||
|
[test "$enable_mips_msa" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
mipsel*|mips64el*) : ;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# MIPS
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# MIPS MMI (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([mips-mmi],
|
||||||
|
AS_HELP_STRING([[[--enable-mips-mmi]]],
|
||||||
|
[Enable MIPS MMI 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 __mips_mmi systems:
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
|
||||||
|
[Disable MIPS MMI optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_mips_mmi=no;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [],
|
||||||
|
[Check for MIPS MMI support at run-time]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [],
|
||||||
|
[Turn on MIPS MMI optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
|
||||||
|
[Enable MIPS MMI optimizations])
|
||||||
|
AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a']
|
||||||
|
[to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
|
||||||
|
# where MIPS optimizations were explicitly requested (this allows a fallback if a
|
||||||
|
# future host CPU does not match 'mips*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_MIPS_MMI],
|
||||||
|
[test "$enable_mips_mmi" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
mipsel*|mips64el*) :;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# INTEL
|
||||||
|
# =====
|
||||||
|
#
|
||||||
|
# INTEL SSE (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([intel-sse],
|
||||||
|
AS_HELP_STRING([[[--enable-intel-sse]]],
|
||||||
|
[Enable Intel SSE optimizations: =no/off, yes/on:]
|
||||||
|
[no/off: disable the optimizations;]
|
||||||
|
[yes/on: enable the optimizations.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling:
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||||
|
[Disable Intel SSE optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_intel_sse=no ;;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
||||||
|
[Enable Intel SSE optimizations]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
|
||||||
|
# where Intel optimizations were explicitly requested (this allows a fallback
|
||||||
|
# if a future host CPU does not match 'x86*')
|
||||||
|
AM_CONDITIONAL([PNG_INTEL_SSE],
|
||||||
|
[test "$enable_intel_sse" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
i?86|x86_64) : ;;
|
||||||
|
*) test "$enable_intel_sse" != '' ;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# PowerPC
|
||||||
|
# =======
|
||||||
|
#
|
||||||
|
# PowerPC VSX (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([powerpc-vsx],
|
||||||
|
AS_HELP_STRING([[[--enable-powerpc-vsx]]],
|
||||||
|
[Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:]
|
||||||
|
[no/off: disable the optimizations; check: use internal checking code]
|
||||||
|
[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 __ppc64__ systems:
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
|
||||||
|
[Disable POWERPC VSX optimizations])
|
||||||
|
# Prevent inclusion of the platform-specific files below:
|
||||||
|
enable_powerpc_vsx=no ;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
|
||||||
|
[Check for POWERPC VSX support at run-time])
|
||||||
|
AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file]
|
||||||
|
[for the list of supported OSes.]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
|
||||||
|
[Turn on POWERPC VSX optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
|
||||||
|
[Enable POWERPC VSX optimizations])
|
||||||
|
AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass '-maltivec -mvsx']
|
||||||
|
[or '-mcpu=power8' to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*')
|
||||||
|
# or where PowerPC optimizations were explicitly requested (this allows a fallback
|
||||||
|
# if a future host CPU does not match 'powerpc*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_POWERPC_VSX],
|
||||||
|
[test "$enable_powerpc_vsx" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
powerpc*|ppc64*) : ;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# LOONGARCH
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# LOONGARCH LSX (SIMD) support
|
||||||
|
|
||||||
|
if test "$LSX_CFLAGS" = ''; then
|
||||||
|
LSX_CFLAGS="-mlsx"
|
||||||
|
fi
|
||||||
|
|
||||||
|
compiler_support_loongarch_lsx=no
|
||||||
|
AC_MSG_CHECKING(whether to use loongarch LSX intrinsics)
|
||||||
|
save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$CFLAGS $LSX_CFLAGS"
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
#include<lsxintrin.h>
|
||||||
|
int main(){
|
||||||
|
__m128i a, b, c;
|
||||||
|
a = __lsx_vadd_w(b, c);
|
||||||
|
return 0;
|
||||||
|
}]])],compiler_support_loongarch_lsx=yes)
|
||||||
|
CFLAGS=$save_CFLAGS
|
||||||
|
AC_MSG_RESULT($compiler_support_loongarch_lsx)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([loongarch-lsx],
|
||||||
|
AS_HELP_STRING([[[--enable-loongarch-lsx]]],
|
||||||
|
[Enable LOONGARCH LSX optimizations: =no/off, yes/on:]
|
||||||
|
[no/off: disable the optimizations;]
|
||||||
|
[yes/on: turn on unconditionally.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling on __loongarch_simd systems:
|
||||||
|
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
|
||||||
|
[Disable LOONGARCH LSX optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_loongarch_lsx=no;;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
|
||||||
|
[Enable LOONGARCH LSX optimizations])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
if test "$enable_loongarch_lsx" != 'no'; then
|
||||||
|
if test $compiler_support_loongarch_lsx = yes; then
|
||||||
|
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], [Enable LOONGARCH LSX optimizations])
|
||||||
|
else
|
||||||
|
AC_MSG_WARN([Compiler does not support loongarch LSX.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or
|
||||||
|
# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a
|
||||||
|
# future host CPU does not match 'loongarch*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_LOONGARCH_LSX],
|
||||||
|
[test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
loongarch*) :;;
|
||||||
|
*) test "$enable_loongarch_lsx" != '';;
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
This "contrib" directory contains contributions which are not necessarily under
|
This "contrib" directory contains contributions which are not necessarily under
|
||||||
the libpng license, although all are open source. They are not part of
|
the libpng license, although all are open source. They are not part of
|
||||||
libpng proper and are not used for building the library.
|
libpng proper and are not used for building the library, although some are used
|
||||||
|
for testing the library via "make check".
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
|
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
Detection of the ability to exexcute ARM NEON on an ARM processor requires
|
Detection of the ability to execute ARM NEON on an ARM processor requires
|
||||||
operating system support. (The information is not available in user mode.)
|
operating system support. (The information is not available in user mode.)
|
||||||
|
|
||||||
HOW TO USE THIS
|
HOW TO USE THIS
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||||
* Written by John Bowler, 2014.
|
* Written by John Bowler, 2014.
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -17,13 +16,14 @@
|
|||||||
*
|
*
|
||||||
* Documentation:
|
* Documentation:
|
||||||
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||||
* http://code.google.com/p/android/issues/detail?id=49065
|
* https://code.google.com/p/android/issues/detail?id=49065
|
||||||
*
|
*
|
||||||
* NOTE: this requires that libpng is built against the Android NDK and linked
|
* 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
|
* 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,
|
* has been compiled only, not linked: no version of the library has been found,
|
||||||
* only the header files exist in the NDK.
|
* only the header files exist in the NDK.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cpu-features.h>
|
#include <cpu-features.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||||
* Written by Mans Rullgard, 2011.
|
* Written by Mans Rullgard, 2011.
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
*
|
*
|
||||||
* SEE contrib/arm-neon/README before reporting bugs
|
* SEE contrib/arm-neon/README before reporting bugs
|
||||||
*
|
*
|
||||||
* STATUS: COMPILED, TESTED
|
* STATUS: COMPILED, TESTED
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
* This generic __linux__ implementation requires reading /proc/self/auxv and
|
* This generic __linux__ implementation requires reading /proc/self/auxv and
|
||||||
* looking at each element for one that records NEON capabilities.
|
* looking at each element for one that records NEON capabilities.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h> /* for POSIX 1003.1 */
|
#include <unistd.h> /* for POSIX 1003.1 */
|
||||||
#include <errno.h> /* for EINTR */
|
#include <errno.h> /* for EINTR */
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
/* contrib/arm-neon/linux.c
|
/* contrib/arm-neon/linux.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2014, 2017 Glenn Randers-Pehrson
|
||||||
* Written by John Bowler, 2014.
|
* Written by John Bowler, 2014, 2017.
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -16,9 +15,10 @@
|
|||||||
* png_have_neon implemented for Linux by reading the widely available
|
* png_have_neon implemented for Linux by reading the widely available
|
||||||
* pseudo-file /proc/cpuinfo.
|
* pseudo-file /proc/cpuinfo.
|
||||||
*
|
*
|
||||||
* This code is strict ANSI-C and is probably moderately portable, it does
|
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||||
* however use <stdio.h> and assumes that /proc/cpuinfo is never localized.
|
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -62,7 +62,7 @@ png_have_neon(png_structp png_ptr)
|
|||||||
|
|
||||||
counter=0;
|
counter=0;
|
||||||
state = Feature;
|
state = Feature;
|
||||||
/* FALL THROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case Feature:
|
case Feature:
|
||||||
/* Match 'FEATURE', ASCII case insensitive. */
|
/* Match 'FEATURE', ASCII case insensitive. */
|
||||||
@@ -72,10 +72,10 @@ png_have_neon(png_structp png_ptr)
|
|||||||
state = Colon;
|
state = Colon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* did not match 'feature' */
|
/* did not match 'feature' */
|
||||||
state = SkipLine;
|
state = SkipLine;
|
||||||
/* FALL THROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case SkipLine:
|
case SkipLine:
|
||||||
skipLine:
|
skipLine:
|
||||||
@@ -110,7 +110,7 @@ png_have_neon(png_structp png_ptr)
|
|||||||
|
|
||||||
state = Neon;
|
state = Neon;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
/* FALL THROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case Neon:
|
case Neon:
|
||||||
/* Look for 'neon' tag */
|
/* Look for 'neon' tag */
|
||||||
@@ -122,7 +122,7 @@ png_have_neon(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
state = SkipTag;
|
state = SkipTag;
|
||||||
/* FALL THROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case SkipTag:
|
case SkipTag:
|
||||||
/* Skip non-space characters */
|
/* Skip non-space characters */
|
||||||
@@ -152,8 +152,10 @@ png_have_neon(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
else
|
else
|
||||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
57
contrib/conftest/pngcp.dfa
Normal file
57
contrib/conftest/pngcp.dfa
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# pngcp.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2016
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with support for pngcp. This means just png_read_png,
|
||||||
|
# png_write_png and small number of configuration settings.
|
||||||
|
#
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# This option is specific to this configuration; it adds a #define to the
|
||||||
|
# generated pnglibconf.h which turns on the (not portable) timing option for
|
||||||
|
# pngcp. Note that any option is automatically preceded by PNG_; there is no
|
||||||
|
# way round this and this is deliberate.
|
||||||
|
option PNGCP_TIMING
|
||||||
|
|
||||||
|
# Because of the everything off above the option must also be turned on. This
|
||||||
|
# may not be done in one step because it is safer and avoids mis-spelled options
|
||||||
|
# in user .dfa files to error out if an unrecognized option is turned on.
|
||||||
|
option PNGCP_TIMING on
|
||||||
|
|
||||||
|
# Options to turn on png_read_png and png_write_png:
|
||||||
|
option INFO_IMAGE on
|
||||||
|
option SEQUENTIAL_READ on
|
||||||
|
option EASY_ACCESS on
|
||||||
|
option WRITE on
|
||||||
|
option WRITE_16BIT on
|
||||||
|
option WRITE_FILTER on
|
||||||
|
|
||||||
|
# pngcp needs this to preserve unknown chunks, switching all these on means that
|
||||||
|
# pngcp can work without explicit known chunk reading support
|
||||||
|
option UNKNOWN_CHUNKS on
|
||||||
|
option SET_UNKNOWN_CHUNKS on
|
||||||
|
option HANDLE_AS_UNKNOWN on
|
||||||
|
option SAVE_UNKNOWN_CHUNKS on
|
||||||
|
option WRITE_UNKNOWN_CHUNKS on
|
||||||
|
|
||||||
|
# pngcp needs this to handle palette files with invalid indices:
|
||||||
|
option CHECK_FOR_INVALID_INDEX on
|
||||||
|
option GET_PALETTE_MAX on
|
||||||
|
|
||||||
|
# Pre-libpng 1.7 pngcp has to stash text chunks manually, post 1.7 without this
|
||||||
|
# text chunks should be handled as unknown ok.
|
||||||
|
option TEXT on
|
||||||
|
|
||||||
|
# this is used to turn off limits:
|
||||||
|
option USER_LIMITS on
|
||||||
|
option SET_USER_LIMITS on
|
||||||
|
|
||||||
|
# these are just required for specific customizations
|
||||||
|
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||||
|
option WRITE_CUSTOMIZE_COMPRESSION on
|
||||||
@@ -21,4 +21,4 @@ ORIGINAL AUTHORS
|
|||||||
of the people below claim any rights with regard to the contents of this
|
of the people below claim any rights with regard to the contents of this
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
John Bowler <jbowler@acm.org>
|
John Bowler <jbowler at acm.org>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* without processing the image. Notice that some header information may occur
|
* without processing the image. Notice that some header information may occur
|
||||||
* after the image data. Textual data and comments are an example; the approach
|
* after the image data. Textual data and comments are an example; the approach
|
||||||
* in this file won't work reliably for such data because it only looks for the
|
* 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.
|
* information in the section of the file that precedes the image data.
|
||||||
*
|
*
|
||||||
* Compile and link against libpng and zlib, plus anything else required on the
|
* Compile and link against libpng and zlib, plus anything else required on the
|
||||||
* system you use.
|
* system you use.
|
||||||
@@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
|
||||||
|
defined (PNG_iCCP_SUPPORTED)
|
||||||
|
|
||||||
|
|
||||||
static int verbose = 1;
|
static int verbose = 1;
|
||||||
static png_byte no_profile[] = "no profile";
|
static png_byte no_profile[] = "no profile";
|
||||||
|
|
||||||
@@ -178,3 +182,4 @@ main(int argc, char **argv)
|
|||||||
/* Exit code is true if any extract succeeds */
|
/* Exit code is true if any extract succeeds */
|
||||||
return extracted == 0;
|
return extracted == 0;
|
||||||
}
|
}
|
||||||
|
#endif /* READ && STDIO && iCCP */
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "../../png.h"
|
#include "../../png.h"
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||||
|
|
||||||
/* Return component 'c' of pixel 'x' from the given row. */
|
/* Return component 'c' of pixel 'x' from the given row. */
|
||||||
static unsigned int
|
static unsigned int
|
||||||
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||||
@@ -40,7 +42,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
|||||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
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 = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
|
||||||
row += bit_offset_lo >> 3;
|
row += bit_offset_lo >> 3;
|
||||||
bit_offset_lo &= 0x07;
|
bit_offset_lo &= 0x07;
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ static void
|
|||||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||||
png_uint_32 x)
|
png_uint_32 x)
|
||||||
{
|
{
|
||||||
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
|
|
||||||
switch (png_get_color_type(png_ptr, info_ptr))
|
switch (png_get_color_type(png_ptr, info_ptr))
|
||||||
{
|
{
|
||||||
@@ -85,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
|||||||
*/
|
*/
|
||||||
case PNG_COLOR_TYPE_PALETTE:
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
{
|
{
|
||||||
PNG_CONST unsigned int index = component(row, x, 0, bit_depth, 1);
|
int index = component(row, x, 0, bit_depth, 1);
|
||||||
png_colorp palette = NULL;
|
png_colorp palette = NULL;
|
||||||
int num_palette = 0;
|
int num_palette = 0;
|
||||||
|
|
||||||
@@ -366,3 +368,4 @@ int main(int argc, const char **argv)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif /* READ && SEQUENTIAL_READ */
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*- pngtopng
|
/*- pngtopng
|
||||||
*
|
*
|
||||||
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011, 2017.
|
||||||
* To the extent possible under law, the author has waived all copyright and
|
* 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:
|
* related or neighboring rights to this work. This work is published from:
|
||||||
* United States.
|
* United States.
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
* ensure the code picks up the local libpng implementation:
|
* ensure the code picks up the local libpng implementation:
|
||||||
*/
|
*/
|
||||||
#include "../../png.h"
|
#include "../../png.h"
|
||||||
|
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
|
||||||
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
@@ -57,26 +59,27 @@ int main(int argc, const char **argv)
|
|||||||
else
|
else
|
||||||
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
||||||
image.message);
|
image.message);
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
||||||
image.message);
|
image.message);
|
||||||
|
|
||||||
/* This is the only place where a 'free' is required; libpng does
|
free(buffer);
|
||||||
* 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
|
else
|
||||||
|
{
|
||||||
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
/* This is the only place where a 'free' is required; libpng does
|
||||||
|
* the cleanup on error and success, but in this case we couldn't
|
||||||
|
* complete the read because of running out of memory and so libpng
|
||||||
|
* has not got to the point where it can do cleanup.
|
||||||
|
*/
|
||||||
|
png_image_free(&image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -90,3 +93,4 @@ int main(int argc, const char **argv)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif /* READ && WRITE */
|
||||||
|
|||||||
648
contrib/examples/simpleover.c
Normal file
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 */
|
||||||
@@ -59,15 +59,16 @@ INCS = $(PNGINC) $(ZINC) $(XINC)
|
|||||||
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
|
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
|
||||||
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
|
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
|
||||||
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
|
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
|
||||||
WLIBSs = $(PNGLIBs) $(ZLIBs)
|
WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
||||||
CFLAGS = -O -Wall
|
CFLAGS = -O -Wall
|
||||||
|
#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
|
||||||
# [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, -Wextra, and -W can also be used]
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
O = .o
|
O = .o
|
||||||
E =
|
E =
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ of PBMPLUS/NetPBM) and converts them to PNG.
|
|||||||
|
|
||||||
The source code for all three demo programs currently compiles under
|
The source code for all three demo programs currently compiles under
|
||||||
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||||
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
zinser at decus.de, for making the necessary changes for OpenVMS and for
|
||||||
providing an appropriate build script.) Build instructions can be found
|
providing an appropriate build script.) Build instructions can be found
|
||||||
below.
|
below.
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
|
|||||||
13-15 of the book for detailed discussion of the three programs.
|
13-15 of the book for detailed discussion of the three programs.
|
||||||
|
|
||||||
Greg Roelofs
|
Greg Roelofs
|
||||||
http://pobox.com/~newt/greg_contact.html
|
https://pobox.com/~newt/greg_contact.html
|
||||||
16 March 2008
|
16 March 2008
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
|
|||||||
|
|
||||||
- Prerequisites (in order of compilation):
|
- Prerequisites (in order of compilation):
|
||||||
|
|
||||||
- zlib http://zlib.net/
|
- zlib https://zlib.net/
|
||||||
- libpng http://www.libpng.org/pub/png/libpng.html
|
- libpng http://www.libpng.org/pub/png/libpng.html
|
||||||
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007,2017 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
|
||||||
@@ -100,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
|
|||||||
|
|
||||||
/* could pass pointers to user-defined error handlers instead of NULLs: */
|
/* could pass pointers to user-defined error handlers instead of NULLs: */
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL,
|
||||||
|
NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
|
||||||
@@ -263,6 +264,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
|||||||
*pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
*pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
*pChannels = (int)png_get_channels(png_ptr, info_ptr);
|
*pChannels = (int)png_get_channels(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, "readpng: image_data buffer would be too large\n",
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
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
|
||||||
@@ -51,6 +51,12 @@
|
|||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Changelog:
|
||||||
|
2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P)
|
||||||
|
2017-04-22 - Guard against integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
@@ -104,7 +110,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_get_libpng_ver(NULL), mainprog_ptr,
|
||||||
readpng2_error_handler, readpng2_warning_handler);
|
readpng2_error_handler, readpng2_warning_handler);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
@@ -140,7 +146,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
|||||||
/* These byte strings were copied from png.h. If a future version
|
/* These byte strings were copied from png.h. If a future version
|
||||||
* of readpng2.c recognizes more chunks, add them to this list.
|
* of readpng2.c recognizes more chunks, add them to this list.
|
||||||
*/
|
*/
|
||||||
static PNG_CONST png_byte chunks_to_process[] = {
|
static const png_byte chunks_to_process[] = {
|
||||||
98, 75, 71, 68, '\0', /* bKGD */
|
98, 75, 71, 68, '\0', /* bKGD */
|
||||||
103, 65, 77, 65, '\0', /* gAMA */
|
103, 65, 77, 65, '\0', /* gAMA */
|
||||||
115, 82, 71, 66, '\0', /* sRGB */
|
115, 82, 71, 66, '\0', /* sRGB */
|
||||||
@@ -261,36 +267,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
/* since we know we've read all of the PNG file's "header" (i.e., up
|
/* since we know we've read all of the PNG file's "header" (i.e., up
|
||||||
* to IDAT), we can check for a background color here */
|
* to IDAT), we can check for a background color here */
|
||||||
|
|
||||||
if (mainprog_ptr->need_bgcolor &&
|
if (mainprog_ptr->need_bgcolor)
|
||||||
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
|
|
||||||
{
|
{
|
||||||
png_color_16p pBackground;
|
png_color_16p pBackground;
|
||||||
|
|
||||||
/* it is not obvious from the libpng documentation, but this function
|
/* it is not obvious from the libpng documentation, but this function
|
||||||
* takes a pointer to a pointer, and it always returns valid red,
|
* takes a pointer to a pointer, and it always returns valid red,
|
||||||
* green and blue values, regardless of color_type: */
|
* green and blue values, regardless of color_type: */
|
||||||
png_get_bKGD(png_ptr, info_ptr, &pBackground);
|
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
|
||||||
|
{
|
||||||
|
|
||||||
/* however, it always returns the raw bKGD data, regardless of any
|
/* however, it always returns the raw bKGD data, regardless of any
|
||||||
* bit-depth transformations, so check depth and adjust if necessary */
|
* bit-depth transformations, so check depth and adjust if necessary
|
||||||
if (bit_depth == 16) {
|
*/
|
||||||
mainprog_ptr->bg_red = pBackground->red >> 8;
|
if (bit_depth == 16) {
|
||||||
mainprog_ptr->bg_green = pBackground->green >> 8;
|
mainprog_ptr->bg_red = pBackground->red >> 8;
|
||||||
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
mainprog_ptr->bg_green = pBackground->green >> 8;
|
||||||
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
||||||
if (bit_depth == 1)
|
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
if (bit_depth == 1)
|
||||||
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
else if (bit_depth == 2)
|
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
else if (bit_depth == 2)
|
||||||
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
else /* bit_depth == 4 */
|
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
else /* bit_depth == 4 */
|
||||||
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
} else {
|
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
||||||
mainprog_ptr->bg_red = (uch)pBackground->red;
|
} else {
|
||||||
mainprog_ptr->bg_green = (uch)pBackground->green;
|
mainprog_ptr->bg_red = (uch)pBackground->red;
|
||||||
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
mainprog_ptr->bg_green = (uch)pBackground->green;
|
||||||
|
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +456,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
/* all done */
|
/* all done */
|
||||||
|
|
||||||
|
(void)info_ptr; /* Unused */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,6 +482,7 @@ static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
|
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
(void)png_ptr; /* Unused */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007,2017 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
|
||||||
@@ -154,17 +154,26 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
|||||||
*pRowbytes = rowbytes = channels*width;
|
*pRowbytes = rowbytes = channels*width;
|
||||||
*pChannels = channels;
|
*pChannels = channels;
|
||||||
|
|
||||||
|
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
|
|
||||||
|
|
||||||
|
|
||||||
/* 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,11 @@
|
|||||||
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
- 2.01: fixed improper display of usage screen on PNG error(s)
|
- 2.01: fixed improper display of usage screen on PNG error(s)
|
||||||
|
- 2.02: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 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
|
||||||
@@ -182,7 +183,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
||||||
/* First reenable console output, which normally goes to the bit bucket
|
/* First reenable console output, which normally goes to the bit bucket
|
||||||
* for windowed apps. Closing the console window will terminate the
|
* for windowed apps. Closing the console window will terminate the
|
||||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
|
||||||
* incantation. */
|
* incantation. */
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
@@ -496,6 +497,12 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
|
|||||||
|
|
||||||
wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2;
|
wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2;
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (image_height > ((size_t)(-1))/wimage_rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
|
||||||
|
return 4; /* fail */
|
||||||
|
}
|
||||||
|
|
||||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||||
wimage_rowbytes*image_height)))
|
wimage_rowbytes*image_height)))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,10 +26,13 @@
|
|||||||
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
|
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
- 2.01: fixed improper display of usage screen on PNG error(s)
|
- 2.01: fixed improper display of usage screen on PNG error(s)
|
||||||
|
- 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings
|
||||||
|
about unused variable (GR-P)
|
||||||
|
- 2.03: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 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
|
||||||
@@ -80,7 +83,7 @@
|
|||||||
|
|
||||||
#define PROGNAME "rpng-x"
|
#define PROGNAME "rpng-x"
|
||||||
#define LONGNAME "Simple PNG Viewer for X"
|
#define LONGNAME "Simple PNG Viewer for X"
|
||||||
#define VERSION "2.01 of 16 March 2008"
|
#define VERSION "2.02 of 15 June 2014"
|
||||||
#define RESNAME "rpng" /* our X resource application name */
|
#define RESNAME "rpng" /* our X resource application name */
|
||||||
#define RESCLASS "Rpng" /* our X resource class name */
|
#define RESCLASS "Rpng" /* our X resource class name */
|
||||||
|
|
||||||
@@ -279,15 +282,17 @@ int main(int argc, char **argv)
|
|||||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||||
" 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",
|
||||||
|
PROGNAME, default_display_exponent);
|
||||||
|
|
||||||
|
fprintf(stderr, "\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"
|
||||||
"\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\n"
|
"\t\t used with transparent images\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, default_display_exponent);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,6 +424,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
rpng_x_cleanup();
|
rpng_x_cleanup();
|
||||||
|
|
||||||
|
(void)argc; /* Unused */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,11 @@
|
|||||||
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
||||||
unexpected-EOF and file-read-error cases
|
unexpected-EOF and file-read-error cases
|
||||||
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
|
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
|
||||||
|
- 2.04: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 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
|
||||||
@@ -299,7 +300,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
|||||||
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
||||||
/* Next reenable console output, which normally goes to the bit bucket
|
/* Next reenable console output, which normally goes to the bit bucket
|
||||||
* for windowed apps. Closing the console window will terminate the
|
* for windowed apps. Closing the console window will terminate the
|
||||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
|
||||||
* incantation. */
|
* incantation. */
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
@@ -648,6 +649,13 @@ static void rpng2_win_init()
|
|||||||
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
||||||
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (rpng2_info.height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
|
||||||
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
||||||
if (!rpng2_info.image_data) {
|
if (!rpng2_info.image_data) {
|
||||||
readpng2_cleanup(&rpng2_info);
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
|||||||
@@ -41,10 +41,14 @@
|
|||||||
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).
|
||||||
|
- 2.06: check for integer overflow (Glenn R-P)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2010, 2014-2015, 2017 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 +99,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 +115,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 +473,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;
|
||||||
@@ -735,6 +759,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +782,13 @@ static void rpng2_x_init(void)
|
|||||||
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
||||||
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (rpng2_info.height > ((size_t)(-1))/rpng2_info.rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
|
||||||
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
||||||
if (!rpng2_info.image_data) {
|
if (!rpng2_info.image_data) {
|
||||||
readpng2_cleanup(&rpng2_info);
|
readpng2_cleanup(&rpng2_info);
|
||||||
@@ -1826,6 +1859,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() */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
|
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
|
||||||
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
|
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
|
- 2.01: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
|
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
|
||||||
dose not work! In order to do something useful I needed to redirect
|
dose not work! In order to do something useful I needed to redirect
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007, 2017 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
|
||||||
@@ -702,7 +703,18 @@ int main(int argc, char **argv)
|
|||||||
if (wpng_info.interlaced) {
|
if (wpng_info.interlaced) {
|
||||||
long i;
|
long i;
|
||||||
ulg bytes;
|
ulg bytes;
|
||||||
ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */
|
ulg image_bytes;
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (wpng_info_height > ((size_t)(-1)/rowbytes ||
|
||||||
|
wpng_info_height > ((ulg)(-1)/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer too large\n");
|
||||||
|
writepng_cleanup(&wpng_info);
|
||||||
|
wpng_cleanup();
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
image_bytes = rowbytes * wpng_info.height;
|
||||||
|
|
||||||
wpng_info.image_data = (uch *)malloc(image_bytes);
|
wpng_info.image_data = (uch *)malloc(image_bytes);
|
||||||
wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *));
|
wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007, 2017 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
|
||||||
@@ -90,7 +90,7 @@ int writepng_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_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||||
writepng_error_handler, NULL);
|
writepng_error_handler, NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
/* Fake a PNG - just write it out directly. */
|
/* 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 <stdio.h>
|
||||||
#include <zlib.h> /* for crc32 */
|
#include <zlib.h> /* for crc32 */
|
||||||
|
|
||||||
@@ -52,6 +60,6 @@ main(void)
|
|||||||
fwrite(signature, sizeof signature, 1, stdout);
|
fwrite(signature, sizeof signature, 1, stdout);
|
||||||
put_chunk(IHDR, sizeof IHDR);
|
put_chunk(IHDR, sizeof IHDR);
|
||||||
|
|
||||||
for(;;)
|
for (;;)
|
||||||
put_chunk(unknown, sizeof unknown);
|
put_chunk(unknown, sizeof unknown);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2013 John Cunningham Bowler
|
# Copyright (c) 2013 John Cunningham Bowler
|
||||||
#
|
#
|
||||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
|
||||||
#
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
/* makepng.c
|
/* makepng.c */
|
||||||
*
|
#define _ISOC99_SOURCE
|
||||||
* Copyright (c) 2013 John Cunningham Bowler
|
/* Copyright: */
|
||||||
*
|
#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler"
|
||||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
/*
|
||||||
*
|
|
||||||
* 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
|
||||||
*
|
*
|
||||||
* Make a test PNG image. The arguments are as follows:
|
* Make a test PNG image. The arguments are as follows:
|
||||||
*
|
*
|
||||||
* makepng [--sRGB|--linear|--1.8] [--color=<color>] color-type bit-depth \
|
* makepng [--sRGB|--linear|--1.8] [--tRNS] [--nofilters] \
|
||||||
* [file-name]
|
* color-type bit-depth [file-name]
|
||||||
*
|
*
|
||||||
* The color-type may be numeric (and must match the numbers used by the PNG
|
* The color-type may be numeric (and must match the numbers used by the PNG
|
||||||
* specification) or one of the format names listed below. The bit-depth is the
|
* specification) or one of the format names listed below. The bit-depth is the
|
||||||
@@ -39,8 +38,8 @@
|
|||||||
* 4 channels: linear combinations of, from the top-left corner clockwise,
|
* 4 channels: linear combinations of, from the top-left corner clockwise,
|
||||||
* transparent, red, green, blue.
|
* transparent, red, green, blue.
|
||||||
*
|
*
|
||||||
* For color-mapped images a four channel color-map is used and the PNG file has
|
* For color-mapped images a four channel color-map is used and if --tRNS is
|
||||||
* a tRNS chunk, as follows:
|
* given the PNG file has a tRNS chunk, as follows:
|
||||||
*
|
*
|
||||||
* 1-bit: entry 0 is transparent-red, entry 1 is opaque-white
|
* 1-bit: entry 0 is transparent-red, entry 1 is opaque-white
|
||||||
* 2-bit: entry 0: transparent-green
|
* 2-bit: entry 0: transparent-green
|
||||||
@@ -53,6 +52,9 @@
|
|||||||
* The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The
|
* The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The
|
||||||
* image is the 1-channel diamond, but using palette index, not luminosity.
|
* image is the 1-channel diamond, but using palette index, not luminosity.
|
||||||
*
|
*
|
||||||
|
* For formats other than color-mapped ones if --tRNS is specified a tRNS chunk
|
||||||
|
* is generated with all channels equal to the low bits of 0x0101.
|
||||||
|
*
|
||||||
* Image size is determined by the final pixel depth in bits, i.e. channels x
|
* Image size is determined by the final pixel depth in bits, i.e. channels x
|
||||||
* bit-depth, as follows:
|
* bit-depth, as follows:
|
||||||
*
|
*
|
||||||
@@ -60,20 +62,64 @@
|
|||||||
* 16 bits: 256x256
|
* 16 bits: 256x256
|
||||||
* More than 16 bits: 1024x1024
|
* More than 16 bits: 1024x1024
|
||||||
*
|
*
|
||||||
* Row filtering is turned off (the 'none' filter is used on every row) and the
|
* Row filtering is the libpng default but may be turned off (the 'none' filter
|
||||||
* images are not interlaced.
|
* is used on every row) with the --nofilters option.
|
||||||
|
*
|
||||||
|
* The images are not interlaced.
|
||||||
|
*
|
||||||
|
* If file-name is given then the PNG is written to that file, else it is
|
||||||
|
* written to stdout. Notice that stdout is not supported on systems where, by
|
||||||
|
* default, it assumes text output; this program makes no attempt to change the
|
||||||
|
* text mode of stdout!
|
||||||
|
*
|
||||||
|
* makepng --color=<color> ...
|
||||||
*
|
*
|
||||||
* If --color is given then the whole image has that color, color-mapped images
|
* If --color is given then the whole image has that color, color-mapped images
|
||||||
* will have exactly one palette entry and all image files with be 16x16 in
|
* will have exactly one palette entry and all image files with be 16x16 in
|
||||||
* size. The color value is 1 to 4 decimal numbers as appropriate for the color
|
* size. The color value is 1 to 4 decimal numbers as appropriate for the color
|
||||||
* type.
|
* type.
|
||||||
*
|
*
|
||||||
* If file-name is given then the PNG is written to that file, else it is
|
* makepng --small ...
|
||||||
* written to stdout. Notice that stdout is not supported on systems where, by
|
*
|
||||||
* default, it assumes text output; this program makes no attempt to change the
|
* If --small is given the images are no larger than required to include every
|
||||||
* text mode of stdout!
|
* possible pixel value for the format.
|
||||||
|
*
|
||||||
|
* For formats with pixels 8 bits or fewer in size the images consist of a
|
||||||
|
* single row with 2^pixel-depth pixels, one of every possible value.
|
||||||
|
*
|
||||||
|
* For formats with 16-bit pixels a 256x256 image is generated containing every
|
||||||
|
* possible pixel value.
|
||||||
|
*
|
||||||
|
* For larger pixel sizes a 256x256 image is generated where the first row
|
||||||
|
* consists of each pixel that has identical byte values throughout the pixel
|
||||||
|
* followed by rows where the byte values differ within the pixel.
|
||||||
|
*
|
||||||
|
* In all cases the pixel values are arranged in such a way that the SUB and UP
|
||||||
|
* filters give byte sequences for maximal zlib compression. By default (if
|
||||||
|
* --nofilters is not given) the SUB filter is used on the first row and the UP
|
||||||
|
* filter on all following rows.
|
||||||
|
*
|
||||||
|
* The --small option is meant to provide good test-case coverage, however the
|
||||||
|
* images are not easy to examine visually. Without the --small option the
|
||||||
|
* images contain identical color values; the pixel values are adjusted
|
||||||
|
* according to the gamma encoding with no gamma encoding being interpreted as
|
||||||
|
* sRGB.
|
||||||
|
*
|
||||||
|
* LICENSING
|
||||||
|
* =========
|
||||||
|
*
|
||||||
|
* This code is copyright of the authors, see the COPYRIGHT define above. The
|
||||||
|
* code is licensed as above, using the libpng license. The code generates
|
||||||
|
* images which are solely the product of the code; the options choose which of
|
||||||
|
* the many possibilities to generate. The images that result (but not the code
|
||||||
|
* which generates them) are licensed as defined here:
|
||||||
|
*
|
||||||
|
* IMPORTANT: the COPYRIGHT #define must contain ISO-Latin-1 characters, the
|
||||||
|
* IMAGE_LICENSING #define must contain UTF-8 characters. The 'copyright'
|
||||||
|
* symbol 0xA9U (\251) in ISO-Latin-1 encoding and 0xC20xA9 (\302\251) in UTF-8.
|
||||||
*/
|
*/
|
||||||
#define _ISOC99_SOURCE /* for strtoull */
|
#define IMAGE_LICENSING "Dedicated to the public domain per Creative Commons "\
|
||||||
|
"license \"CC0 1.0\"; https://creativecommons.org/publicdomain/zero/1.0/"
|
||||||
|
|
||||||
#include <stddef.h> /* for offsetof */
|
#include <stddef.h> /* for offsetof */
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -82,6 +128,8 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
@@ -96,6 +144,25 @@
|
|||||||
# include "../../png.h"
|
# include "../../png.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
/* Work round for GCC complaints about casting a (double) function result to
|
||||||
|
* an unsigned:
|
||||||
|
*/
|
||||||
|
static unsigned int
|
||||||
|
flooru(double d)
|
||||||
|
{
|
||||||
|
d = floor(d);
|
||||||
|
return (unsigned int)d;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_byte
|
||||||
|
floorb(double d)
|
||||||
|
{
|
||||||
|
d = floor(d);
|
||||||
|
return (png_byte)d;
|
||||||
|
}
|
||||||
|
|
||||||
/* This structure is used for inserting extra chunks (the --insert argument, not
|
/* This structure is used for inserting extra chunks (the --insert argument, not
|
||||||
* documented above.)
|
* documented above.)
|
||||||
*/
|
*/
|
||||||
@@ -107,7 +174,7 @@ typedef struct chunk_insert
|
|||||||
png_charp parameters[1];
|
png_charp parameters[1];
|
||||||
} chunk_insert;
|
} chunk_insert;
|
||||||
|
|
||||||
static int
|
static unsigned int
|
||||||
channels_of_type(int color_type)
|
channels_of_type(int color_type)
|
||||||
{
|
{
|
||||||
if (color_type & PNG_COLOR_MASK_PALETTE)
|
if (color_type & PNG_COLOR_MASK_PALETTE)
|
||||||
@@ -128,14 +195,15 @@ channels_of_type(int color_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static unsigned int
|
||||||
pixel_depth_of_type(int color_type, int bit_depth)
|
pixel_depth_of_type(int color_type, int bit_depth)
|
||||||
{
|
{
|
||||||
return channels_of_type(color_type) * bit_depth;
|
return channels_of_type(color_type) * bit_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
|
image_size_of_type(int color_type, int bit_depth, unsigned int *colors,
|
||||||
|
int small)
|
||||||
{
|
{
|
||||||
if (*colors)
|
if (*colors)
|
||||||
return 16;
|
return 16;
|
||||||
@@ -144,7 +212,16 @@ image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
|
|||||||
{
|
{
|
||||||
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||||
|
|
||||||
if (pixel_depth < 8)
|
if (small)
|
||||||
|
{
|
||||||
|
if (pixel_depth <= 8) /* there will be one row */
|
||||||
|
return 1 << pixel_depth;
|
||||||
|
|
||||||
|
else
|
||||||
|
return 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (pixel_depth < 8)
|
||||||
return 64;
|
return 64;
|
||||||
|
|
||||||
else if (pixel_depth > 16)
|
else if (pixel_depth > 16)
|
||||||
@@ -217,27 +294,31 @@ generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
|
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
|
||||||
unsigned int x, y, ip;
|
unsigned int x, y;
|
||||||
|
volatile unsigned int ip = 0;
|
||||||
|
|
||||||
for (x=0; x<size; ++x) for (y=0; y<size; ++y)
|
for (x=0; x<size; ++x)
|
||||||
{
|
{
|
||||||
ip = x + (size * y);
|
for (y=0; y<size; ++y)
|
||||||
|
{
|
||||||
|
ip = x + (size * y);
|
||||||
|
|
||||||
/* size is at most 16, so the scaled value below fits in 16 bits
|
/* size is at most 16, so the scaled value below fits in 16 bits
|
||||||
*/
|
*/
|
||||||
# define interp(pos, c1, c2) ((pos * c1) + ((size-pos) * c2))
|
# define interp(pos, c1, c2) ((pos * c1) + ((size-pos) * c2))
|
||||||
# define xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
# define xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
||||||
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
||||||
(size*size))
|
(size*size))
|
||||||
|
|
||||||
set_color(palette+ip, trans+ip,
|
set_color(palette+ip, trans+ip,
|
||||||
/* color: green, red,blue,white */
|
/* color: green, red,blue,white */
|
||||||
xyinterp(x, y, 0, 255, 0, 255),
|
xyinterp(x, y, 0, 255, 0, 255),
|
||||||
xyinterp(x, y, 255, 0, 0, 255),
|
xyinterp(x, y, 255, 0, 0, 255),
|
||||||
xyinterp(x, y, 0, 0, 255, 255),
|
xyinterp(x, y, 0, 0, 255, 255),
|
||||||
/* alpha: 0, 102, 204, 255) */
|
/* alpha: 0, 102, 204, 255) */
|
||||||
xyinterp(x, y, 0, 102, 204, 255),
|
xyinterp(x, y, 0, 102, 204, 255),
|
||||||
gamma_table);
|
gamma_table);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ip+1;
|
return ip+1;
|
||||||
@@ -281,7 +362,7 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
|||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
value = (unsigned int)floor(65535*pow(value/65535.,conv)+.5);
|
value = flooru(65535*pow(value/65535.,conv)+.5);
|
||||||
*row++ = (png_byte)(value >> 8);
|
*row++ = (png_byte)(value >> 8);
|
||||||
*row = (png_byte)value;
|
*row = (png_byte)value;
|
||||||
return;
|
return;
|
||||||
@@ -306,15 +387,148 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int /* filter mask for row */
|
||||||
generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||||
int bit_depth, png_const_bytep gamma_table, double conv,
|
int bit_depth, png_const_bytep gamma_table, double conv,
|
||||||
unsigned int *colors)
|
unsigned int *colors, int small)
|
||||||
{
|
{
|
||||||
png_uint_32 size_max = image_size_of_type(color_type, bit_depth, colors)-1;
|
int filters = 0; /* file *MASK*, 0 means the default, not NONE */
|
||||||
|
png_uint_32 size_max =
|
||||||
|
image_size_of_type(color_type, bit_depth, colors, small)-1;
|
||||||
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
|
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
|
||||||
|
|
||||||
if (colors[0] == 0) switch (channels_of_type(color_type))
|
if (colors[0] == 0 && small)
|
||||||
|
{
|
||||||
|
unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||||
|
|
||||||
|
/* For pixel depths less than 16 generate a single row containing all the
|
||||||
|
* possible pixel values. For 16 generate all 65536 byte pair
|
||||||
|
* combinations in a 256x256 pixel array.
|
||||||
|
*/
|
||||||
|
switch (pixel_depth)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
assert(y == 0 && rowbytes == 1 && size_max == 1);
|
||||||
|
row[0] = 0x6CU; /* binary: 01101100, only top 2 bits used */
|
||||||
|
filters = PNG_FILTER_NONE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
assert(y == 0 && rowbytes == 1 && size_max == 3);
|
||||||
|
row[0] = 0x1BU; /* binary 00011011, all bits used */
|
||||||
|
filters = PNG_FILTER_NONE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
assert(y == 0 && rowbytes == 8 && size_max == 15);
|
||||||
|
row[0] = 0x01U;
|
||||||
|
row[1] = 0x23U; /* SUB gives 0x22U for all following bytes */
|
||||||
|
row[2] = 0x45U;
|
||||||
|
row[3] = 0x67U;
|
||||||
|
row[4] = 0x89U;
|
||||||
|
row[5] = 0xABU;
|
||||||
|
row[6] = 0xCDU;
|
||||||
|
row[7] = 0xEFU;
|
||||||
|
filters = PNG_FILTER_SUB;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
/* The row will have all the pixel values in order starting with
|
||||||
|
* '1', the SUB filter will change every byte into '1' (including
|
||||||
|
* the last, which generates pixel value '0'). Since the SUB filter
|
||||||
|
* has value 1 this should result in maximum compression.
|
||||||
|
*/
|
||||||
|
assert(y == 0 && rowbytes == 256 && size_max == 255);
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
row[size_max] = 0xFFU & (size_max+1);
|
||||||
|
if (size_max == 0)
|
||||||
|
break;
|
||||||
|
--size_max;
|
||||||
|
}
|
||||||
|
filters = PNG_FILTER_SUB;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
/* Rows are generated such that each row has a constant difference
|
||||||
|
* between the first and second byte of each pixel and so that the
|
||||||
|
* difference increases by 1 at each row. The rows start with the
|
||||||
|
* first byte value of 0 and the value increases to 255 across the
|
||||||
|
* row.
|
||||||
|
*
|
||||||
|
* The difference starts at 1, so the first row is:
|
||||||
|
*
|
||||||
|
* 0 1 1 2 2 3 3 4 ... 254 255 255 0
|
||||||
|
*
|
||||||
|
* This means that running the SUB filter on the first row produces:
|
||||||
|
*
|
||||||
|
* [SUB==1] 0 1 0 1 0 1...
|
||||||
|
*
|
||||||
|
* Then the difference is 2 on the next row, giving:
|
||||||
|
*
|
||||||
|
* 0 2 1 3 2 4 3 5 ... 254 0 255 1
|
||||||
|
*
|
||||||
|
* When the UP filter is run on this libpng produces:
|
||||||
|
*
|
||||||
|
* [UP ==2] 0 1 0 1 0 1...
|
||||||
|
*
|
||||||
|
* And so on for all the remain rows to the final two * rows:
|
||||||
|
*
|
||||||
|
* row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254
|
||||||
|
* row 255: 0 0 1 1 2 2 3 3 4 4 ... 254 254 255 255
|
||||||
|
*/
|
||||||
|
assert(rowbytes == 512 && size_max == 255);
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
row[2*size_max ] = 0xFFU & size_max;
|
||||||
|
row[2*size_max+1] = 0xFFU & (size_max+y+1);
|
||||||
|
if (size_max == 0)
|
||||||
|
break;
|
||||||
|
--size_max;
|
||||||
|
}
|
||||||
|
/* The first row must include PNG_FILTER_UP so that libpng knows we
|
||||||
|
* need to keep it for the following row:
|
||||||
|
*/
|
||||||
|
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 24:
|
||||||
|
case 32:
|
||||||
|
case 48:
|
||||||
|
case 64:
|
||||||
|
/* The rows are filled by an algorithm similar to the above, in the
|
||||||
|
* first row pixel bytes are all equal, increasing from 0 by 1 for
|
||||||
|
* each pixel. In the second row the bytes within a pixel are
|
||||||
|
* incremented 1,3,5,7,... from the previous row byte. Using an odd
|
||||||
|
* number ensures all the possible byte values are used.
|
||||||
|
*/
|
||||||
|
assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3));
|
||||||
|
pixel_depth >>= 3; /* now in bytes */
|
||||||
|
while (rowbytes > 0)
|
||||||
|
{
|
||||||
|
const size_t pixel_index = --rowbytes/pixel_depth;
|
||||||
|
|
||||||
|
if (y == 0)
|
||||||
|
row[rowbytes] = 0xFFU & pixel_index;
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const size_t byte_offset =
|
||||||
|
rowbytes - pixel_index * pixel_depth;
|
||||||
|
|
||||||
|
row[rowbytes] =
|
||||||
|
0xFFU & (pixel_index + (byte_offset * 2*y) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0/*NOT REACHED*/);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else switch (channels_of_type(color_type))
|
||||||
{
|
{
|
||||||
/* 1 channel: a square image with a diamond, the least luminous colors are on
|
/* 1 channel: a square image with a diamond, the least luminous colors are on
|
||||||
* the edge of the image, the most luminous in the center.
|
* the edge of the image, the most luminous in the center.
|
||||||
@@ -448,7 +662,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
const png_uint_32 luma = colors[1];
|
png_uint_32 luma = colors[1];
|
||||||
png_uint_32 x;
|
png_uint_32 x;
|
||||||
|
|
||||||
for (x=0; x<=size_max; ++x)
|
for (x=0; x<=size_max; ++x)
|
||||||
@@ -459,8 +673,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
const png_uint_32 luma = colors[1];
|
png_uint_32 luma = colors[1];
|
||||||
const png_uint_32 alpha = colors[2];
|
png_uint_32 alpha = colors[2];
|
||||||
png_uint_32 x;
|
png_uint_32 x;
|
||||||
|
|
||||||
for (x=0; x<size_max; ++x)
|
for (x=0; x<size_max; ++x)
|
||||||
@@ -475,9 +689,9 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
{
|
{
|
||||||
const png_uint_32 red = colors[1];
|
png_uint_32 red = colors[1];
|
||||||
const png_uint_32 green = colors[2];
|
png_uint_32 green = colors[2];
|
||||||
const png_uint_32 blue = colors[3];
|
png_uint_32 blue = colors[3];
|
||||||
png_uint_32 x;
|
png_uint_32 x;
|
||||||
|
|
||||||
for (x=0; x<=size_max; ++x)
|
for (x=0; x<=size_max; ++x)
|
||||||
@@ -494,10 +708,10 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
|||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
const png_uint_32 red = colors[1];
|
png_uint_32 red = colors[1];
|
||||||
const png_uint_32 green = colors[2];
|
png_uint_32 green = colors[2];
|
||||||
const png_uint_32 blue = colors[3];
|
png_uint_32 blue = colors[3];
|
||||||
const png_uint_32 alpha = colors[4];
|
png_uint_32 alpha = colors[4];
|
||||||
png_uint_32 x;
|
png_uint_32 x;
|
||||||
|
|
||||||
for (x=0; x<=size_max; ++x)
|
for (x=0; x<=size_max; ++x)
|
||||||
@@ -526,6 +740,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
|||||||
colors[0], channels_of_type(color_type));
|
colors[0], channels_of_type(color_type));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -554,7 +770,7 @@ makepng_error(png_structp png_ptr, png_const_charp message)
|
|||||||
static int /* 0 on success, else an error code */
|
static int /* 0 on success, else an error code */
|
||||||
write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||||
volatile png_fixed_point gamma, chunk_insert * volatile insert,
|
volatile png_fixed_point gamma, chunk_insert * volatile insert,
|
||||||
unsigned int filters, unsigned int *colors)
|
unsigned int filters, unsigned int *colors, int small, int tRNS)
|
||||||
{
|
{
|
||||||
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||||
name, makepng_error, makepng_warning);
|
name, makepng_error, makepng_warning);
|
||||||
@@ -581,6 +797,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
|
|
||||||
/* Allow benign errors so that we can write PNGs with errors */
|
/* Allow benign errors so that we can write PNGs with errors */
|
||||||
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||||
|
|
||||||
|
/* Max out the text compression level in an attempt to make the license
|
||||||
|
* small. If --small then do the same for the IDAT.
|
||||||
|
*/
|
||||||
|
if (small)
|
||||||
|
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
|
png_set_text_compression_level(png_ptr, Z_BEST_COMPRESSION);
|
||||||
|
|
||||||
png_init_io(png_ptr, fp);
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
@@ -588,11 +813,37 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
png_error(png_ptr, "OOM allocating info structure");
|
png_error(png_ptr, "OOM allocating info structure");
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned int size = image_size_of_type(color_type, bit_depth, colors);
|
unsigned int size =
|
||||||
|
image_size_of_type(color_type, bit_depth, colors, small);
|
||||||
|
unsigned int ysize;
|
||||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||||
png_byte gamma_table[256];
|
png_byte gamma_table[256];
|
||||||
double conv;
|
double conv;
|
||||||
|
|
||||||
|
/* Normally images are square, but with 'small' we want to simply generate
|
||||||
|
* all the pixel values, or all that we reasonably can:
|
||||||
|
*/
|
||||||
|
if (small)
|
||||||
|
{
|
||||||
|
unsigned int pixel_depth =
|
||||||
|
pixel_depth_of_type(color_type, bit_depth);
|
||||||
|
|
||||||
|
if (pixel_depth <= 8U)
|
||||||
|
{
|
||||||
|
assert(size == (1U<<pixel_depth));
|
||||||
|
ysize = 1U;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
assert(size == 256U);
|
||||||
|
ysize = 256U;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
ysize = size;
|
||||||
|
|
||||||
/* This function uses the libpng values used on read to carry extra
|
/* This function uses the libpng values used on read to carry extra
|
||||||
* information about the gamma:
|
* information about the gamma:
|
||||||
*/
|
*/
|
||||||
@@ -608,10 +859,13 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (real_gamma == 45455) for (i=0; i<256; ++i)
|
if (real_gamma == 45455)
|
||||||
{
|
{
|
||||||
gamma_table[i] = (png_byte)i;
|
for (i=0; i<256; ++i)
|
||||||
conv = 1.;
|
{
|
||||||
|
gamma_table[i] = (png_byte)i;
|
||||||
|
conv = 1.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -625,13 +879,13 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
gamma_table[0] = 0;
|
gamma_table[0] = 0;
|
||||||
|
|
||||||
for (i=1; i<255; ++i)
|
for (i=1; i<255; ++i)
|
||||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
|
gamma_table[i] = floorb(pow(i/255.,conv) * 255 + .5);
|
||||||
|
|
||||||
gamma_table[255] = 255;
|
gamma_table[255] = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
png_set_IHDR(png_ptr, info_ptr, size, size, bit_depth, color_type,
|
png_set_IHDR(png_ptr, info_ptr, size, ysize, bit_depth, color_type,
|
||||||
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
|
|
||||||
if (color_type & PNG_COLOR_MASK_PALETTE)
|
if (color_type & PNG_COLOR_MASK_PALETTE)
|
||||||
@@ -643,14 +897,26 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
|
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
|
||||||
colors);
|
colors);
|
||||||
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
|
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
|
||||||
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
|
|
||||||
NULL/*transparent color*/);
|
if (tRNS)
|
||||||
|
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
|
||||||
|
NULL/*transparent color*/);
|
||||||
|
|
||||||
/* Reset gamma_table to prevent the image rows being changed */
|
/* Reset gamma_table to prevent the image rows being changed */
|
||||||
for (npalette=0; npalette<256; ++npalette)
|
for (npalette=0; npalette<256; ++npalette)
|
||||||
gamma_table[npalette] = (png_byte)npalette;
|
gamma_table[npalette] = (png_byte)npalette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (tRNS)
|
||||||
|
{
|
||||||
|
png_color_16 col;
|
||||||
|
|
||||||
|
col.red = col.green = col.blue = col.gray =
|
||||||
|
0x0101U & ((1U<<bit_depth)-1U);
|
||||||
|
col.index = 0U;
|
||||||
|
png_set_tRNS(png_ptr, info_ptr, NULL/*trans*/, 1U, &col);
|
||||||
|
}
|
||||||
|
|
||||||
if (gamma == PNG_DEFAULT_sRGB)
|
if (gamma == PNG_DEFAULT_sRGB)
|
||||||
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
|
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
|
||||||
|
|
||||||
@@ -682,9 +948,13 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
|
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
|
||||||
|
|
||||||
{
|
{
|
||||||
int passes = png_set_interlace_handling(png_ptr);
|
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
# else /* !WRITE_INTERLACING */
|
||||||
|
int passes = 1;
|
||||||
|
# endif /* !WRITE_INTERLACING */
|
||||||
int pass;
|
int pass;
|
||||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
row = malloc(rowbytes);
|
row = malloc(rowbytes);
|
||||||
|
|
||||||
@@ -695,10 +965,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
|||||||
{
|
{
|
||||||
unsigned int y;
|
unsigned int y;
|
||||||
|
|
||||||
for (y=0; y<size; ++y)
|
for (y=0; y<ysize; ++y)
|
||||||
{
|
{
|
||||||
generate_row(row, rowbytes, y, color_type, bit_depth,
|
unsigned int row_filters =
|
||||||
gamma_table, conv, colors);
|
generate_row(row, rowbytes, y, color_type, bit_depth,
|
||||||
|
gamma_table, conv, colors, small);
|
||||||
|
|
||||||
|
if (row_filters != 0 && filters == PNG_ALL_FILTERS)
|
||||||
|
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, row_filters);
|
||||||
|
|
||||||
png_write_row(png_ptr, row);
|
png_write_row(png_ptr, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -823,11 +1098,11 @@ load_file(png_const_charp name, png_bytepp result)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static png_size_t
|
static size_t
|
||||||
load_fake(png_charp param, png_bytepp profile)
|
load_fake(png_charp param, png_bytepp profile)
|
||||||
{
|
{
|
||||||
char *endptr = NULL;
|
char *endptr = NULL;
|
||||||
unsigned long long int size = strtoull(param, &endptr, 0/*base*/);
|
uint64_t size = strtoull(param, &endptr, 0/*base*/);
|
||||||
|
|
||||||
/* The 'fake' format is <number>*[string] */
|
/* The 'fake' format is <number>*[string] */
|
||||||
if (endptr != NULL && *endptr == '*')
|
if (endptr != NULL && *endptr == '*')
|
||||||
@@ -893,7 +1168,7 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
|||||||
{
|
{
|
||||||
case '<':
|
case '<':
|
||||||
{
|
{
|
||||||
png_size_t filelen = load_file(params[1]+1, &profile);
|
size_t filelen = load_file(params[1]+1, &profile);
|
||||||
if (filelen > 0xfffffffc) /* Maximum profile length */
|
if (filelen > 0xfffffffc) /* Maximum profile length */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n",
|
fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n",
|
||||||
@@ -908,7 +1183,7 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
|||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
{
|
{
|
||||||
png_size_t fake_len = load_fake(params[1], &profile);
|
size_t fake_len = load_fake(params[1], &profile);
|
||||||
|
|
||||||
if (fake_len > 0) /* else a simple parameter */
|
if (fake_len > 0) /* else a simple parameter */
|
||||||
{
|
{
|
||||||
@@ -1003,7 +1278,7 @@ set_text(png_structp png_ptr, png_infop info_ptr, png_textp text,
|
|||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
{
|
{
|
||||||
png_bytep data = NULL;
|
png_bytep data = NULL;
|
||||||
png_size_t fake_len = load_fake(param, &data);
|
size_t fake_len = load_fake(param, &data);
|
||||||
|
|
||||||
if (fake_len > 0) /* else a simple parameter */
|
if (fake_len > 0) /* else a simple parameter */
|
||||||
{
|
{
|
||||||
@@ -1062,7 +1337,8 @@ insert_iTXt(png_structp png_ptr, png_infop info_ptr, int nparams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
|
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||||
|
png_charpp params)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
png_uint_16 freq[256];
|
png_uint_16 freq[256];
|
||||||
@@ -1089,6 +1365,56 @@ insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp par
|
|||||||
png_set_hIST(png_ptr, info_ptr, freq);
|
png_set_hIST(png_ptr, info_ptr, freq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static png_byte
|
||||||
|
bval(png_const_structrp png_ptr, png_charp param, unsigned int maxval)
|
||||||
|
{
|
||||||
|
char *endptr = NULL;
|
||||||
|
unsigned long int l = strtoul(param, &endptr, 0/*base*/);
|
||||||
|
|
||||||
|
if (param[0] && *endptr == 0 && l <= maxval)
|
||||||
|
return (png_byte)l;
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "sBIT: invalid sBIT value");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||||
|
png_charpp params)
|
||||||
|
{
|
||||||
|
int ct = png_get_color_type(png_ptr, info_ptr);
|
||||||
|
int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||||
|
(ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
|
||||||
|
unsigned int maxval =
|
||||||
|
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
|
||||||
|
png_color_8 sBIT;
|
||||||
|
|
||||||
|
if (nparams != c)
|
||||||
|
png_error(png_ptr, "sBIT: incorrect parameter count");
|
||||||
|
|
||||||
|
if (ct & PNG_COLOR_MASK_COLOR)
|
||||||
|
{
|
||||||
|
sBIT.red = bval(png_ptr, params[0], maxval);
|
||||||
|
sBIT.green = bval(png_ptr, params[1], maxval);
|
||||||
|
sBIT.blue = bval(png_ptr, params[2], maxval);
|
||||||
|
sBIT.gray = 42;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sBIT.red = sBIT.green = sBIT.blue = 42;
|
||||||
|
sBIT.gray = bval(png_ptr, params[0], maxval);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ct & PNG_COLOR_MASK_ALPHA)
|
||||||
|
sBIT.alpha = bval(png_ptr, params[nparams-1], maxval);
|
||||||
|
|
||||||
|
else
|
||||||
|
sBIT.alpha = 42;
|
||||||
|
|
||||||
|
png_set_sBIT(png_ptr, info_ptr, &sBIT);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
insert_sPLT(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
|
insert_sPLT(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
|
||||||
@@ -1108,10 +1434,13 @@ find_parameters(png_const_charp what, png_charp param, png_charp *list,
|
|||||||
for (i=0; *param && i<nparams; ++i)
|
for (i=0; *param && i<nparams; ++i)
|
||||||
{
|
{
|
||||||
list[i] = param;
|
list[i] = param;
|
||||||
while (*++param) if (*param == '\n' || *param == ':')
|
while (*++param)
|
||||||
{
|
{
|
||||||
*param++ = 0; /* Terminate last parameter */
|
if (*param == '\n' || *param == ':')
|
||||||
break; /* And start a new one. */
|
{
|
||||||
|
*param++ = 0; /* Terminate last parameter */
|
||||||
|
break; /* And start a new one. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,6 +1545,11 @@ find_insert(png_const_charp what, png_charp param)
|
|||||||
return make_insert(what, insert_hIST, nparams, parameter_list);
|
return make_insert(what, insert_hIST, nparams, parameter_list);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CHUNK(115,66,73,84): /* sBIT */
|
||||||
|
if (nparams <= 4)
|
||||||
|
return make_insert(what, insert_sBIT, nparams, parameter_list);
|
||||||
|
break;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
case CHUNK(115,80,76,84): /* sPLT */
|
case CHUNK(115,80,76,84): /* sPLT */
|
||||||
return make_insert(what, insert_sPLT, nparams, parameter_list);
|
return make_insert(what, insert_sPLT, nparams, parameter_list);
|
||||||
@@ -1231,6 +1565,80 @@ find_insert(png_const_charp what, png_charp param)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is necessary because libpng expects writeable strings for things like
|
||||||
|
* text chunks (maybe this should be fixed...)
|
||||||
|
*/
|
||||||
|
static png_charp
|
||||||
|
strstash(png_const_charp foo)
|
||||||
|
{
|
||||||
|
/* The program indicates a memory allocation error by crashing, this is by
|
||||||
|
* design.
|
||||||
|
*/
|
||||||
|
if (foo != NULL)
|
||||||
|
{
|
||||||
|
png_charp bar = malloc(strlen(foo)+1);
|
||||||
|
return strcpy(bar, foo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_charp
|
||||||
|
strstash_list(const png_const_charp *text)
|
||||||
|
{
|
||||||
|
size_t foo = 0;
|
||||||
|
png_charp result, bar;
|
||||||
|
const png_const_charp *line = text;
|
||||||
|
|
||||||
|
while (*line != NULL)
|
||||||
|
foo += strlen(*line++);
|
||||||
|
|
||||||
|
result = bar = malloc(foo+1);
|
||||||
|
|
||||||
|
line = text;
|
||||||
|
while (*line != NULL)
|
||||||
|
{
|
||||||
|
foo = strlen(*line);
|
||||||
|
memcpy(bar, *line++, foo);
|
||||||
|
bar += foo;
|
||||||
|
}
|
||||||
|
|
||||||
|
*bar = 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* These are used to insert Copyright and Licence fields, they allow the text to
|
||||||
|
* have \n unlike the --insert option.
|
||||||
|
*/
|
||||||
|
static chunk_insert *
|
||||||
|
add_tEXt(const char *key, const png_const_charp *text)
|
||||||
|
{
|
||||||
|
static char what[5] = { 116, 69, 88, 116, 0 };
|
||||||
|
png_charp parameter_list[3];
|
||||||
|
|
||||||
|
parameter_list[0] = strstash(key);
|
||||||
|
parameter_list[1] = strstash_list(text);
|
||||||
|
parameter_list[2] = NULL;
|
||||||
|
|
||||||
|
return make_insert(what, insert_tEXt, 2, parameter_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static chunk_insert *
|
||||||
|
add_iTXt(const char *key, const char *language, const char *language_key,
|
||||||
|
const png_const_charp *text)
|
||||||
|
{
|
||||||
|
static char what[5] = { 105, 84, 88, 116, 0 };
|
||||||
|
png_charp parameter_list[5];
|
||||||
|
|
||||||
|
parameter_list[0] = strstash(key);
|
||||||
|
parameter_list[1] = strstash(language);
|
||||||
|
parameter_list[2] = strstash(language_key);
|
||||||
|
parameter_list[3] = strstash_list(text);
|
||||||
|
parameter_list[4] = NULL;
|
||||||
|
|
||||||
|
return make_insert(what, insert_iTXt, 4, parameter_list);
|
||||||
|
}
|
||||||
|
|
||||||
/* This is a not-very-good parser for a sequence of numbers (including 0). It
|
/* This is a not-very-good parser for a sequence of numbers (including 0). It
|
||||||
* doesn't accept some apparently valid things, but it accepts all the sensible
|
* doesn't accept some apparently valid things, but it accepts all the sensible
|
||||||
* combinations.
|
* combinations.
|
||||||
@@ -1280,6 +1688,8 @@ main(int argc, char **argv)
|
|||||||
const char *file_name = NULL;
|
const char *file_name = NULL;
|
||||||
int color_type = 8; /* invalid */
|
int color_type = 8; /* invalid */
|
||||||
int bit_depth = 32; /* invalid */
|
int bit_depth = 32; /* invalid */
|
||||||
|
int small = 0; /* make full size images */
|
||||||
|
int tRNS = 0; /* don't output a tRNS chunk */
|
||||||
unsigned int colors[5];
|
unsigned int colors[5];
|
||||||
unsigned int filters = PNG_ALL_FILTERS;
|
unsigned int filters = PNG_ALL_FILTERS;
|
||||||
png_fixed_point gamma = 0; /* not set */
|
png_fixed_point gamma = 0; /* not set */
|
||||||
@@ -1292,6 +1702,18 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char *arg = *++argv;
|
char *arg = *++argv;
|
||||||
|
|
||||||
|
if (strcmp(arg, "--small") == 0)
|
||||||
|
{
|
||||||
|
small = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(arg, "--tRNS") == 0)
|
||||||
|
{
|
||||||
|
tRNS = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(arg, "--sRGB") == 0)
|
if (strcmp(arg, "--sRGB") == 0)
|
||||||
{
|
{
|
||||||
gamma = PNG_DEFAULT_sRGB;
|
gamma = PNG_DEFAULT_sRGB;
|
||||||
@@ -1432,15 +1854,16 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (color_type == 8 || bit_depth == 32)
|
if (color_type == 8 || bit_depth == 32)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: makepng [--sRGB|--linear|--1.8] "
|
fprintf(stderr, "usage: makepng [--small] [--sRGB|--linear|--1.8] "
|
||||||
"[--color=...] color-type bit-depth [file-name]\n"
|
"[--color=...] color-type bit-depth [file-name]\n"
|
||||||
" Make a test PNG file, by default writes to stdout.\n");
|
" Make a test PNG file, by default writes to stdout.\n"
|
||||||
|
" Other options are available, UTSL.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check the colors */
|
/* Check the colors */
|
||||||
{
|
{
|
||||||
const unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U :
|
||||||
(1U<<bit_depth)-1);
|
(1U<<bit_depth)-1);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -1453,10 +1876,19 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* small and colors are incompatible (will probably crash if both are used at
|
||||||
|
* the same time!)
|
||||||
|
*/
|
||||||
|
if (small && colors[0] != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "makepng: --color --small: only one at a time!\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Restrict the filters for more speed to those we know are used for the
|
/* Restrict the filters for more speed to those we know are used for the
|
||||||
* generated images.
|
* generated images.
|
||||||
*/
|
*/
|
||||||
if (filters == PNG_ALL_FILTERS)
|
if (filters == PNG_ALL_FILTERS && !small/*small provides defaults*/)
|
||||||
{
|
{
|
||||||
if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8)
|
if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8)
|
||||||
filters = PNG_FILTER_NONE;
|
filters = PNG_FILTER_NONE;
|
||||||
@@ -1474,9 +1906,39 @@ main(int argc, char **argv)
|
|||||||
filters &= ~PNG_FILTER_NONE;
|
filters &= ~PNG_FILTER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Insert standard copyright and licence text. */
|
||||||
|
{
|
||||||
|
static png_const_charp copyright[] =
|
||||||
|
{
|
||||||
|
COPYRIGHT, /* ISO-Latin-1 */
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
static png_const_charp licensing[] =
|
||||||
|
{
|
||||||
|
IMAGE_LICENSING, /* UTF-8 */
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
chunk_insert *new_insert;
|
||||||
|
|
||||||
|
new_insert = add_tEXt("Copyright", copyright);
|
||||||
|
if (new_insert != NULL)
|
||||||
|
{
|
||||||
|
*insert_ptr = new_insert;
|
||||||
|
insert_ptr = &new_insert->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
new_insert = add_iTXt("Licensing", "en", NULL, licensing);
|
||||||
|
if (new_insert != NULL)
|
||||||
|
{
|
||||||
|
*insert_ptr = new_insert;
|
||||||
|
insert_ptr = &new_insert->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int ret = write_png(&file_name, fp, color_type, bit_depth, gamma,
|
int ret = write_png(&file_name, fp, color_type, bit_depth, gamma,
|
||||||
head_insert, filters, colors);
|
head_insert, filters, colors, small, tRNS);
|
||||||
|
|
||||||
if (ret != 0 && file_name != NULL)
|
if (ret != 0 && file_name != NULL)
|
||||||
remove(file_name);
|
remove(file_name);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngimage.c
|
/* pngimage.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 John Cunningham Bowler
|
* Copyright (c) 2021 Cosmin Truta
|
||||||
*
|
* Copyright (c) 2015,2016 John Cunningham Bowler
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
* using png_read_png and then write with png_write_png. Test all possible
|
* using png_read_png and then write with png_write_png. Test all possible
|
||||||
* transforms.
|
* transforms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -36,7 +37,28 @@
|
|||||||
# include <setjmp.h> /* because png.h did *not* include this */
|
# include <setjmp.h> /* because png.h did *not* include this */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PNG_INFO_IMAGE_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
|
||||||
|
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
|
||||||
|
*/
|
||||||
|
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
|
||||||
|
# define SKIP 77
|
||||||
|
#else
|
||||||
|
# define SKIP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if PNG_LIBPNG_VER < 10700
|
||||||
|
/* READ_PNG and WRITE_PNG were not defined, so: */
|
||||||
|
# ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||||
|
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
# define PNG_READ_PNG_SUPPORTED
|
||||||
|
# endif /* SEQUENTIAL_READ */
|
||||||
|
# ifdef PNG_WRITE_SUPPORTED
|
||||||
|
# define PNG_WRITE_PNG_SUPPORTED
|
||||||
|
# endif /* WRITE */
|
||||||
|
# endif /* INFO_IMAGE */
|
||||||
|
#endif /* pre 1.7.0 */
|
||||||
|
|
||||||
|
#ifdef PNG_READ_PNG_SUPPORTED
|
||||||
/* If a transform is valid on both read and write this implies that if the
|
/* If a transform is valid on both read and write this implies that if the
|
||||||
* transform is applied to read it must also be applied on write to produce
|
* transform is applied to read it must also be applied on write to produce
|
||||||
* meaningful data. This is because these transforms when performed on read
|
* meaningful data. This is because these transforms when performed on read
|
||||||
@@ -236,10 +258,12 @@ static struct transform_info
|
|||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
T(SCALE_16, NONE, X, X, 16, R)
|
T(SCALE_16, NONE, X, X, 16, R),
|
||||||
/* scales 16-bit components to 8-bits. */
|
/* scales 16-bit components to 8-bits. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{ NULL /*name*/, 0, 0, 0, 0, 0, 0, 0/*!tested*/ }
|
||||||
|
|
||||||
#undef T
|
#undef T
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -295,10 +319,9 @@ transform_name(int t)
|
|||||||
t &= -t; /* first set bit */
|
t &= -t; /* first set bit */
|
||||||
|
|
||||||
for (i=0; i<TTABLE_SIZE; ++i)
|
for (i=0; i<TTABLE_SIZE; ++i)
|
||||||
{
|
if (transform_info[i].name != NULL)
|
||||||
if ((transform_info[i].transform & t) != 0)
|
if ((transform_info[i].transform & t) != 0)
|
||||||
return transform_info[i].name;
|
return transform_info[i].name;
|
||||||
}
|
|
||||||
|
|
||||||
return "invalid transform";
|
return "invalid transform";
|
||||||
}
|
}
|
||||||
@@ -317,11 +340,14 @@ validate_T(void)
|
|||||||
|
|
||||||
for (i=0; i<TTABLE_SIZE; ++i)
|
for (i=0; i<TTABLE_SIZE; ++i)
|
||||||
{
|
{
|
||||||
if (transform_info[i].when & TRANSFORM_R)
|
if (transform_info[i].name != NULL)
|
||||||
read_transforms |= transform_info[i].transform;
|
{
|
||||||
|
if (transform_info[i].when & TRANSFORM_R)
|
||||||
|
read_transforms |= transform_info[i].transform;
|
||||||
|
|
||||||
if (transform_info[i].when & TRANSFORM_W)
|
if (transform_info[i].when & TRANSFORM_W)
|
||||||
write_transforms |= transform_info[i].transform;
|
write_transforms |= transform_info[i].transform;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reversible transforms are those which are supported on both read and
|
/* Reversible transforms are those which are supported on both read and
|
||||||
@@ -337,6 +363,9 @@ validate_T(void)
|
|||||||
* In both cases the file data is held in a linked list of buffers - not all
|
* In both cases the file data is held in a linked list of buffers - not all
|
||||||
* of these are in use at any time.
|
* of these are in use at any time.
|
||||||
*/
|
*/
|
||||||
|
#define NEW(type) ((type *)malloc(sizeof (type)))
|
||||||
|
#define DELETE(ptr) (free(ptr))
|
||||||
|
|
||||||
struct buffer_list
|
struct buffer_list
|
||||||
{
|
{
|
||||||
struct buffer_list *next; /* next buffer in list */
|
struct buffer_list *next; /* next buffer in list */
|
||||||
@@ -361,7 +390,26 @@ buffer_init(struct buffer *buffer)
|
|||||||
buffer->current = NULL;
|
buffer->current = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
static void
|
||||||
|
buffer_destroy_list(struct buffer_list *list)
|
||||||
|
{
|
||||||
|
if (list != NULL)
|
||||||
|
{
|
||||||
|
struct buffer_list *next = list->next;
|
||||||
|
DELETE(list);
|
||||||
|
buffer_destroy_list(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
buffer_destroy(struct buffer *buffer)
|
||||||
|
{
|
||||||
|
struct buffer_list *list = buffer->first.next;
|
||||||
|
buffer_init(buffer);
|
||||||
|
buffer_destroy_list(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
static void
|
static void
|
||||||
buffer_start_write(struct buffer *buffer)
|
buffer_start_write(struct buffer *buffer)
|
||||||
{
|
{
|
||||||
@@ -390,8 +438,6 @@ get_buffer(png_structp pp)
|
|||||||
return (struct buffer*)png_get_io_ptr(pp);
|
return (struct buffer*)png_get_io_ptr(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NEW(type) ((type *)malloc(sizeof (type)))
|
|
||||||
|
|
||||||
static struct buffer_list *
|
static struct buffer_list *
|
||||||
buffer_extend(struct buffer_list *current)
|
buffer_extend(struct buffer_list *current)
|
||||||
{
|
{
|
||||||
@@ -485,6 +531,7 @@ typedef enum
|
|||||||
#define SKIP_BUGS 0x100 /* Skip over known bugs */
|
#define SKIP_BUGS 0x100 /* Skip over known bugs */
|
||||||
#define LOG_SKIPPED 0x200 /* Log skipped bugs */
|
#define LOG_SKIPPED 0x200 /* Log skipped bugs */
|
||||||
#define FIND_BAD_COMBOS 0x400 /* Attempt to deduce bad combos */
|
#define FIND_BAD_COMBOS 0x400 /* Attempt to deduce bad combos */
|
||||||
|
#define LIST_COMBOS 0x800 /* List combos by name */
|
||||||
|
|
||||||
/* Result masks apply to the result bits in the 'results' field below; these
|
/* Result masks apply to the result bits in the 'results' field below; these
|
||||||
* bits are simple 1U<<error_level. A pass requires either nothing worse than
|
* bits are simple 1U<<error_level. A pass requires either nothing worse than
|
||||||
@@ -507,7 +554,7 @@ struct display
|
|||||||
png_structp original_pp; /* used on the original read */
|
png_structp original_pp; /* used on the original read */
|
||||||
png_infop original_ip; /* set by the original read */
|
png_infop original_ip; /* set by the original read */
|
||||||
|
|
||||||
png_size_t original_rowbytes; /* of the original rows: */
|
size_t original_rowbytes; /* of the original rows: */
|
||||||
png_bytepp original_rows; /* from the original read */
|
png_bytepp original_rows; /* from the original read */
|
||||||
|
|
||||||
/* Original chunks valid */
|
/* Original chunks valid */
|
||||||
@@ -532,7 +579,7 @@ struct display
|
|||||||
png_structp read_pp;
|
png_structp read_pp;
|
||||||
png_infop read_ip;
|
png_infop read_ip;
|
||||||
|
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
/* Used to write a new image (the original info_ptr is used) */
|
/* Used to write a new image (the original info_ptr is used) */
|
||||||
png_structp write_pp;
|
png_structp write_pp;
|
||||||
struct buffer written_file; /* where the file gets written */
|
struct buffer written_file; /* where the file gets written */
|
||||||
@@ -559,7 +606,7 @@ display_init(struct display *dp)
|
|||||||
dp->read_ip = NULL;
|
dp->read_ip = NULL;
|
||||||
buffer_init(&dp->original_file);
|
buffer_init(&dp->original_file);
|
||||||
|
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
dp->write_pp = NULL;
|
dp->write_pp = NULL;
|
||||||
buffer_init(&dp->written_file);
|
buffer_init(&dp->written_file);
|
||||||
# endif
|
# endif
|
||||||
@@ -572,7 +619,7 @@ display_clean_read(struct display *dp)
|
|||||||
png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL);
|
png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
static void
|
static void
|
||||||
display_clean_write(struct display *dp)
|
display_clean_write(struct display *dp)
|
||||||
{
|
{
|
||||||
@@ -584,7 +631,7 @@ display_clean_write(struct display *dp)
|
|||||||
static void
|
static void
|
||||||
display_clean(struct display *dp)
|
display_clean(struct display *dp)
|
||||||
{
|
{
|
||||||
# ifdef PNG_WRITE_SUPPORTED
|
# ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
display_clean_write(dp);
|
display_clean_write(dp);
|
||||||
# endif
|
# endif
|
||||||
display_clean_read(dp);
|
display_clean_read(dp);
|
||||||
@@ -598,6 +645,17 @@ display_clean(struct display *dp)
|
|||||||
dp->results = 0; /* reset for next time */
|
dp->results = 0; /* reset for next time */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
display_destroy(struct display *dp)
|
||||||
|
{
|
||||||
|
/* Release any memory held in the display. */
|
||||||
|
# ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
|
buffer_destroy(&dp->written_file);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
buffer_destroy(&dp->original_file);
|
||||||
|
}
|
||||||
|
|
||||||
static struct display *
|
static struct display *
|
||||||
get_dp(png_structp pp)
|
get_dp(png_structp pp)
|
||||||
/* The display pointer is always stored in the png_struct error pointer */
|
/* The display pointer is always stored in the png_struct error pointer */
|
||||||
@@ -659,7 +717,35 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
|
|||||||
int tr = dp->transforms;
|
int tr = dp->transforms;
|
||||||
|
|
||||||
if (is_combo(tr))
|
if (is_combo(tr))
|
||||||
fprintf(stderr, "(0x%x)", tr);
|
{
|
||||||
|
if (dp->options & LIST_COMBOS)
|
||||||
|
{
|
||||||
|
int trx = tr;
|
||||||
|
|
||||||
|
fprintf(stderr, "(");
|
||||||
|
if (trx)
|
||||||
|
{
|
||||||
|
int start = 0;
|
||||||
|
|
||||||
|
while (trx)
|
||||||
|
{
|
||||||
|
int trz = trx & -trx;
|
||||||
|
|
||||||
|
if (start) fprintf(stderr, "+");
|
||||||
|
fprintf(stderr, "%s", transform_name(trz));
|
||||||
|
start = 1;
|
||||||
|
trx &= ~trz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "-");
|
||||||
|
fprintf(stderr, ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "(0x%x)", tr);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
fprintf(stderr, "(%s)", transform_name(tr));
|
fprintf(stderr, "(%s)", transform_name(tr));
|
||||||
@@ -724,7 +810,7 @@ display_cache_file(struct display *dp, const char *filename)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
||||||
png_size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
struct buffer_list *last = bp->current;
|
struct buffer_list *last = bp->current;
|
||||||
size_t read_count = bp->read_count;
|
size_t read_count = bp->read_count;
|
||||||
@@ -772,7 +858,7 @@ buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void PNGCBAPI
|
static void PNGCBAPI
|
||||||
read_function(png_structp pp, png_bytep data, png_size_t size)
|
read_function(png_structp pp, png_bytep data, size_t size)
|
||||||
{
|
{
|
||||||
buffer_read(get_dp(pp), get_buffer(pp), data, size);
|
buffer_read(get_dp(pp), get_buffer(pp), data, size);
|
||||||
}
|
}
|
||||||
@@ -844,7 +930,7 @@ update_display(struct display *dp)
|
|||||||
png_structp pp;
|
png_structp pp;
|
||||||
png_infop ip;
|
png_infop ip;
|
||||||
|
|
||||||
/* Now perform the initial read with a 0 tranform. */
|
/* Now perform the initial read with a 0 transform. */
|
||||||
read_png(dp, &dp->original_file, "original read", 0/*no transform*/);
|
read_png(dp, &dp->original_file, "original read", 0/*no transform*/);
|
||||||
|
|
||||||
/* Move the result to the 'original' fields */
|
/* Move the result to the 'original' fields */
|
||||||
@@ -881,19 +967,22 @@ update_display(struct display *dp)
|
|||||||
|
|
||||||
for (i=0; i<TTABLE_SIZE; ++i)
|
for (i=0; i<TTABLE_SIZE; ++i)
|
||||||
{
|
{
|
||||||
int transform = transform_info[i].transform;
|
if (transform_info[i].name != NULL)
|
||||||
|
{
|
||||||
|
int transform = transform_info[i].transform;
|
||||||
|
|
||||||
if ((transform_info[i].valid_chunks == 0 ||
|
if ((transform_info[i].valid_chunks == 0 ||
|
||||||
(transform_info[i].valid_chunks & chunks) != 0) &&
|
(transform_info[i].valid_chunks & chunks) != 0) &&
|
||||||
(transform_info[i].color_mask_required & ct) ==
|
(transform_info[i].color_mask_required & ct) ==
|
||||||
transform_info[i].color_mask_required &&
|
transform_info[i].color_mask_required &&
|
||||||
(transform_info[i].color_mask_absent & ct) == 0 &&
|
(transform_info[i].color_mask_absent & ct) == 0 &&
|
||||||
(transform_info[i].bit_depths & bd) != 0 &&
|
(transform_info[i].bit_depths & bd) != 0 &&
|
||||||
(transform_info[i].when & TRANSFORM_R) != 0)
|
(transform_info[i].when & TRANSFORM_R) != 0)
|
||||||
active |= transform;
|
active |= transform;
|
||||||
|
|
||||||
else if ((transform_info[i].when & TRANSFORM_R) != 0)
|
else if ((transform_info[i].when & TRANSFORM_R) != 0)
|
||||||
inactive |= transform;
|
inactive |= transform;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some transforms appear multiple times in the table; the 'active' status
|
/* Some transforms appear multiple times in the table; the 'active' status
|
||||||
@@ -904,9 +993,6 @@ update_display(struct display *dp)
|
|||||||
|
|
||||||
dp->active_transforms = active;
|
dp->active_transforms = active;
|
||||||
dp->ignored_transforms = inactive; /* excluding write-only transforms */
|
dp->ignored_transforms = inactive; /* excluding write-only transforms */
|
||||||
|
|
||||||
if (active == 0)
|
|
||||||
display_log(dp, INTERNAL_ERROR, "bad transform table");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,8 +1006,9 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
int interlace_method, compression_method, filter_method;
|
int interlace_method, compression_method, filter_method;
|
||||||
const char *e = NULL;
|
const char *e = NULL;
|
||||||
|
|
||||||
png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth,
|
if (!png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth,
|
||||||
&color_type, &interlace_method, &compression_method, &filter_method);
|
&color_type, &interlace_method, &compression_method, &filter_method))
|
||||||
|
display_log(dp, LIBPNG_BUG, "png_get_IHDR failed");
|
||||||
|
|
||||||
# define C(item) if (item != dp->item) \
|
# define C(item) if (item != dp->item) \
|
||||||
display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\
|
display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\
|
||||||
@@ -946,7 +1033,7 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
{
|
{
|
||||||
unsigned long chunks =
|
unsigned long chunks =
|
||||||
png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff);
|
png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff);
|
||||||
|
|
||||||
if (chunks != dp->chunks)
|
if (chunks != dp->chunks)
|
||||||
display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx",
|
display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx",
|
||||||
(unsigned long)dp->chunks, chunks);
|
(unsigned long)dp->chunks, chunks);
|
||||||
@@ -1001,8 +1088,9 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
size_t x;
|
size_t x;
|
||||||
|
|
||||||
/* Find the first error */
|
/* Find the first error */
|
||||||
for (x=0; x<rowbytes-1; ++x) if (row[x] != orig[x])
|
for (x=0; x<rowbytes-1; ++x)
|
||||||
break;
|
if (row[x] != orig[x])
|
||||||
|
break;
|
||||||
|
|
||||||
display_log(dp, APP_FAIL,
|
display_log(dp, APP_FAIL,
|
||||||
"byte(%lu,%lu) changed 0x%.2x -> 0x%.2x",
|
"byte(%lu,%lu) changed 0x%.2x -> 0x%.2x",
|
||||||
@@ -1013,6 +1101,7 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
# ifdef PNG_sBIT_SUPPORTED
|
||||||
{
|
{
|
||||||
unsigned long y;
|
unsigned long y;
|
||||||
int bpp; /* bits-per-pixel then bytes-per-pixel */
|
int bpp; /* bits-per-pixel then bytes-per-pixel */
|
||||||
@@ -1056,6 +1145,7 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
display_log(dp, LIBPNG_ERROR, "invalid colour type %d",
|
display_log(dp, LIBPNG_ERROR, "invalid colour type %d",
|
||||||
color_type);
|
color_type);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
memset(sig_bits, 0, sizeof(sig_bits));
|
||||||
bpp = 0;
|
bpp = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1089,8 +1179,8 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
{
|
{
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
case 16: /* Two bytes per component, bit-endian */
|
case 16: /* Two bytes per component, big-endian */
|
||||||
for (b = (bpp >> 4); b > 0; )
|
for (b = (bpp >> 4); b > 0; --b)
|
||||||
{
|
{
|
||||||
unsigned int sig = (unsigned int)(0xffff0000 >> sig_bits[b]);
|
unsigned int sig = (unsigned int)(0xffff0000 >> sig_bits[b]);
|
||||||
|
|
||||||
@@ -1117,7 +1207,7 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
sig_bits[0] = (png_byte)b;
|
sig_bits[0] = (png_byte)b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: /* Relicate twice */
|
case 4: /* Replicate twice */
|
||||||
/* Value is 1, 2, 3 or 4 */
|
/* Value is 1, 2, 3 or 4 */
|
||||||
b = 0xf & ((0xf << 4) >> sig_bits[0]);
|
b = 0xf & ((0xf << 4) >> sig_bits[0]);
|
||||||
b |= b << 4;
|
b |= b << 4;
|
||||||
@@ -1174,15 +1264,19 @@ compare_read(struct display *dp, int applied_transforms)
|
|||||||
}
|
}
|
||||||
} /* for y */
|
} /* for y */
|
||||||
}
|
}
|
||||||
|
# else /* !sBIT */
|
||||||
|
display_log(dp, INTERNAL_ERROR,
|
||||||
|
"active shift transform but no sBIT support");
|
||||||
|
# endif /* !sBIT */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1; /* compare succeeded */
|
return 1; /* compare succeeded */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
static void
|
static void
|
||||||
buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
||||||
png_size_t size)
|
size_t size)
|
||||||
/* Generic write function used both from the write callback provided to
|
/* Generic write function used both from the write callback provided to
|
||||||
* libpng and from the generic read code.
|
* libpng and from the generic read code.
|
||||||
*/
|
*/
|
||||||
@@ -1226,7 +1320,7 @@ buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void PNGCBAPI
|
static void PNGCBAPI
|
||||||
write_function(png_structp pp, png_bytep data, png_size_t size)
|
write_function(png_structp pp, png_bytep data, size_t size)
|
||||||
{
|
{
|
||||||
buffer_write(get_dp(pp), get_buffer(pp), data, size);
|
buffer_write(get_dp(pp), get_buffer(pp), data, size);
|
||||||
}
|
}
|
||||||
@@ -1278,7 +1372,7 @@ write_png(struct display *dp, png_infop ip, int transforms)
|
|||||||
*/
|
*/
|
||||||
display_clean_write(dp);
|
display_clean_write(dp);
|
||||||
}
|
}
|
||||||
#endif /* WRITE_SUPPORTED */
|
#endif /* WRITE_PNG */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
skip_transform(struct display *dp, int tr)
|
skip_transform(struct display *dp, int tr)
|
||||||
@@ -1340,7 +1434,7 @@ test_one_file(struct display *dp, const char *filename)
|
|||||||
return; /* no point testing more */
|
return; /* no point testing more */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
/* Second test: write the original PNG data out to a new file (to test the
|
/* Second test: write the original PNG data out to a new file (to test the
|
||||||
* write side) then read the result back in and make sure that it hasn't
|
* write side) then read the result back in and make sure that it hasn't
|
||||||
* changed.
|
* changed.
|
||||||
@@ -1361,7 +1455,7 @@ test_one_file(struct display *dp, const char *filename)
|
|||||||
* unsigned, because some transforms are negative on a 16-bit system.
|
* unsigned, because some transforms are negative on a 16-bit system.
|
||||||
*/
|
*/
|
||||||
unsigned int active = dp->active_transforms;
|
unsigned int active = dp->active_transforms;
|
||||||
const int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
int exhaustive = (dp->options & EXHAUSTIVE) != 0;
|
||||||
unsigned int current = first_transform(active);
|
unsigned int current = first_transform(active);
|
||||||
unsigned int bad_transforms = 0;
|
unsigned int bad_transforms = 0;
|
||||||
unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */
|
unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */
|
||||||
@@ -1381,7 +1475,7 @@ test_one_file(struct display *dp, const char *filename)
|
|||||||
* out and read it back in again (without the reversible transforms)
|
* out and read it back in again (without the reversible transforms)
|
||||||
* we should get back to the place where we started.
|
* we should get back to the place where we started.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||||
if ((current & write_transforms) == current)
|
if ((current & write_transforms) == current)
|
||||||
{
|
{
|
||||||
/* All transforms reversible: write the PNG with the transformations
|
/* All transforms reversible: write the PNG with the transformations
|
||||||
@@ -1487,7 +1581,7 @@ do_test(struct display *dp, const char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(const int argc, const char * const * const argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
/* For each file on the command line test it with a range of transforms */
|
/* For each file on the command line test it with a range of transforms */
|
||||||
int option_end, ilog = 0;
|
int option_end, ilog = 0;
|
||||||
@@ -1557,6 +1651,12 @@ main(const int argc, const char * const * const argv)
|
|||||||
else if (strcmp(name, "--nofind-bad-combos") == 0)
|
else if (strcmp(name, "--nofind-bad-combos") == 0)
|
||||||
d.options &= ~FIND_BAD_COMBOS;
|
d.options &= ~FIND_BAD_COMBOS;
|
||||||
|
|
||||||
|
else if (strcmp(name, "--list-combos") == 0)
|
||||||
|
d.options |= LIST_COMBOS;
|
||||||
|
|
||||||
|
else if (strcmp(name, "--nolist-combos") == 0)
|
||||||
|
d.options &= ~LIST_COMBOS;
|
||||||
|
|
||||||
else if (name[0] == '-' && name[1] == '-')
|
else if (name[0] == '-' && name[1] == '-')
|
||||||
{
|
{
|
||||||
fprintf(stderr, "pngimage: %s: unknown option\n", name);
|
fprintf(stderr, "pngimage: %s: unknown option\n", name);
|
||||||
@@ -1583,7 +1683,7 @@ main(const int argc, const char * const * const argv)
|
|||||||
/* Here on any return, including failures, except user/internal issues
|
/* Here on any return, including failures, except user/internal issues
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
const int pass = (d.options & STRICT) ?
|
int pass = (d.options & STRICT) ?
|
||||||
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
RESULT_STRICT(d.results) : RESULT_RELAXED(d.results);
|
||||||
|
|
||||||
if (!pass)
|
if (!pass)
|
||||||
@@ -1595,8 +1695,9 @@ main(const int argc, const char * const * const argv)
|
|||||||
|
|
||||||
printf("%s: pngimage ", pass ? "PASS" : "FAIL");
|
printf("%s: pngimage ", pass ? "PASS" : "FAIL");
|
||||||
|
|
||||||
for (j=1; j<option_end; ++j) if (j != ilog)
|
for (j=1; j<option_end; ++j)
|
||||||
printf("%s ", argv[j]);
|
if (j != ilog)
|
||||||
|
printf("%s ", argv[j]);
|
||||||
|
|
||||||
printf("%s\n", d.filename);
|
printf("%s\n", d.filename);
|
||||||
}
|
}
|
||||||
@@ -1605,14 +1706,17 @@ main(const int argc, const char * const * const argv)
|
|||||||
display_clean(&d);
|
display_clean(&d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Release allocated memory */
|
||||||
|
display_destroy(&d);
|
||||||
|
|
||||||
return errors != 0;
|
return errors != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* !PNG_INFO_IMAGE_SUPPORTED || !PNG_READ_SUPPORTED */
|
#else /* !READ_PNG */
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "pngimage: no support for png_read/write_image\n");
|
fprintf(stderr, "pngimage: no support for png_read/write_image\n");
|
||||||
return 77;
|
return SKIP;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
165
contrib/libtests/pngstest-errors.h
Normal file
165
contrib/libtests/pngstest-errors.h
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/* contrib/libtests/pngstest-errors.h
|
||||||
|
*
|
||||||
|
* BUILT USING: libpng version 1.6.19beta03 - September 25, 2015
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* THIS IS A MACHINE GENERATED FILE: do not edit it directly!
|
||||||
|
* Instead run:
|
||||||
|
*
|
||||||
|
* pngstest --accumulate
|
||||||
|
*
|
||||||
|
* on as many PNG files as possible; at least PNGSuite and
|
||||||
|
* contrib/libtests/testpngs.
|
||||||
|
*/
|
||||||
|
static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 19, 0, 0 }, { 0, 0, 0, 0 }, { 0, 20, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 893, 0 }, { 0, 0, 893, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 16, 17, 0 }, { 0, 17, 17, 0 }, { 0, 19, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 850, 875, 0 }, { 0, 850, 875, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 74, 9, 0 }, { 0, 20, 9, 0 }, { 0, 74, 9, 0 }, { 0, 20, 9, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 126, 143, 0 }, { 0, 11, 7, 0 }, { 0, 74, 9, 0 }, { 0, 17, 9, 0 },
|
||||||
|
{ 0, 4, 4, 0 }, { 0, 5, 4, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb */
|
||||||
|
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 673, 0 }, { 0, 0, 673, 0 }, { 0, 0, 674, 0 }, { 0, 0, 674, 0 },
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 460, 0 }, { 0, 0, 460, 0 }, { 0, 0, 263, 0 }, { 0, 0, 263, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||||
|
{ 0, 6, 8, 0 }, { 0, 7, 8, 0 }, { 0, 75, 9, 0 }, { 0, 9, 9, 0 },
|
||||||
|
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 514, 0 }, { 0, 717, 514, 0 },
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 13323, 460, 0 }, { 0, 427, 460, 0 }, { 0, 16480, 263, 0 }, { 0, 243, 263, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 253, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 265, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 243, 265, 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 15, 15, 0 }, { 0, 186, 15, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 20, 0 }, { 0, 0, 20, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 16, 17, 0 }, { 0, 187, 17, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 9, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb */
|
||||||
|
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||||
|
{ 0, 4, 8, 0 }, { 0, 9, 8, 0 }, { 0, 9, 5, 0 }, { 0, 32, 5, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 19, 9, 0 }, { 0, 255, 9, 25 }, { 0, 88, 9, 0 }, { 0, 255, 9, 25 },
|
||||||
|
{ 0, 1012, 928, 0 }, { 0, 16026, 928, 6425 }, { 0, 1012, 928, 0 }, { 0, 16026, 928, 6425 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
|
||||||
|
{ 0, 0, 962, 0 }, { 0, 0, 962, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 225, 25, 0 }, { 0, 255, 25, 67 },
|
||||||
|
{ 0, 17534, 18491, 0 }, { 0, 15736, 2824, 6425 }, { 0, 14019, 13677, 0 }, { 0, 50115, 13677, 17219 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 },
|
||||||
|
{ 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 74, 74, 0 }, { 0, 255, 74, 25 }, { 0, 99, 74, 0 }, { 0, 255, 74, 25 },
|
||||||
|
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 98, 0 }, { 0, 0, 98, 0 },
|
||||||
|
{ 0, 0, 18664, 0 }, { 0, 0, 18664, 0 }, { 0, 0, 24998, 0 }, { 0, 0, 24998, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 181, 196, 0 }, { 0, 255, 61, 25 }, { 206, 187, 98, 0 }, { 0, 255, 98, 67 },
|
||||||
|
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 49172, 24992, 17347 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/* END MACHINE GENERATED */
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
/*-
|
|
||||||
* pngstest.c
|
/* pngstest.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 John Cunningham Bowler
|
* Copyright (c) 2021 Cosmin Truta
|
||||||
*
|
* Copyright (c) 2013-2017 John Cunningham Bowler
|
||||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -11,8 +10,9 @@
|
|||||||
*
|
*
|
||||||
* Test for the PNG 'simplified' APIs.
|
* Test for the PNG 'simplified' APIs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define _ISOC90_SOURCE 1
|
#define _ISOC90_SOURCE 1
|
||||||
#define MALLOC_CHECK_ 2/*glibc facility: turn on debugging*/
|
#define MALLOC_CHECK_ 2 /*glibc facility: turn on debugging*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -35,6 +35,15 @@
|
|||||||
# include "../../png.h"
|
# include "../../png.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
|
||||||
|
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
|
||||||
|
*/
|
||||||
|
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
|
||||||
|
# define SKIP 77
|
||||||
|
#else
|
||||||
|
# define SKIP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* Else nothing can be done */
|
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* Else nothing can be done */
|
||||||
#include "../tools/sRGB.h"
|
#include "../tools/sRGB.h"
|
||||||
|
|
||||||
@@ -99,10 +108,18 @@ make_random_bytes(png_uint_32* seed, void* pv, size_t size)
|
|||||||
seed[1] = u1;
|
seed[1] = u1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static png_uint_32 color_seed[2];
|
||||||
|
|
||||||
|
static void
|
||||||
|
reseed(void)
|
||||||
|
{
|
||||||
|
color_seed[0] = 0x12345678U;
|
||||||
|
color_seed[1] = 0x9abcdefU;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
random_color(png_colorp color)
|
random_color(png_colorp color)
|
||||||
{
|
{
|
||||||
static png_uint_32 color_seed[2] = { 0x12345678, 0x9abcdef };
|
|
||||||
make_random_bytes(color_seed, color, sizeof *color);
|
make_random_bytes(color_seed, color, sizeof *color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +324,7 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms)
|
|||||||
}
|
}
|
||||||
#endif /* unused */
|
#endif /* unused */
|
||||||
|
|
||||||
#define READ_FILE 1 /* else memory */
|
#define USE_FILE 1 /* else memory */
|
||||||
#define USE_STDIO 2 /* else use file name */
|
#define USE_STDIO 2 /* else use file name */
|
||||||
#define STRICT 4 /* fail on warnings too */
|
#define STRICT 4 /* fail on warnings too */
|
||||||
#define VERBOSE 8
|
#define VERBOSE 8
|
||||||
@@ -316,16 +333,19 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms)
|
|||||||
#define ACCUMULATE 64
|
#define ACCUMULATE 64
|
||||||
#define FAST_WRITE 128
|
#define FAST_WRITE 128
|
||||||
#define sRGB_16BIT 256
|
#define sRGB_16BIT 256
|
||||||
|
#define NO_RESEED 512 /* do not reseed on each new file */
|
||||||
|
#define GBG_ERROR 1024 /* do not ignore the gamma+background_rgb_to_gray
|
||||||
|
* libpng warning. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_opts(png_uint_32 opts)
|
print_opts(png_uint_32 opts)
|
||||||
{
|
{
|
||||||
if (opts & READ_FILE)
|
if (opts & USE_FILE)
|
||||||
printf(" --file");
|
printf(" --file");
|
||||||
if (opts & USE_STDIO)
|
if (opts & USE_STDIO)
|
||||||
printf(" --stdio");
|
printf(" --stdio");
|
||||||
if (opts & STRICT)
|
if (!(opts & STRICT))
|
||||||
printf(" --strict");
|
printf(" --nostrict");
|
||||||
if (opts & VERBOSE)
|
if (opts & VERBOSE)
|
||||||
printf(" --verbose");
|
printf(" --verbose");
|
||||||
if (opts & KEEP_TMPFILES)
|
if (opts & KEEP_TMPFILES)
|
||||||
@@ -338,6 +358,12 @@ print_opts(png_uint_32 opts)
|
|||||||
printf(" --slow");
|
printf(" --slow");
|
||||||
if (opts & sRGB_16BIT)
|
if (opts & sRGB_16BIT)
|
||||||
printf(" --sRGB-16bit");
|
printf(" --sRGB-16bit");
|
||||||
|
if (opts & NO_RESEED)
|
||||||
|
printf(" --noreseed");
|
||||||
|
#if PNG_LIBPNG_VER < 10700 /* else on by default */
|
||||||
|
if (opts & GBG_ERROR)
|
||||||
|
printf(" --fault-gbg-warning");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
|
#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
|
||||||
@@ -347,7 +373,7 @@ print_opts(png_uint_32 opts)
|
|||||||
*/
|
*/
|
||||||
#define FORMAT_COUNT 64
|
#define FORMAT_COUNT 64
|
||||||
#define FORMAT_MASK 0x3f
|
#define FORMAT_MASK 0x3f
|
||||||
static PNG_CONST char * PNG_CONST format_names[FORMAT_COUNT] =
|
static const char * const format_names[FORMAT_COUNT] =
|
||||||
{
|
{
|
||||||
"sRGB-gray",
|
"sRGB-gray",
|
||||||
"sRGB-gray+alpha",
|
"sRGB-gray+alpha",
|
||||||
@@ -553,11 +579,11 @@ typedef struct
|
|||||||
int stride_extra;
|
int stride_extra;
|
||||||
FILE *input_file;
|
FILE *input_file;
|
||||||
png_voidp input_memory;
|
png_voidp input_memory;
|
||||||
png_size_t input_memory_size;
|
size_t input_memory_size;
|
||||||
png_bytep buffer;
|
png_bytep buffer;
|
||||||
ptrdiff_t stride;
|
ptrdiff_t stride;
|
||||||
png_size_t bufsize;
|
size_t bufsize;
|
||||||
png_size_t allocsize;
|
size_t allocsize;
|
||||||
char tmpfile_name[32];
|
char tmpfile_name[32];
|
||||||
png_uint_16 colormap[256*4];
|
png_uint_16 colormap[256*4];
|
||||||
}
|
}
|
||||||
@@ -615,7 +641,7 @@ freeimage(Image *image)
|
|||||||
|
|
||||||
if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0)
|
if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0)
|
||||||
{
|
{
|
||||||
remove(image->tmpfile_name);
|
(void)remove(image->tmpfile_name);
|
||||||
image->tmpfile_name[0] = 0;
|
image->tmpfile_name[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -640,7 +666,7 @@ static void initimage(Image *image, png_uint_32 opts, const char *file_name,
|
|||||||
static void
|
static void
|
||||||
allocbuffer(Image *image)
|
allocbuffer(Image *image)
|
||||||
{
|
{
|
||||||
png_size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride);
|
size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride);
|
||||||
|
|
||||||
if (size+32 > image->bufsize)
|
if (size+32 > image->bufsize)
|
||||||
{
|
{
|
||||||
@@ -741,8 +767,15 @@ checkopaque(Image *image)
|
|||||||
return logerror(image, image->file_name, ": opaque not NULL", "");
|
return logerror(image, image->file_name, ": opaque not NULL", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (image->image.warning_or_error != 0 && (image->opts & STRICT) != 0)
|
/* Separate out the gamma+background_rgb_to_gray warning because it may
|
||||||
return logerror(image, image->file_name, " --strict", "");
|
* produce opaque component errors:
|
||||||
|
*/
|
||||||
|
else if (image->image.warning_or_error != 0 &&
|
||||||
|
(strcmp(image->image.message,
|
||||||
|
"libpng does not support gamma+background+rgb_to_gray") == 0 ?
|
||||||
|
(image->opts & GBG_ERROR) != 0 : (image->opts & STRICT) != 0))
|
||||||
|
return logerror(image, image->file_name, (image->opts & GBG_ERROR) != 0 ?
|
||||||
|
" --fault-gbg-warning" : " --strict", "");
|
||||||
|
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1110,7 +1143,7 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convertion between pixel formats. The code above effectively eliminates the
|
/* Conversion between pixel formats. The code above effectively eliminates the
|
||||||
* component ordering changes leaving three basic changes:
|
* component ordering changes leaving three basic changes:
|
||||||
*
|
*
|
||||||
* 1) Remove an alpha channel by pre-multiplication or compositing on a
|
* 1) Remove an alpha channel by pre-multiplication or compositing on a
|
||||||
@@ -1118,7 +1151,7 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
|
|||||||
*
|
*
|
||||||
* 2) Remove color by mapping to grayscale. (Grayscale to color is a no-op.)
|
* 2) Remove color by mapping to grayscale. (Grayscale to color is a no-op.)
|
||||||
*
|
*
|
||||||
* 3) Convert between 8-bit and 16-bit components. (Both directtions are
|
* 3) Convert between 8-bit and 16-bit components. (Both directions are
|
||||||
* relevant.)
|
* relevant.)
|
||||||
*
|
*
|
||||||
* This gives the following base format conversion matrix:
|
* This gives the following base format conversion matrix:
|
||||||
@@ -1984,156 +2017,7 @@ static void (* const gpc_fn_colormapped[8/*in*/][8/*out*/])
|
|||||||
* gpc_error_to_colormap.
|
* gpc_error_to_colormap.
|
||||||
*/
|
*/
|
||||||
#if PNG_FORMAT_FLAG_COLORMAP == 8 /* extra check also required */
|
#if PNG_FORMAT_FLAG_COLORMAP == 8 /* extra check also required */
|
||||||
/* START MACHINE GENERATED */
|
# include "pngstest-errors.h" /* machine generated */
|
||||||
static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =
|
|
||||||
{
|
|
||||||
{ /* input: sRGB-gray */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: sRGB-gray+alpha */
|
|
||||||
{ 0, 18, 0, 0 }, { 0, 0, 0, 0 }, { 0, 20, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: sRGB-rgb */
|
|
||||||
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 893, 0 }, { 0, 0, 893, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: sRGB-rgb+alpha */
|
|
||||||
{ 0, 4, 13, 0 }, { 0, 14, 13, 0 }, { 0, 19, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 832, 764, 0 }, { 0, 832, 764, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: linear-gray */
|
|
||||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: linear-gray+alpha */
|
|
||||||
{ 0, 74, 9, 0 }, { 0, 20, 9, 0 }, { 0, 74, 9, 0 }, { 0, 20, 9, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: linear-rgb */
|
|
||||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
|
||||||
{ 0, 0, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: linear-rgb+alpha */
|
|
||||||
{ 0, 126, 143, 0 }, { 0, 9, 7, 0 }, { 0, 74, 9, 0 }, { 0, 16, 9, 0 },
|
|
||||||
{ 0, 4, 4, 0 }, { 0, 5, 4, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-gray */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-gray+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-rgb */
|
|
||||||
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 8, 0 }, { 0, 0, 8, 0 },
|
|
||||||
{ 0, 0, 673, 0 }, { 0, 0, 673, 0 }, { 0, 0, 674, 0 }, { 0, 0, 674, 0 },
|
|
||||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 460, 0 }, { 0, 0, 460, 0 }, { 0, 0, 263, 0 }, { 0, 0, 263, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
|
||||||
{ 0, 6, 8, 0 }, { 0, 7, 8, 0 }, { 0, 75, 8, 0 }, { 0, 9, 8, 0 },
|
|
||||||
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 409, 0 }, { 0, 717, 409, 0 },
|
|
||||||
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 13323, 460, 0 }, { 0, 334, 460, 0 }, { 0, 16480, 263, 0 }, { 0, 243, 263, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-gray */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-gray+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 253, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-rgb */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 265, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-rgb+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 243, 265, 0 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =
|
|
||||||
{
|
|
||||||
{ /* input: sRGB-gray */
|
|
||||||
{ 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }
|
|
||||||
}, { /* input: sRGB-gray+alpha */
|
|
||||||
{ 0, 15, 15, 0 }, { 0, 186, 15, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
|
||||||
}, { /* input: sRGB-rgb */
|
|
||||||
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
|
|
||||||
}, { /* input: sRGB-rgb+alpha */
|
|
||||||
{ 0, 12, 14, 0 }, { 0, 180, 14, 0 }, { 0, 14, 15, 0 }, { 0, 186, 15, 0 }
|
|
||||||
}, { /* input: linear-gray */
|
|
||||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
|
||||||
}, { /* input: linear-gray+alpha */
|
|
||||||
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
|
||||||
}, { /* input: linear-rgb */
|
|
||||||
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
|
||||||
}, { /* input: linear-rgb+alpha */
|
|
||||||
{ 0, 1, 1, 0 }, { 0, 8, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-gray */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-gray+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-rgb */
|
|
||||||
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
|
|
||||||
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
|
||||||
{ 0, 4, 8, 0 }, { 0, 9, 8, 0 }, { 0, 8, 3, 0 }, { 0, 32, 3, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-gray */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-gray+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-rgb */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}, { /* input: color-mapped-linear-rgb+alpha */
|
|
||||||
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =
|
|
||||||
{
|
|
||||||
{ /* input: sRGB-gray */
|
|
||||||
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
|
||||||
{ 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }
|
|
||||||
}, { /* input: sRGB-gray+alpha */
|
|
||||||
{ 0, 19, 2, 0 }, { 0, 255, 2, 25 }, { 0, 88, 2, 0 }, { 0, 255, 2, 25 },
|
|
||||||
{ 0, 1012, 745, 0 }, { 0, 16026, 745, 6425 }, { 0, 1012, 745, 0 }, { 0, 16026, 745, 6425 }
|
|
||||||
}, { /* input: sRGB-rgb */
|
|
||||||
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
|
|
||||||
{ 0, 0, 937, 0 }, { 0, 0, 937, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
|
|
||||||
}, { /* input: sRGB-rgb+alpha */
|
|
||||||
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 220, 25, 0 }, { 0, 255, 25, 67 },
|
|
||||||
{ 0, 17534, 18491, 0 }, { 0, 15614, 2824, 6425 }, { 0, 14019, 13677, 0 }, { 0, 48573, 13677, 17219 }
|
|
||||||
}, { /* input: linear-gray */
|
|
||||||
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 },
|
|
||||||
{ 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }
|
|
||||||
}, { /* input: linear-gray+alpha */
|
|
||||||
{ 0, 74, 74, 0 }, { 0, 255, 74, 25 }, { 0, 97, 74, 0 }, { 0, 255, 74, 25 },
|
|
||||||
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6552 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6552 }
|
|
||||||
}, { /* input: linear-rgb */
|
|
||||||
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 98, 0 }, { 0, 0, 98, 0 },
|
|
||||||
{ 0, 0, 18664, 0 }, { 0, 0, 18664, 0 }, { 0, 0, 24998, 0 }, { 0, 0, 24998, 0 }
|
|
||||||
}, { /* input: linear-rgb+alpha */
|
|
||||||
{ 0, 181, 196, 0 }, { 0, 255, 61, 25 }, { 206, 187, 98, 0 }, { 0, 255, 98, 67 },
|
|
||||||
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 46509, 24992, 17347 }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/* END MACHINE GENERATED */
|
|
||||||
#endif /* COLORMAP flag check */
|
#endif /* COLORMAP flag check */
|
||||||
#endif /* flag checks */
|
#endif /* flag checks */
|
||||||
|
|
||||||
@@ -2153,8 +2037,8 @@ typedef struct
|
|||||||
/* Precalculated values: */
|
/* Precalculated values: */
|
||||||
int in_opaque; /* Value of input alpha that is opaque */
|
int in_opaque; /* Value of input alpha that is opaque */
|
||||||
int is_palette; /* Sample values come from the palette */
|
int is_palette; /* Sample values come from the palette */
|
||||||
int accumulate; /* Accumlate component errors (don't log) */
|
int accumulate; /* Accumulate component errors (don't log) */
|
||||||
int output_8bit; /* Output is 8 bit (else 16 bit) */
|
int output_8bit; /* Output is 8-bit (else 16-bit) */
|
||||||
|
|
||||||
void (*in_gp)(Pixel*, png_const_voidp);
|
void (*in_gp)(Pixel*, png_const_voidp);
|
||||||
void (*out_gp)(Pixel*, png_const_voidp);
|
void (*out_gp)(Pixel*, png_const_voidp);
|
||||||
@@ -2463,8 +2347,8 @@ static int
|
|||||||
logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y,
|
logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y,
|
||||||
const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason)
|
const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason)
|
||||||
{
|
{
|
||||||
const png_uint_32 in_format = transform->in_image->image.format;
|
png_uint_32 in_format = transform->in_image->image.format;
|
||||||
const png_uint_32 out_format = transform->out_image->image.format;
|
png_uint_32 out_format = transform->out_image->image.format;
|
||||||
|
|
||||||
png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
|
png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
|
||||||
const char *via_linear = "";
|
const char *via_linear = "";
|
||||||
@@ -2719,17 +2603,17 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
ptrdiff_t strideb = b->stride;
|
ptrdiff_t strideb = b->stride;
|
||||||
png_const_bytep rowa = a->buffer+16;
|
png_const_bytep rowa = a->buffer+16;
|
||||||
png_const_bytep rowb = b->buffer+16;
|
png_const_bytep rowb = b->buffer+16;
|
||||||
const png_uint_32 width = a->image.width;
|
png_uint_32 width = a->image.width;
|
||||||
const png_uint_32 height = a->image.height;
|
png_uint_32 height = a->image.height;
|
||||||
const png_uint_32 formata = a->image.format;
|
png_uint_32 formata = a->image.format;
|
||||||
const png_uint_32 formatb = b->image.format;
|
png_uint_32 formatb = b->image.format;
|
||||||
const unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||||
const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||||
int alpha_added, alpha_removed;
|
int alpha_added, alpha_removed;
|
||||||
int bchannels;
|
int bchannels;
|
||||||
int btoa[4];
|
|
||||||
png_uint_32 y;
|
png_uint_32 y;
|
||||||
Transform tr;
|
Transform tr;
|
||||||
|
int btoa[4]={0,0,0,0};
|
||||||
|
|
||||||
/* This should never happen: */
|
/* This should never happen: */
|
||||||
if (width != b->image.width || height != b->image.height)
|
if (width != b->image.width || height != b->image.height)
|
||||||
@@ -2818,7 +2702,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
{
|
{
|
||||||
if ((a->opts & ACCUMULATE) == 0)
|
if ((a->opts & ACCUMULATE) == 0)
|
||||||
{
|
{
|
||||||
char pindex[9];
|
char pindex[16];
|
||||||
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
||||||
(unsigned long)a->image.colormap_entries);
|
(unsigned long)a->image.colormap_entries);
|
||||||
logerror(a, a->file_name, ": bad pixel index: ", pindex);
|
logerror(a, a->file_name, ": bad pixel index: ", pindex);
|
||||||
@@ -2828,13 +2712,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
|
|
||||||
else if (y >= b->image.colormap_entries)
|
else if (y >= b->image.colormap_entries)
|
||||||
{
|
{
|
||||||
if ((a->opts & ACCUMULATE) == 0)
|
if ((b->opts & ACCUMULATE) == 0)
|
||||||
{
|
{
|
||||||
char pindex[9];
|
char pindex[16];
|
||||||
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
||||||
(unsigned long)b->image.colormap_entries);
|
(unsigned long)b->image.colormap_entries);
|
||||||
logerror(b, b->file_name, ": bad pixel index: ", pindex);
|
logerror(b, b->file_name, ": bad pixel index: ", pindex);
|
||||||
}
|
}
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2843,7 +2727,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If reqested copy the error values back from the Transform. */
|
/* If requested, copy the error values back from the Transform. */
|
||||||
if (a->opts & ACCUMULATE)
|
if (a->opts & ACCUMULATE)
|
||||||
{
|
{
|
||||||
tr.error_ptr[0] = tr.error[0];
|
tr.error_ptr[0] = tr.error[0];
|
||||||
@@ -2862,22 +2746,27 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
*/
|
*/
|
||||||
else if ((a->opts & ACCUMULATE) == 0)
|
else if ((a->opts & ACCUMULATE) == 0)
|
||||||
{
|
{
|
||||||
|
# ifdef __GNUC__
|
||||||
|
# define BYTE_CHARS 20 /* 2^32: GCC sprintf warning */
|
||||||
|
# else
|
||||||
|
# define BYTE_CHARS 3 /* 2^8: real maximum value */
|
||||||
|
# endif
|
||||||
/* Check the original image first,
|
/* Check the original image first,
|
||||||
* TODO: deal with input images with bad pixel values?
|
* TODO: deal with input images with bad pixel values?
|
||||||
*/
|
*/
|
||||||
if (amax >= a->image.colormap_entries)
|
if (amax >= a->image.colormap_entries)
|
||||||
{
|
{
|
||||||
char pindex[9];
|
char pindex[3+2*BYTE_CHARS];
|
||||||
sprintf(pindex, "%d[%lu]", amax,
|
sprintf(pindex, "%d[%u]", amax,
|
||||||
(unsigned long)a->image.colormap_entries);
|
(png_byte)/*SAFE*/a->image.colormap_entries);
|
||||||
return logerror(a, a->file_name, ": bad pixel index: ", pindex);
|
return logerror(a, a->file_name, ": bad pixel index: ", pindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (bmax >= b->image.colormap_entries)
|
else if (bmax >= b->image.colormap_entries)
|
||||||
{
|
{
|
||||||
char pindex[9];
|
char pindex[3+2*BYTE_CHARS];
|
||||||
sprintf(pindex, "%d[%lu]", bmax,
|
sprintf(pindex, "%d[%u]", bmax,
|
||||||
(unsigned long)b->image.colormap_entries);
|
(png_byte)/*SAFE*/b->image.colormap_entries);
|
||||||
return logerror(b, b->file_name, ": bad pixel index: ", pindex);
|
return logerror(b, b->file_name, ": bad pixel index: ", pindex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2902,8 +2791,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
(formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
|
(formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
|
||||||
{
|
{
|
||||||
/* Was an alpha channel changed? */
|
/* Was an alpha channel changed? */
|
||||||
const png_uint_32 alpha_changed = (formata ^ formatb) &
|
png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA;
|
||||||
PNG_FORMAT_FLAG_ALPHA;
|
|
||||||
|
|
||||||
/* Was an alpha channel removed? (The third test.) If so the direct
|
/* Was an alpha channel removed? (The third test.) If so the direct
|
||||||
* comparison is only possible if the input alpha is opaque.
|
* comparison is only possible if the input alpha is opaque.
|
||||||
@@ -2933,8 +2821,11 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
bchannels = component_loc(bloc, formatb);
|
bchannels = component_loc(bloc, formatb);
|
||||||
|
|
||||||
/* Hence the btoa array. */
|
/* Hence the btoa array. */
|
||||||
for (i=0; i<4; ++i) if (bloc[i] < 4)
|
for (i=0; i<4; ++i)
|
||||||
btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */
|
{
|
||||||
|
if (bloc[i] < 4)
|
||||||
|
btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */
|
||||||
|
}
|
||||||
|
|
||||||
if (alpha_added)
|
if (alpha_added)
|
||||||
alpha_added = bloc[0]; /* location of alpha channel in image b */
|
alpha_added = bloc[0]; /* location of alpha channel in image b */
|
||||||
@@ -2997,10 +2888,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
if (pua[btoa[3]] != pub[3]) break;
|
if (pua[btoa[3]] != pub[3]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 3:
|
case 3:
|
||||||
if (pua[btoa[2]] != pub[2]) break;
|
if (pua[btoa[2]] != pub[2]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 2:
|
case 2:
|
||||||
if (pua[btoa[1]] != pub[1]) break;
|
if (pua[btoa[1]] != pub[1]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 1:
|
case 1:
|
||||||
if (pua[btoa[0]] != pub[0]) break;
|
if (pua[btoa[0]] != pub[0]) break;
|
||||||
if (alpha_added != 4 && pub[alpha_added] != 65535) break;
|
if (alpha_added != 4 && pub[alpha_added] != 65535) break;
|
||||||
@@ -3016,10 +2910,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
{
|
{
|
||||||
case 4:
|
case 4:
|
||||||
if (psa[btoa[3]] != psb[3]) break;
|
if (psa[btoa[3]] != psb[3]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 3:
|
case 3:
|
||||||
if (psa[btoa[2]] != psb[2]) break;
|
if (psa[btoa[2]] != psb[2]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 2:
|
case 2:
|
||||||
if (psa[btoa[1]] != psb[1]) break;
|
if (psa[btoa[1]] != psb[1]) break;
|
||||||
|
/* FALLTHROUGH */
|
||||||
case 1:
|
case 1:
|
||||||
if (psa[btoa[0]] != psb[0]) break;
|
if (psa[btoa[0]] != psb[0]) break;
|
||||||
if (alpha_added != 4 && psb[alpha_added] != 255) break;
|
if (alpha_added != 4 && psb[alpha_added] != 255) break;
|
||||||
@@ -3038,7 +2935,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If reqested copy the error values back from the Transform. */
|
/* If requested, copy the error values back from the Transform. */
|
||||||
if (a->opts & ACCUMULATE)
|
if (a->opts & ACCUMULATE)
|
||||||
{
|
{
|
||||||
tr.error_ptr[0] = tr.error[0];
|
tr.error_ptr[0] = tr.error[0];
|
||||||
@@ -3157,14 +3054,14 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
|
|||||||
static int
|
static int
|
||||||
read_one_file(Image *image)
|
read_one_file(Image *image)
|
||||||
{
|
{
|
||||||
if (!(image->opts & READ_FILE) || (image->opts & USE_STDIO))
|
if (!(image->opts & USE_FILE) || (image->opts & USE_STDIO))
|
||||||
{
|
{
|
||||||
/* memory or stdio. */
|
/* memory or stdio. */
|
||||||
FILE *f = fopen(image->file_name, "rb");
|
FILE *f = fopen(image->file_name, "rb");
|
||||||
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
if (image->opts & READ_FILE)
|
if (image->opts & USE_FILE)
|
||||||
image->input_file = f;
|
image->input_file = f;
|
||||||
|
|
||||||
else /* memory */
|
else /* memory */
|
||||||
@@ -3173,32 +3070,45 @@ read_one_file(Image *image)
|
|||||||
{
|
{
|
||||||
long int cb = ftell(f);
|
long int cb = ftell(f);
|
||||||
|
|
||||||
if (cb > 0 && (unsigned long int)cb < (size_t)~(size_t)0)
|
if (cb > 0)
|
||||||
{
|
{
|
||||||
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
#ifndef __COVERITY__
|
||||||
|
if ((unsigned long int)cb <= (size_t)~(size_t)0)
|
||||||
if (b != NULL)
|
#endif
|
||||||
{
|
{
|
||||||
rewind(f);
|
png_bytep b = voidcast(png_bytep, malloc((size_t)cb));
|
||||||
|
|
||||||
if (fread(b, (size_t)cb, 1, f) == 1)
|
if (b != NULL)
|
||||||
{
|
{
|
||||||
fclose(f);
|
rewind(f);
|
||||||
image->input_memory_size = cb;
|
|
||||||
image->input_memory = b;
|
if (fread(b, (size_t)cb, 1, f) == 1)
|
||||||
|
{
|
||||||
|
fclose(f);
|
||||||
|
image->input_memory_size = cb;
|
||||||
|
image->input_memory = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(b);
|
||||||
|
return logclose(image, f, image->file_name,
|
||||||
|
": read failed: ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
free(b);
|
|
||||||
return logclose(image, f, image->file_name,
|
return logclose(image, f, image->file_name,
|
||||||
": read failed: ");
|
": out of memory: ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
return logclose(image, f, image->file_name,
|
return logclose(image, f, image->file_name,
|
||||||
": out of memory: ");
|
": file too big for this architecture: ");
|
||||||
|
/* cb is the length of the file as a (long) and
|
||||||
|
* this is greater than the maximum amount of
|
||||||
|
* memory that can be requested from malloc.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cb == 0)
|
else if (cb == 0)
|
||||||
@@ -3232,7 +3142,41 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
|||||||
|
|
||||||
if (image->opts & USE_STDIO)
|
if (image->opts & USE_STDIO)
|
||||||
{
|
{
|
||||||
|
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
|
#ifndef __COVERITY__
|
||||||
FILE *f = tmpfile();
|
FILE *f = tmpfile();
|
||||||
|
#else
|
||||||
|
/* Experimental. Coverity says tmpfile() is insecure because it
|
||||||
|
* generates predictable names.
|
||||||
|
*
|
||||||
|
* It is possible to satisfy Coverity by using mkstemp(); however,
|
||||||
|
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
|
||||||
|
* implementation as well, and doesn't need the fix. Note that
|
||||||
|
* the fix won't work on platforms that don't support mkstemp().
|
||||||
|
*
|
||||||
|
* https://www.securecoding.cert.org/confluence/display/c/
|
||||||
|
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
|
||||||
|
* says that most historic implementations of tmpfile() provide
|
||||||
|
* only a limited number of possible temporary file names
|
||||||
|
* (usually 26) before file names are recycled. That article also
|
||||||
|
* provides a secure solution that unfortunately depends upon mkstemp().
|
||||||
|
*/
|
||||||
|
char tmpfile[] = "pngstest-XXXXXX";
|
||||||
|
int filedes;
|
||||||
|
FILE *f;
|
||||||
|
umask(0177);
|
||||||
|
filedes = mkstemp(tmpfile);
|
||||||
|
if (filedes < 0)
|
||||||
|
f = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f = fdopen(filedes,"w+");
|
||||||
|
/* Hide the filename immediately and ensure that the file does
|
||||||
|
* not exist after the program ends
|
||||||
|
*/
|
||||||
|
(void) unlink(tmpfile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
@@ -3261,14 +3205,18 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
|||||||
|
|
||||||
else
|
else
|
||||||
return logerror(image, "tmpfile", ": open: ", strerror(errno));
|
return logerror(image, "tmpfile", ": open: ", strerror(errno));
|
||||||
|
#else /* SIMPLIFIED_WRITE_STDIO */
|
||||||
|
return logerror(image, "tmpfile", ": open: unsupported", "");
|
||||||
|
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else if (image->opts & USE_FILE)
|
||||||
{
|
{
|
||||||
static int counter = 0;
|
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||||
|
static unsigned int counter = 0;
|
||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
sprintf(name, "%s%d.png", tmpf, ++counter);
|
sprintf(name, "%s%u.png", tmpf, ++counter);
|
||||||
|
|
||||||
if (png_image_write_to_file(&image->image, name, convert_to_8bit,
|
if (png_image_write_to_file(&image->image, name, convert_to_8bit,
|
||||||
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
||||||
@@ -3284,6 +3232,51 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
|||||||
|
|
||||||
else
|
else
|
||||||
return logerror(image, name, ": write failed", "");
|
return logerror(image, name, ": write failed", "");
|
||||||
|
#else /* SIMPLIFIED_WRITE_STDIO */
|
||||||
|
return logerror(image, "stdio", ": open: unsupported", "");
|
||||||
|
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* use memory */
|
||||||
|
{
|
||||||
|
png_alloc_size_t size;
|
||||||
|
|
||||||
|
if (png_image_write_get_memory_size(image->image, size, convert_to_8bit,
|
||||||
|
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
||||||
|
{
|
||||||
|
/* This is non-fatal but ignoring it was causing serious problems in
|
||||||
|
* the macro to be ignored:
|
||||||
|
*/
|
||||||
|
if (size > PNG_IMAGE_PNG_SIZE_MAX(image->image))
|
||||||
|
return logerror(image, "memory", ": PNG_IMAGE_SIZE_MAX wrong", "");
|
||||||
|
|
||||||
|
initimage(output, image->opts, "memory", image->stride_extra);
|
||||||
|
output->input_memory = malloc(size);
|
||||||
|
|
||||||
|
if (output->input_memory != NULL)
|
||||||
|
{
|
||||||
|
output->input_memory_size = size;
|
||||||
|
|
||||||
|
if (png_image_write_to_memory(&image->image, output->input_memory,
|
||||||
|
&output->input_memory_size, convert_to_8bit, image->buffer+16,
|
||||||
|
(png_int_32)image->stride, image->colormap))
|
||||||
|
{
|
||||||
|
/* This is also non-fatal but it safes safer to error out anyway:
|
||||||
|
*/
|
||||||
|
if (size != output->input_memory_size)
|
||||||
|
return logerror(image, "memory", ": memory size wrong", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return logerror(image, "memory", ": write failed", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return logerror(image, "memory", ": out of memory", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return logerror(image, "memory", ": get size:", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 'output' has an initialized temporary image, read this back in and compare
|
/* 'output' has an initialized temporary image, read this back in and compare
|
||||||
@@ -3459,6 +3452,8 @@ test_one_file(const char *file_name, format_list *formats, png_uint_32 opts,
|
|||||||
int result;
|
int result;
|
||||||
Image image;
|
Image image;
|
||||||
|
|
||||||
|
if (!(opts & NO_RESEED))
|
||||||
|
reseed(); /* ensure that the random numbers don't depend on file order */
|
||||||
newimage(&image);
|
newimage(&image);
|
||||||
initimage(&image, opts, file_name, stride_extra);
|
initimage(&image, opts, file_name, stride_extra);
|
||||||
result = read_one_file(&image);
|
result = read_one_file(&image);
|
||||||
@@ -3496,7 +3491,7 @@ test_one_file(const char *file_name, format_list *formats, png_uint_32 opts,
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
png_uint_32 opts = FAST_WRITE;
|
png_uint_32 opts = FAST_WRITE | STRICT;
|
||||||
format_list formats;
|
format_list formats;
|
||||||
const char *touch = NULL;
|
const char *touch = NULL;
|
||||||
int log_pass = 0;
|
int log_pass = 0;
|
||||||
@@ -3505,11 +3500,17 @@ main(int argc, char **argv)
|
|||||||
int retval = 0;
|
int retval = 0;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
|
#if PNG_LIBPNG_VER >= 10700
|
||||||
|
/* This error should not exist in 1.7 or later: */
|
||||||
|
opts |= GBG_ERROR;
|
||||||
|
#endif
|
||||||
|
|
||||||
init_sRGB_to_d();
|
init_sRGB_to_d();
|
||||||
#if 0
|
#if 0
|
||||||
init_error_via_linear();
|
init_error_via_linear();
|
||||||
#endif
|
#endif
|
||||||
format_init(&formats);
|
format_init(&formats);
|
||||||
|
reseed(); /* initialize random number seeds */
|
||||||
|
|
||||||
for (c=1; c<argc; ++c)
|
for (c=1; c<argc; ++c)
|
||||||
{
|
{
|
||||||
@@ -3524,17 +3525,17 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (strcmp(arg, "--file") == 0)
|
else if (strcmp(arg, "--file") == 0)
|
||||||
# ifdef PNG_STDIO_SUPPORTED
|
# ifdef PNG_STDIO_SUPPORTED
|
||||||
opts |= READ_FILE;
|
opts |= USE_FILE;
|
||||||
# else
|
# else
|
||||||
return 77; /* skipped: no support */
|
return SKIP; /* skipped: no support */
|
||||||
# endif
|
# endif
|
||||||
else if (strcmp(arg, "--memory") == 0)
|
else if (strcmp(arg, "--memory") == 0)
|
||||||
opts &= ~READ_FILE;
|
opts &= ~USE_FILE;
|
||||||
else if (strcmp(arg, "--stdio") == 0)
|
else if (strcmp(arg, "--stdio") == 0)
|
||||||
# ifdef PNG_STDIO_SUPPORTED
|
# ifdef PNG_STDIO_SUPPORTED
|
||||||
opts |= USE_STDIO;
|
opts |= USE_STDIO;
|
||||||
# else
|
# else
|
||||||
return 77; /* skipped: no support */
|
return SKIP; /* skipped: no support */
|
||||||
# endif
|
# endif
|
||||||
else if (strcmp(arg, "--name") == 0)
|
else if (strcmp(arg, "--name") == 0)
|
||||||
opts &= ~USE_STDIO;
|
opts &= ~USE_STDIO;
|
||||||
@@ -3560,10 +3561,16 @@ main(int argc, char **argv)
|
|||||||
opts &= ~KEEP_GOING;
|
opts &= ~KEEP_GOING;
|
||||||
else if (strcmp(arg, "--strict") == 0)
|
else if (strcmp(arg, "--strict") == 0)
|
||||||
opts |= STRICT;
|
opts |= STRICT;
|
||||||
|
else if (strcmp(arg, "--nostrict") == 0)
|
||||||
|
opts &= ~STRICT;
|
||||||
else if (strcmp(arg, "--sRGB-16bit") == 0)
|
else if (strcmp(arg, "--sRGB-16bit") == 0)
|
||||||
opts |= sRGB_16BIT;
|
opts |= sRGB_16BIT;
|
||||||
else if (strcmp(arg, "--linear-16bit") == 0)
|
else if (strcmp(arg, "--linear-16bit") == 0)
|
||||||
opts &= ~sRGB_16BIT;
|
opts &= ~sRGB_16BIT;
|
||||||
|
else if (strcmp(arg, "--noreseed") == 0)
|
||||||
|
opts |= NO_RESEED;
|
||||||
|
else if (strcmp(arg, "--fault-gbg-warning") == 0)
|
||||||
|
opts |= GBG_ERROR;
|
||||||
else if (strcmp(arg, "--tmpfile") == 0)
|
else if (strcmp(arg, "--tmpfile") == 0)
|
||||||
{
|
{
|
||||||
if (c+1 < argc)
|
if (c+1 < argc)
|
||||||
@@ -3577,7 +3584,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Safe: checked above */
|
/* Safe: checked above */
|
||||||
strcpy(tmpf, argv[c]);
|
strncpy(tmpf, argv[c], sizeof (tmpf)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -3623,7 +3630,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (arg[0] == '-')
|
if (arg[0] == '-')
|
||||||
{
|
{
|
||||||
const int term = (arg[1] == '0' ? 0 : '\n');
|
int term = (arg[1] == '0' ? 0 : '\n');
|
||||||
unsigned int ich = 0;
|
unsigned int ich = 0;
|
||||||
|
|
||||||
/* Loop reading files, use a static buffer to simplify this and just
|
/* Loop reading files, use a static buffer to simplify this and just
|
||||||
@@ -3676,6 +3683,23 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
unsigned int in;
|
unsigned int in;
|
||||||
|
|
||||||
|
printf("/* contrib/libtests/pngstest-errors.h\n");
|
||||||
|
printf(" *\n");
|
||||||
|
printf(" * BUILT USING:" PNG_HEADER_VERSION_STRING);
|
||||||
|
printf(" *\n");
|
||||||
|
printf(" * This code is released under the libpng license.\n");
|
||||||
|
printf(" * For conditions of distribution and use, see the disclaimer\n");
|
||||||
|
printf(" * and license in png.h\n");
|
||||||
|
printf(" *\n");
|
||||||
|
printf(" * THIS IS A MACHINE GENERATED FILE: do not edit it directly!\n");
|
||||||
|
printf(" * Instead run:\n");
|
||||||
|
printf(" *\n");
|
||||||
|
printf(" * pngstest --accumulate\n");
|
||||||
|
printf(" *\n");
|
||||||
|
printf(" * on as many PNG files as possible; at least PNGSuite and\n");
|
||||||
|
printf(" * contrib/libtests/testpngs.\n");
|
||||||
|
printf(" */\n");
|
||||||
|
|
||||||
printf("static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =\n");
|
printf("static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =\n");
|
||||||
printf("{\n");
|
printf("{\n");
|
||||||
for (in=0; in<16; ++in)
|
for (in=0; in<16; ++in)
|
||||||
@@ -3765,6 +3789,7 @@ main(int argc, char **argv)
|
|||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
printf("};\n");
|
printf("};\n");
|
||||||
|
printf("/* END MACHINE GENERATED */\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == 0 && touch != NULL)
|
if (retval == 0 && touch != NULL)
|
||||||
@@ -3802,6 +3827,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "pngstest: no read support in libpng, test skipped\n");
|
fprintf(stderr, "pngstest: no read support in libpng, test skipped\n");
|
||||||
/* So the test is skipped: */
|
/* So the test is skipped: */
|
||||||
return 77;
|
return SKIP;
|
||||||
}
|
}
|
||||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/* pngunknown.c - test the read side unknown chunk handling
|
/* pngunknown.c - test the read side unknown chunk handling
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
* Copyright (c) 2021 Cosmin Truta
|
||||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
* Copyright (c) 2015,2017 Glenn Randers-Pehrson
|
||||||
* Written by John Cunningham Bowler
|
* Written by John Cunningham Bowler
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
@@ -30,10 +30,21 @@
|
|||||||
# include "../../png.h"
|
# include "../../png.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
|
||||||
|
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
|
||||||
|
*/
|
||||||
|
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
|
||||||
|
# define SKIP 77
|
||||||
|
#else
|
||||||
|
# define SKIP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Since this program tests the ability to change the unknown chunk handling
|
/* Since this program tests the ability to change the unknown chunk handling
|
||||||
* these must be defined:
|
* these must be defined:
|
||||||
*/
|
*/
|
||||||
#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||||
|
defined(PNG_STDIO_SUPPORTED) &&\
|
||||||
defined(PNG_READ_SUPPORTED)
|
defined(PNG_READ_SUPPORTED)
|
||||||
|
|
||||||
/* One of these must be defined to allow us to find out what happened. It is
|
/* One of these must be defined to allow us to find out what happened. It is
|
||||||
@@ -45,7 +56,7 @@
|
|||||||
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
|
||||||
#if PNG_LIBPNG_VER < 10500
|
#if PNG_LIBPNG_VER < 10500
|
||||||
/* This deliberately lacks the PNG_CONST. */
|
/* This deliberately lacks the const. */
|
||||||
typedef png_byte *png_const_bytep;
|
typedef png_byte *png_const_bytep;
|
||||||
|
|
||||||
/* This is copied from 1.5.1 png.h: */
|
/* This is copied from 1.5.1 png.h: */
|
||||||
@@ -74,7 +85,7 @@ typedef png_byte *png_const_bytep;
|
|||||||
#define PNG_WRITE_16BIT_SUPPORTED
|
#define PNG_WRITE_16BIT_SUPPORTED
|
||||||
#define PNG_READ_16BIT_SUPPORTED
|
#define PNG_READ_16BIT_SUPPORTED
|
||||||
|
|
||||||
/* This comes from pnglibconf.h afer 1.5: */
|
/* This comes from pnglibconf.h after 1.5: */
|
||||||
#define PNG_FP_1 100000
|
#define PNG_FP_1 100000
|
||||||
#define PNG_GAMMA_THRESHOLD_FIXED\
|
#define PNG_GAMMA_THRESHOLD_FIXED\
|
||||||
((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
|
((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
|
||||||
@@ -103,6 +114,7 @@ typedef png_byte *png_const_bytep;
|
|||||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||||
|
#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
|
||||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||||
@@ -199,6 +211,13 @@ static struct
|
|||||||
1,
|
1,
|
||||||
# endif
|
# endif
|
||||||
1, START, 0 },
|
1, START, 0 },
|
||||||
|
{ "eXIf", PNG_INFO_eXIf, png_eXIf,
|
||||||
|
# ifdef PNG_READ_eXIf_SUPPORTED
|
||||||
|
0,
|
||||||
|
# else
|
||||||
|
1,
|
||||||
|
# endif
|
||||||
|
1, END, 0 },
|
||||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
|
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
|
||||||
# ifdef PNG_READ_gAMA_SUPPORTED
|
# ifdef PNG_READ_gAMA_SUPPORTED
|
||||||
0,
|
0,
|
||||||
@@ -351,7 +370,9 @@ find_by_flag(png_uint_32 flag)
|
|||||||
{
|
{
|
||||||
int i = NINFO;
|
int i = NINFO;
|
||||||
|
|
||||||
while (--i >= 0) if (chunk_info[i].flag == flag) return i;
|
while (--i >= 0)
|
||||||
|
if (chunk_info[i].flag == flag)
|
||||||
|
return i;
|
||||||
|
|
||||||
fprintf(stderr, "pngunknown: internal error\n");
|
fprintf(stderr, "pngunknown: internal error\n");
|
||||||
exit(4);
|
exit(4);
|
||||||
@@ -363,7 +384,7 @@ ancillary(const char *name)
|
|||||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
static int
|
static int
|
||||||
ancillaryb(const png_byte *name)
|
ancillaryb(const png_byte *name)
|
||||||
{
|
{
|
||||||
@@ -467,7 +488,7 @@ get_valid(display *d, png_infop info_ptr)
|
|||||||
png_textp text;
|
png_textp text;
|
||||||
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
|
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
|
||||||
|
|
||||||
while (ntext-- > 0) switch (text[ntext].compression)
|
while (ntext > 0) switch (text[--ntext].compression)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
flags |= PNG_INFO_tEXt;
|
flags |= PNG_INFO_tEXt;
|
||||||
@@ -528,33 +549,36 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
|
|||||||
|
|
||||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||||
case PNG_HANDLE_CHUNK_NEVER:
|
case PNG_HANDLE_CHUNK_NEVER:
|
||||||
discard = 1/*handled; discard*/;
|
discard = 1; /*handled; discard*/
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||||
discard = 0/*not handled; keep*/;
|
discard = 0; /*not handled; keep*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Also store information about this chunk in the display, the relevant flag
|
/* Also store information about this chunk in the display, the relevant flag
|
||||||
* is set if the chunk is to be kept ('not handled'.)
|
* is set if the chunk is to be kept ('not handled'.)
|
||||||
*/
|
*/
|
||||||
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
|
if (chunk >= 0)
|
||||||
{
|
{
|
||||||
png_uint_32 flag = chunk_info[chunk].flag;
|
if (!discard) /* stupidity to stop a GCC warning */
|
||||||
|
{
|
||||||
|
png_uint_32 flag = chunk_info[chunk].flag;
|
||||||
|
|
||||||
if (pc->location & PNG_AFTER_IDAT)
|
if (pc->location & PNG_AFTER_IDAT)
|
||||||
d->after_IDAT |= flag;
|
d->after_IDAT |= flag;
|
||||||
|
|
||||||
else
|
else
|
||||||
d->before_IDAT |= flag;
|
d->before_IDAT |= flag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* However if there is no support to store unknown chunks don't ask libpng to
|
/* However if there is no support to store unknown chunks don't ask libpng to
|
||||||
* do it; there will be an png_error.
|
* do it; there will be an png_error.
|
||||||
*/
|
*/
|
||||||
# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
return discard;
|
return discard;
|
||||||
# else
|
# else
|
||||||
return 1; /*handled; discard*/
|
return 1; /*handled; discard*/
|
||||||
@@ -562,7 +586,7 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
|
|||||||
}
|
}
|
||||||
#endif /* READ_USER_CHUNKS_SUPPORTED */
|
#endif /* READ_USER_CHUNKS_SUPPORTED */
|
||||||
|
|
||||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
static png_uint_32
|
static png_uint_32
|
||||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||||
{
|
{
|
||||||
@@ -603,7 +627,7 @@ get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
|||||||
++(d->error_count);
|
++(d->error_count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALL THROUGH (safe) */
|
/* FALLTHROUGH */ /* (safe) */
|
||||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -615,7 +639,7 @@ get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
|||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
#else
|
#else /* SAVE_UNKNOWN_CHUNKS */
|
||||||
static png_uint_32
|
static png_uint_32
|
||||||
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
||||||
/* Otherwise this will return the cached values set by any user callback */
|
/* Otherwise this will return the cached values set by any user callback */
|
||||||
@@ -634,8 +658,8 @@ get_unknown(display *d, png_infop info_ptr, int after_IDAT)
|
|||||||
* a check to ensure the logic is correct.
|
* a check to ensure the logic is correct.
|
||||||
*/
|
*/
|
||||||
# error No store support and no user chunk support, this will not work
|
# error No store support and no user chunk support, this will not work
|
||||||
# endif
|
# endif /* READ_USER_CHUNKS */
|
||||||
#endif
|
#endif /* SAVE_UNKNOWN_CHUNKS */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||||
@@ -722,11 +746,17 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
|||||||
* in this case, so we just check the arguments! This could
|
* in this case, so we just check the arguments! This could
|
||||||
* be improved in the future by using the read callback.
|
* be improved in the future by using the read callback.
|
||||||
*/
|
*/
|
||||||
png_byte name[5];
|
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||||
|
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||||
|
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||||
|
{
|
||||||
|
png_byte name[5];
|
||||||
|
|
||||||
memcpy(name, chunk_info[chunk].name, 5);
|
memcpy(name, chunk_info[chunk].name, 5);
|
||||||
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
|
||||||
chunk_info[chunk].keep = option;
|
chunk_info[chunk].keep = option;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,7 +765,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
|||||||
case 7: /* default */
|
case 7: /* default */
|
||||||
if (memcmp(argv[i], "default", 7) == 0)
|
if (memcmp(argv[i], "default", 7) == 0)
|
||||||
{
|
{
|
||||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||||
|
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||||
|
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||||
|
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
|
||||||
|
|
||||||
d->keep = option;
|
d->keep = option;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -745,7 +780,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
|||||||
case 3: /* all */
|
case 3: /* all */
|
||||||
if (memcmp(argv[i], "all", 3) == 0)
|
if (memcmp(argv[i], "all", 3) == 0)
|
||||||
{
|
{
|
||||||
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
# if PNG_LIBPNG_VER >= 10700 &&\
|
||||||
|
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||||
|
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||||
|
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
|
||||||
|
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
|
||||||
|
|
||||||
d->keep = option;
|
d->keep = option;
|
||||||
|
|
||||||
for (chunk = 0; chunk < NINFO; ++chunk)
|
for (chunk = 0; chunk < NINFO; ++chunk)
|
||||||
@@ -806,8 +846,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
|||||||
{
|
{
|
||||||
png_uint_32 y;
|
png_uint_32 y;
|
||||||
|
|
||||||
for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
for (y=0; y<height; ++y)
|
||||||
png_read_row(d->png_ptr, NULL, NULL);
|
if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||||
|
png_read_row(d->png_ptr, NULL, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* interlaced */
|
} /* interlaced */
|
||||||
@@ -985,6 +1026,20 @@ perform_one_test(FILE *fp, int argc, const char **argv,
|
|||||||
|
|
||||||
def = check(fp, argc, argv, flags[1], d, set_callback);
|
def = check(fp, argc, argv, flags[1], d, set_callback);
|
||||||
|
|
||||||
|
/* If IDAT is being handled as unknown the image read is skipped and all the
|
||||||
|
* IDATs after the first end up in the end info struct, so in this case add
|
||||||
|
* IDAT to the list of unknowns. (Do this after 'check' above sets the
|
||||||
|
* chunk_info 'keep' fields.)
|
||||||
|
*
|
||||||
|
* Note that the flag setting has to be in the 'known' field to avoid
|
||||||
|
* triggering the consistency check below and the flag must only be set if
|
||||||
|
* there are multiple IDATs, so if the check above did find an unknown IDAT
|
||||||
|
* after IDAT.
|
||||||
|
*/
|
||||||
|
if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT &&
|
||||||
|
(flags[1][3] & PNG_INFO_IDAT) != 0)
|
||||||
|
flags[0][2] |= PNG_INFO_IDAT;
|
||||||
|
|
||||||
/* Chunks should either be known or unknown, never both and this should apply
|
/* Chunks should either be known or unknown, never both and this should apply
|
||||||
* whether the chunk is before or after the IDAT (actually, the app can
|
* whether the chunk is before or after the IDAT (actually, the app can
|
||||||
* probably change this by swapping the handling after the image, but this
|
* probably change this by swapping the handling after the image, but this
|
||||||
@@ -1042,15 +1097,15 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
|||||||
|
|
||||||
static const char *standard_tests[] =
|
static const char *standard_tests[] =
|
||||||
{
|
{
|
||||||
"discard", "default=discard", 0,
|
"discard", "default=discard", NULL,
|
||||||
"save", "default=save", 0,
|
"save", "default=save", NULL,
|
||||||
"if-safe", "default=if-safe", 0,
|
"if-safe", "default=if-safe", NULL,
|
||||||
"vpAg", "vpAg=if-safe", 0,
|
"vpAg", "vpAg=if-safe", NULL,
|
||||||
"sTER", "sTER=if-safe", 0,
|
"sTER", "sTER=if-safe", NULL,
|
||||||
"IDAT", "default=discard", "IDAT=save", 0,
|
"IDAT", "default=discard", "IDAT=save", NULL,
|
||||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||||
"sBIT=save", "sRGB=save", 0,
|
"sBIT=save", "sRGB=save", "eXIf=save", NULL,
|
||||||
0/*end*/
|
NULL /*end*/
|
||||||
};
|
};
|
||||||
|
|
||||||
static PNG_NORETURN void
|
static PNG_NORETURN void
|
||||||
@@ -1066,7 +1121,7 @@ int
|
|||||||
main(int argc, const char **argv)
|
main(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
png_uint_32 default_flags[4/*valid,unknown{before,after}*/];
|
png_uint_32 default_flags[4]; /*valid,unknown{before,after}*/
|
||||||
int strict = 0, default_tests = 0;
|
int strict = 0, default_tests = 0;
|
||||||
const char *count_argv = "default=save";
|
const char *count_argv = "default=save";
|
||||||
const char *touch_file = NULL;
|
const char *touch_file = NULL;
|
||||||
@@ -1104,8 +1159,9 @@ main(int argc, const char **argv)
|
|||||||
/* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc
|
/* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc
|
||||||
* optimization which causes warnings with -Wstrict-overflow!
|
* optimization which causes warnings with -Wstrict-overflow!
|
||||||
*/
|
*/
|
||||||
else if (default_tests) if (argc != 1)
|
else if (default_tests)
|
||||||
usage(d.program, "extra arguments");
|
if (argc != 1)
|
||||||
|
usage(d.program, "extra arguments");
|
||||||
|
|
||||||
/* The name of the test file is the last argument; remove it. */
|
/* The name of the test file is the last argument; remove it. */
|
||||||
d.file = argv[--argc];
|
d.file = argv[--argc];
|
||||||
@@ -1167,7 +1223,11 @@ main(int argc, const char **argv)
|
|||||||
const char *result;
|
const char *result;
|
||||||
int arg_count = 0;
|
int arg_count = 0;
|
||||||
|
|
||||||
while (*next) ++next, ++arg_count;
|
while (*next != NULL)
|
||||||
|
{
|
||||||
|
++next;
|
||||||
|
++arg_count;
|
||||||
|
}
|
||||||
|
|
||||||
perform_one_test_safe(fp, arg_count, test, default_flags, &d,
|
perform_one_test_safe(fp, arg_count, test, default_flags, &d,
|
||||||
this_test);
|
this_test);
|
||||||
@@ -1229,7 +1289,7 @@ main(void)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" test ignored: no support to find out about unknown chunks\n");
|
" test ignored: no support to find out about unknown chunks\n");
|
||||||
/* So the test is skipped: */
|
/* So the test is skipped: */
|
||||||
return 77;
|
return SKIP;
|
||||||
}
|
}
|
||||||
#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */
|
#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */
|
||||||
|
|
||||||
@@ -1240,6 +1300,6 @@ main(void)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" test ignored: no support to modify unknown chunk handling\n");
|
" test ignored: no support to modify unknown chunk handling\n");
|
||||||
/* So the test is skipped: */
|
/* So the test is skipped: */
|
||||||
return 77;
|
return SKIP;
|
||||||
}
|
}
|
||||||
#endif /* SET_UNKNOWN_CHUNKS && READ*/
|
#endif /* SET_UNKNOWN_CHUNKS && READ*/
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,8 @@
|
|||||||
|
|
||||||
/* readpng.c
|
/* readpng.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 John Cunningham Bowler
|
* Copyright (c) 2013 John Cunningham Bowler
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
|
||||||
*
|
|
||||||
* 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
|
||||||
@@ -60,8 +59,9 @@ read_png(FILE *fp)
|
|||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
{
|
{
|
||||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* Failure to initialize these is harmless */
|
||||||
row = malloc(rowbytes);
|
row = malloc(rowbytes);
|
||||||
display = malloc(rowbytes);
|
display = malloc(rowbytes);
|
||||||
|
|
||||||
@@ -70,7 +70,12 @@ read_png(FILE *fp)
|
|||||||
|
|
||||||
{
|
{
|
||||||
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||||
int passes = png_set_interlace_handling(png_ptr);
|
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
# else /* !READ_INTERLACING */
|
||||||
|
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
|
||||||
|
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
|
||||||
|
# endif /* !READ_INTERLACING */
|
||||||
int pass;
|
int pass;
|
||||||
|
|
||||||
png_start_read_image(png_ptr);
|
png_start_read_image(png_ptr);
|
||||||
@@ -79,6 +84,11 @@ read_png(FILE *fp)
|
|||||||
{
|
{
|
||||||
png_uint_32 y = height;
|
png_uint_32 y = height;
|
||||||
|
|
||||||
|
# ifndef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
if (passes == PNG_INTERLACE_ADAM7_PASSES)
|
||||||
|
y = PNG_PASS_ROWS(y, pass);
|
||||||
|
# endif /* READ_INTERLACING */
|
||||||
|
|
||||||
/* NOTE: this trashes the row each time; interlace handling won't
|
/* NOTE: this trashes the row each time; interlace handling won't
|
||||||
* work, but this avoids memory thrashing for speed testing.
|
* work, but this avoids memory thrashing for speed testing.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
/* tarith.c
|
/* tarith.c
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2021 Cosmin Truta
|
||||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
* 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.
|
* 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
|
||||||
@@ -88,6 +87,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
int minorarith = 0;
|
int minorarith = 0;
|
||||||
|
|
||||||
while (--argc > 0)
|
while (--argc > 0)
|
||||||
|
{
|
||||||
if (strcmp(*++argv, "-a") == 0)
|
if (strcmp(*++argv, "-a") == 0)
|
||||||
showall = 1;
|
showall = 1;
|
||||||
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||||
@@ -105,10 +105,11 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
fprintf(stderr, "unknown argument %s\n", *argv);
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
png_size_t index;
|
size_t index;
|
||||||
int state, failed = 0;
|
int state, failed = 0;
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
|
|
||||||
@@ -130,8 +131,8 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
if (buffer[precision+7] != 71)
|
if (buffer[precision+7] != 71)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n",
|
||||||
precision, buffer, (unsigned long)strlen(buffer));
|
test, precision, buffer, (unsigned long)strlen(buffer));
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,16 +147,16 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
if (test >= 0 && strcmp(buffer, "inf") ||
|
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||||
test < 0 && strcmp(buffer, "-inf"))
|
test < 0 && strcmp(buffer, "-inf"))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n",
|
||||||
precision, buffer);
|
test, precision, buffer);
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||||
buffer[index] != 0)
|
buffer[index] != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n",
|
||||||
precision, buffer, buffer[index]);
|
test, precision, buffer, buffer[index]);
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||||
@@ -176,7 +177,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%g[%d] -> '%s' but postive value not so reported\n",
|
fprintf(stderr, "%g[%d] -> '%s' but positive value not so reported\n",
|
||||||
test, precision, buffer);
|
test, precision, buffer);
|
||||||
failed = 1;
|
failed = 1;
|
||||||
assert(!PNG_FP_IS_NEGATIVE(state));
|
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||||
@@ -187,7 +188,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
|||||||
/* Check the result against the original. */
|
/* Check the result against the original. */
|
||||||
double out = atof(buffer);
|
double out = atof(buffer);
|
||||||
double change = fabs((out - test)/test);
|
double change = fabs((out - test)/test);
|
||||||
double allow = .5/pow(10,
|
double allow = .5 / pow(10,
|
||||||
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||||
|
|
||||||
/* NOTE: if you hit this error case are you compiling with gcc
|
/* NOTE: if you hit this error case are you compiling with gcc
|
||||||
@@ -257,8 +258,9 @@ skip:
|
|||||||
}
|
}
|
||||||
while (--count);
|
while (--count);
|
||||||
|
|
||||||
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) "
|
||||||
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
"%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_abs);
|
||||||
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||||
|
|
||||||
@@ -329,10 +331,10 @@ 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.
|
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||||
*/
|
*/
|
||||||
png_size_t index = 0;
|
size_t index = 0;
|
||||||
const char test = (char)ch;
|
const char test = (char)ch;
|
||||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||||
const int character_accepted = (index == 1);
|
int character_accepted = (index == 1);
|
||||||
|
|
||||||
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||||
c.is_zero = 0;
|
c.is_zero = 0;
|
||||||
@@ -371,8 +373,8 @@ static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
|||||||
/* This should never fail (it's a serious bug if it does): */
|
/* This should never fail (it's a serious bug if it does): */
|
||||||
if (index != 0 && index != 1)
|
if (index != 0 && index != 1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
fprintf(stderr, "%s: read beyond end of string (%lu)\n",
|
||||||
(unsigned long)index);
|
co->number, (unsigned long)index);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,8 +505,8 @@ static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
|||||||
if (number_is_valid != c.number_was_valid)
|
if (number_is_valid != c.number_was_valid)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
"%s: character '%c' [0x%.2x] changed number validity\n",
|
||||||
ch, ch);
|
co->number, ch, ch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,10 +523,13 @@ static int check_all_characters(checkfp_command *co, checkfp_control c)
|
|||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
if (c.cnumber+4 < sizeof co->number)
|
||||||
{
|
{
|
||||||
if (!check_one_character(co, c, ch))
|
for (ch=0; ch<256; ++ch)
|
||||||
return 0;
|
{
|
||||||
|
if (!check_one_character(co, c, ch))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -539,10 +544,13 @@ static int check_some_characters(checkfp_command *co, checkfp_control c,
|
|||||||
|
|
||||||
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
||||||
{
|
{
|
||||||
if (c.limit > 0) for (i=0; tests[i]; ++i)
|
if (c.limit > 0)
|
||||||
{
|
{
|
||||||
if (!check_one_character(co, c, tests[i]))
|
for (i=0; tests[i]; ++i)
|
||||||
return 0;
|
{
|
||||||
|
if (!check_one_character(co, c, tests[i]))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At the end check all the characters. */
|
/* At the end check all the characters. */
|
||||||
@@ -616,10 +624,10 @@ int validation_muldiv(int count, int argc, char **argv)
|
|||||||
png_int_32 times, div;
|
png_int_32 times, div;
|
||||||
|
|
||||||
while (--argc > 0)
|
while (--argc > 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "unknown argument %s\n", *++argv);
|
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find out about the random number generator. */
|
/* Find out about the random number generator. */
|
||||||
randbuffer = RAND_MAX;
|
randbuffer = RAND_MAX;
|
||||||
@@ -634,7 +642,7 @@ int validation_muldiv(int count, int argc, char **argv)
|
|||||||
{
|
{
|
||||||
png_fixed_point result;
|
png_fixed_point result;
|
||||||
/* NOTE: your mileage may vary, a type is required below that can
|
/* NOTE: your mileage may vary, a type is required below that can
|
||||||
* hold 64 bits or more, if floating point is used a 64 bit or
|
* hold 64 bits or more, if floating point is used a 64-bit or
|
||||||
* better mantissa is required.
|
* better mantissa is required.
|
||||||
*/
|
*/
|
||||||
long long int fp, fpround;
|
long long int fp, fpround;
|
||||||
@@ -687,25 +695,25 @@ int validation_muldiv(int count, int argc, char **argv)
|
|||||||
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n",
|
||||||
fp, ok ? "ok" : "overflow");
|
a, times, div, fp, ok ? "ok" : "overflow");
|
||||||
|
|
||||||
++tested;
|
++tested;
|
||||||
if (png_muldiv(&result, a, times, div) != ok)
|
if (png_muldiv(&result, a, times, div) != ok)
|
||||||
{
|
{
|
||||||
++error;
|
++error;
|
||||||
if (ok)
|
if (ok)
|
||||||
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n",
|
||||||
times, div, fp);
|
a, times, div, fp);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n",
|
||||||
times, div, result, fp);
|
a, times, div, result, fp);
|
||||||
}
|
}
|
||||||
else if (ok && result != fpround)
|
else if (ok && result != fpround)
|
||||||
{
|
{
|
||||||
++error;
|
++error;
|
||||||
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
fprintf(stderr, "%d * %d / %d -> %d not %lld\n",
|
||||||
fp);
|
a, times, div, result, fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++passed;
|
++passed;
|
||||||
@@ -721,8 +729,8 @@ int validation_muldiv(int count, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
while (--count > 0);
|
while (--count > 0);
|
||||||
|
|
||||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64 bit "
|
printf("%d tests including %d overflows, %d passed, %d failed "
|
||||||
"errors)\n", tested, overflow, passed, error, error64);
|
"(%d 64-bit errors)\n", tested, overflow, passed, error, error64);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -799,13 +807,13 @@ int validation_gamma(int argc, char **argv)
|
|||||||
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
||||||
i != 0 && png_log8bit(i) != floor(correct+.5))
|
i != 0 && png_log8bit(i) != floor(correct+.5))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "8 bit log error: %d: got %u, expected %f\n",
|
fprintf(stderr, "8-bit log error: %d: got %u, expected %f\n",
|
||||||
i, png_log8bit(i), correct);
|
i, png_log8bit(i), correct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("maximum 8 bit log error = %f\n", maxerr);
|
printf("maximum 8-bit log error = %f\n", maxerr);
|
||||||
|
|
||||||
maxerr = 0;
|
maxerr = 0;
|
||||||
for (i=0; i<65536; ++i)
|
for (i=0; i<65536; ++i)
|
||||||
@@ -821,14 +829,15 @@ int validation_gamma(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
if (error > .68) /* By experiment error is less than .68 */
|
if (error > .68) /* By experiment error is less than .68 */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "16 bit log error: %d: got %u, expected %f"
|
fprintf(stderr,
|
||||||
" error: %f\n", i, png_log16bit(i), correct, error);
|
"16-bit log error: %d: got %u, expected %f error: %f\n",
|
||||||
|
i, png_log16bit(i), correct, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("maximum 16 bit log error = %f\n", maxerr);
|
printf("maximum 16-bit log error = %f\n", maxerr);
|
||||||
|
|
||||||
/* Now exponentiations. */
|
/* Now exponentiations. */
|
||||||
maxerr = 0;
|
maxerr = 0;
|
||||||
@@ -841,13 +850,14 @@ int validation_gamma(int argc, char **argv)
|
|||||||
maxerr = fabs(error);
|
maxerr = fabs(error);
|
||||||
if (fabs(error) > 1883) /* By experiment. */
|
if (fabs(error) > 1883) /* By experiment. */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "32 bit exp error: %d: got %u, expected %f"
|
fprintf(stderr,
|
||||||
" error: %f\n", i, png_exp(i), correct, error);
|
"32-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||||
|
i, png_exp(i), correct, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("maximum 32 bit exp error = %f\n", maxerr);
|
printf("maximum 32-bit exp error = %f\n", maxerr);
|
||||||
|
|
||||||
maxerr = 0;
|
maxerr = 0;
|
||||||
for (i=0; i<=0xfffff; ++i)
|
for (i=0; i<=0xfffff; ++i)
|
||||||
@@ -859,13 +869,14 @@ int validation_gamma(int argc, char **argv)
|
|||||||
maxerr = fabs(error);
|
maxerr = fabs(error);
|
||||||
if (fabs(error) > .50002) /* By experiment */
|
if (fabs(error) > .50002) /* By experiment */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "8 bit exp error: %d: got %u, expected %f"
|
fprintf(stderr,
|
||||||
" error: %f\n", i, png_exp8bit(i), correct, error);
|
"8-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||||
|
i, png_exp8bit(i), correct, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("maximum 8 bit exp error = %f\n", maxerr);
|
printf("maximum 8-bit exp error = %f\n", maxerr);
|
||||||
|
|
||||||
maxerr = 0;
|
maxerr = 0;
|
||||||
for (i=0; i<=0xfffff; ++i)
|
for (i=0; i<=0xfffff; ++i)
|
||||||
@@ -877,13 +888,14 @@ int validation_gamma(int argc, char **argv)
|
|||||||
maxerr = fabs(error);
|
maxerr = fabs(error);
|
||||||
if (fabs(error) > .524) /* By experiment */
|
if (fabs(error) > .524) /* By experiment */
|
||||||
{
|
{
|
||||||
fprintf(stderr, "16 bit exp error: %d: got %u, expected %f"
|
fprintf(stderr,
|
||||||
" error: %f\n", i, png_exp16bit(i), correct, error);
|
"16-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||||
|
i, png_exp16bit(i), correct, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("maximum 16 bit exp error = %f\n", maxerr);
|
printf("maximum 16-bit exp error = %f\n", maxerr);
|
||||||
} /* !onlygamma */
|
} /* !onlygamma */
|
||||||
|
|
||||||
/* Test the overall gamma correction. */
|
/* Test the overall gamma correction. */
|
||||||
@@ -913,7 +925,7 @@ int validation_gamma(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("gamma %f: maximum 8 bit error %f\n", g, maxerr);
|
printf("gamma %f: maximum 8-bit error %f\n", g, maxerr);
|
||||||
|
|
||||||
maxerr = 0;
|
maxerr = 0;
|
||||||
for (j=0; j<65536; ++j)
|
for (j=0; j<65536; ++j)
|
||||||
@@ -932,7 +944,7 @@ int validation_gamma(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
|
printf("gamma %f: maximum 16-bit error %f\n", g, maxerr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -940,7 +952,7 @@ int validation_gamma(int argc, char **argv)
|
|||||||
|
|
||||||
/**************************** VALIDATION TESTS ********************************/
|
/**************************** VALIDATION TESTS ********************************/
|
||||||
/* Various validation routines are included herein, they require some
|
/* Various validation routines are included herein, they require some
|
||||||
* definition for png_warning and png_error, seetings of VALIDATION:
|
* definition for png_warning and png_error, settings of VALIDATION:
|
||||||
*
|
*
|
||||||
* 1: validates the ASCII to floating point conversions
|
* 1: validates the ASCII to floating point conversions
|
||||||
* 2: validates png_muldiv
|
* 2: validates png_muldiv
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
/* timepng.c
|
/* timepng.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2013 John Cunningham Bowler
|
* Copyright (c) 2013,2016 John Cunningham Bowler
|
||||||
*
|
|
||||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -10,15 +9,17 @@
|
|||||||
*
|
*
|
||||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
* 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
|
* 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
|
* reading each file by row or by image (possibly with transforms in the latter
|
||||||
* does no transforms. The only output is a time as a floating point number of
|
* case). The only output is a time as a floating point number of seconds with
|
||||||
* seconds with 9 decimal digits.
|
* 9 decimal digits.
|
||||||
*/
|
*/
|
||||||
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
@@ -35,36 +36,73 @@
|
|||||||
# include "../../png.h"
|
# include "../../png.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int read_png(FILE *fp)
|
/* The following is to support direct compilation of this file as C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define voidcast(type, value) static_cast<type>(value)
|
||||||
|
#else
|
||||||
|
# define voidcast(type, value) (value)
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* 'CLOCK_PROCESS_CPUTIME_ID' is one of the clock timers for clock_gettime. It
|
||||||
|
* need not be supported even when clock_gettime is available. It returns the
|
||||||
|
* 'CPU' time the process has consumed. 'CPU' time is assumed to include time
|
||||||
|
* when the CPU is actually blocked by a pending cache fill but not time
|
||||||
|
* waiting for page faults. The attempt is to get a measure of the actual time
|
||||||
|
* the implementation takes to read a PNG ignoring the potentially very large IO
|
||||||
|
* overhead.
|
||||||
|
*/
|
||||||
|
#if defined (CLOCK_PROCESS_CPUTIME_ID) && defined(PNG_STDIO_SUPPORTED) &&\
|
||||||
|
defined(PNG_EASY_ACCESS_SUPPORTED) &&\
|
||||||
|
(PNG_LIBPNG_VER >= 10700 ? defined(PNG_READ_PNG_SUPPORTED) :\
|
||||||
|
defined (PNG_SEQUENTIAL_READ_SUPPORTED) &&\
|
||||||
|
defined(PNG_INFO_IMAGE_SUPPORTED))
|
||||||
|
|
||||||
|
typedef struct
|
||||||
{
|
{
|
||||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
FILE *input;
|
||||||
png_infop info_ptr = NULL;
|
FILE *output;
|
||||||
png_bytep row = NULL, display = NULL;
|
} io_data;
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
static PNG_CALLBACK(void, read_and_copy,
|
||||||
return 0;
|
(png_structp png_ptr, png_bytep buffer, size_t cb))
|
||||||
|
{
|
||||||
|
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||||
|
|
||||||
if (setjmp(png_jmpbuf(png_ptr)))
|
if (fread(buffer, cb, 1, io->input) != 1)
|
||||||
|
png_error(png_ptr, strerror(errno));
|
||||||
|
|
||||||
|
if (fwrite(buffer, cb, 1, io->output) != 1)
|
||||||
{
|
{
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
perror("temporary file");
|
||||||
if (row != NULL) free(row);
|
fprintf(stderr, "temporary file PNG write failed\n");
|
||||||
if (display != NULL) free(display);
|
exit(1);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
png_init_io(png_ptr, fp);
|
static void read_by_row(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
FILE *write_ptr, FILE *read_ptr)
|
||||||
|
{
|
||||||
|
/* These don't get freed on error, this is fine; the program immediately
|
||||||
|
* exits.
|
||||||
|
*/
|
||||||
|
png_bytep row = NULL, display = NULL;
|
||||||
|
io_data io_copy;
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
if (write_ptr != NULL)
|
||||||
if (info_ptr == NULL)
|
{
|
||||||
png_error(png_ptr, "OOM allocating info structure");
|
/* Set up for a copy to the temporary file: */
|
||||||
|
io_copy.input = read_ptr;
|
||||||
|
io_copy.output = write_ptr;
|
||||||
|
png_set_read_fn(png_ptr, &io_copy, read_and_copy);
|
||||||
|
}
|
||||||
|
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
{
|
{
|
||||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
row = malloc(rowbytes);
|
row = voidcast(png_bytep,malloc(rowbytes));
|
||||||
display = malloc(rowbytes);
|
display = voidcast(png_bytep,malloc(rowbytes));
|
||||||
|
|
||||||
if (row == NULL || display == NULL)
|
if (row == NULL || display == NULL)
|
||||||
png_error(png_ptr, "OOM allocating row buffers");
|
png_error(png_ptr, "OOM allocating row buffers");
|
||||||
@@ -81,7 +119,8 @@ static int read_png(FILE *fp)
|
|||||||
png_uint_32 y = height;
|
png_uint_32 y = height;
|
||||||
|
|
||||||
/* NOTE: this trashes the row each time; interlace handling won't
|
/* NOTE: this trashes the row each time; interlace handling won't
|
||||||
* work, but this avoids memory thrashing for speed testing.
|
* work, but this avoids memory thrashing for speed testing and is
|
||||||
|
* somewhat representative of an application that works row-by-row.
|
||||||
*/
|
*/
|
||||||
while (y-- > 0)
|
while (y-- > 0)
|
||||||
png_read_row(png_ptr, row, display);
|
png_read_row(png_ptr, row, display);
|
||||||
@@ -91,9 +130,51 @@ static int read_png(FILE *fp)
|
|||||||
|
|
||||||
/* Make sure to read to the end of the file: */
|
/* Make sure to read to the end of the file: */
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
||||||
|
/* Free this up: */
|
||||||
free(row);
|
free(row);
|
||||||
free(display);
|
free(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PNG_CALLBACK(void, no_warnings, (png_structp png_ptr,
|
||||||
|
png_const_charp warning))
|
||||||
|
{
|
||||||
|
(void)png_ptr;
|
||||||
|
(void)warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_png(FILE *fp, png_int_32 transforms, FILE *write_file)
|
||||||
|
{
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,
|
||||||
|
no_warnings);
|
||||||
|
png_infop info_ptr = NULL;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||||
|
# endif
|
||||||
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
|
if (info_ptr == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating info structure");
|
||||||
|
|
||||||
|
if (transforms < 0)
|
||||||
|
read_by_row(png_ptr, info_ptr, write_file, fp);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_read_png(png_ptr, info_ptr, transforms, NULL/*params*/);
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +189,7 @@ static int mytime(struct timespec *t)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int perform_one_test(FILE *fp, int nfiles)
|
static int perform_one_test(FILE *fp, int nfiles, png_int_32 transforms)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct timespec before, after;
|
struct timespec before, after;
|
||||||
@@ -120,7 +201,7 @@ static int perform_one_test(FILE *fp, int nfiles)
|
|||||||
{
|
{
|
||||||
for (i=0; i<nfiles; ++i)
|
for (i=0; i<nfiles; ++i)
|
||||||
{
|
{
|
||||||
if (read_png(fp))
|
if (read_png(fp, transforms, NULL/*write*/))
|
||||||
{
|
{
|
||||||
if (ferror(fp))
|
if (ferror(fp))
|
||||||
{
|
{
|
||||||
@@ -184,120 +265,343 @@ static int add_one_file(FILE *fp, char *name)
|
|||||||
|
|
||||||
if (ip != NULL)
|
if (ip != NULL)
|
||||||
{
|
{
|
||||||
int ch;
|
/* Read the file using libpng; this detects errors and also deals with
|
||||||
for (;;)
|
* files which contain data beyond the end of the file.
|
||||||
|
*/
|
||||||
|
int ok = 0;
|
||||||
|
fpos_t pos;
|
||||||
|
|
||||||
|
if (fgetpos(fp, &pos))
|
||||||
{
|
{
|
||||||
ch = getc(ip);
|
/* Fatal error reading the start: */
|
||||||
if (ch == EOF) break;
|
perror("temporary file");
|
||||||
putc(ch, fp);
|
fprintf(stderr, "temporary file fgetpos error\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ferror(ip))
|
if (read_png(ip, -1/*by row*/, fp/*output*/))
|
||||||
{
|
{
|
||||||
perror(name);
|
if (ferror(ip))
|
||||||
fprintf(stderr, "%s: read error\n", name);
|
{
|
||||||
return 0;
|
perror(name);
|
||||||
|
fprintf(stderr, "%s: read error\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
ok = 1; /* read ok */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: file not added\n", name);
|
||||||
|
|
||||||
(void)fclose(ip);
|
(void)fclose(ip);
|
||||||
|
|
||||||
|
/* An error in the output is fatal; exit immediately: */
|
||||||
if (ferror(fp))
|
if (ferror(fp))
|
||||||
{
|
{
|
||||||
perror("temporary file");
|
perror("temporary file");
|
||||||
fprintf(stderr, "temporary file write error\n");
|
fprintf(stderr, "temporary file write error\n");
|
||||||
return 0;
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Did not read the file successfully, simply rewind the temporary
|
||||||
|
* file. This must happen after the ferror check above to avoid clearing
|
||||||
|
* the error.
|
||||||
|
*/
|
||||||
|
if (fsetpos(fp, &pos))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file fsetpos error\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* file open error: */
|
||||||
perror(name);
|
perror(name);
|
||||||
fprintf(stderr, "%s: open failed\n", name);
|
fprintf(stderr, "%s: open failed\n", name);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 0; /* file not added */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(FILE *fp)
|
||||||
|
{
|
||||||
|
if (fp != NULL) fclose(fp);
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage:\n"
|
||||||
|
" timepng --assemble <assembly> {files}\n"
|
||||||
|
" Read the files into <assembly>, output the count. Options are ignored.\n"
|
||||||
|
" timepng --dissemble <assembly> <count> [options]\n"
|
||||||
|
" Time <count> files from <assembly>, additional files may not be given.\n"
|
||||||
|
" Otherwise:\n"
|
||||||
|
" Read the files into a temporary file and time the decode\n"
|
||||||
|
"Transforms:\n"
|
||||||
|
" --by-image: read by image with png_read_png\n"
|
||||||
|
" --<transform>: implies by-image, use PNG_TRANSFORM_<transform>\n"
|
||||||
|
" Otherwise: read by row using png_read_row (to a single row buffer)\n"
|
||||||
|
/* ISO C90 string length max 509 */);fprintf(stderr,
|
||||||
|
"{files}:\n"
|
||||||
|
" PNG files to copy into the assembly and time. Invalid files are skipped\n"
|
||||||
|
" with appropriate error messages. If no files are given the list of files\n"
|
||||||
|
" is read from stdin with each file name terminated by a newline\n"
|
||||||
|
"Output:\n"
|
||||||
|
" For --assemble the output is the name of the assembly file followed by the\n"
|
||||||
|
" count of the files it contains; the arguments for --dissemble. Otherwise\n"
|
||||||
|
" the output is the total decode time in seconds.\n");
|
||||||
|
|
||||||
|
exit(99);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
FILE *fp = tmpfile();
|
int err = 0;
|
||||||
|
int nfiles = 0;
|
||||||
|
int transforms = -1; /* by row */
|
||||||
|
const char *assembly = NULL;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
if (fp != NULL)
|
if (argc > 2 && strcmp(argv[1], "--assemble") == 0)
|
||||||
{
|
{
|
||||||
int err = 0;
|
/* Just build the test file, argv[2] is the file name. */
|
||||||
int nfiles = 0;
|
assembly = argv[2];
|
||||||
|
fp = fopen(assembly, "wb");
|
||||||
if (argc > 1)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
int i;
|
perror(assembly);
|
||||||
|
fprintf(stderr, "timepng --assemble %s: could not open for write\n",
|
||||||
|
assembly);
|
||||||
|
usage(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=1; i<argc; ++i)
|
argv += 2;
|
||||||
|
argc -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (argc > 3 && strcmp(argv[1], "--dissemble") == 0)
|
||||||
|
{
|
||||||
|
fp = fopen(argv[2], "rb");
|
||||||
|
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror(argv[2]);
|
||||||
|
fprintf(stderr, "timepng --dissemble %s: could not open for read\n",
|
||||||
|
argv[2]);
|
||||||
|
usage(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
nfiles = atoi(argv[3]);
|
||||||
|
if (nfiles <= 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"timepng --dissemble <file> <count>: %s is not a count\n",
|
||||||
|
argv[3]);
|
||||||
|
exit(99);
|
||||||
|
}
|
||||||
|
#ifdef __COVERITY__
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nfiles &= PNG_UINT_31_MAX;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argv += 3;
|
||||||
|
argc -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* Else use a temporary file */
|
||||||
|
{
|
||||||
|
#ifndef __COVERITY__
|
||||||
|
fp = tmpfile();
|
||||||
|
#else
|
||||||
|
/* Experimental. Coverity says tmpfile() is insecure because it
|
||||||
|
* generates predictable names.
|
||||||
|
*
|
||||||
|
* It is possible to satisfy Coverity by using mkstemp(); however,
|
||||||
|
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
|
||||||
|
* implementation as well, and doesn't need the fix. Note that
|
||||||
|
* the fix won't work on platforms that don't support mkstemp().
|
||||||
|
*
|
||||||
|
* https://www.securecoding.cert.org/confluence/display/c/
|
||||||
|
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
|
||||||
|
* says that most historic implementations of tmpfile() provide
|
||||||
|
* only a limited number of possible temporary file names
|
||||||
|
* (usually 26) before file names are recycled. That article also
|
||||||
|
* provides a secure solution that unfortunately depends upon mkstemp().
|
||||||
|
*/
|
||||||
|
char tmpfile[] = "timepng-XXXXXX";
|
||||||
|
int filedes;
|
||||||
|
umask(0177);
|
||||||
|
filedes = mkstemp(tmpfile);
|
||||||
|
if (filedes < 0)
|
||||||
|
fp = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fp = fdopen(filedes,"w+");
|
||||||
|
/* Hide the filename immediately and ensure that the file does
|
||||||
|
* not exist after the program ends
|
||||||
|
*/
|
||||||
|
(void) unlink(tmpfile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror("tmpfile");
|
||||||
|
fprintf(stderr, "timepng: could not open the temporary file\n");
|
||||||
|
exit(1); /* not a user error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the transforms: */
|
||||||
|
while (argc > 1 && argv[1][0] == '-' && argv[1][1] == '-')
|
||||||
|
{
|
||||||
|
const char *opt = *++argv + 2;
|
||||||
|
|
||||||
|
--argc;
|
||||||
|
|
||||||
|
/* Transforms turn on the by-image processing and maybe set some
|
||||||
|
* transforms:
|
||||||
|
*/
|
||||||
|
if (transforms == -1)
|
||||||
|
transforms = PNG_TRANSFORM_IDENTITY;
|
||||||
|
|
||||||
|
if (strcmp(opt, "by-image") == 0)
|
||||||
|
{
|
||||||
|
/* handled above */
|
||||||
|
}
|
||||||
|
|
||||||
|
# define OPT(name) else if (strcmp(opt, #name) == 0)\
|
||||||
|
transforms |= PNG_TRANSFORM_ ## name
|
||||||
|
|
||||||
|
OPT(STRIP_16);
|
||||||
|
OPT(STRIP_ALPHA);
|
||||||
|
OPT(PACKING);
|
||||||
|
OPT(PACKSWAP);
|
||||||
|
OPT(EXPAND);
|
||||||
|
OPT(INVERT_MONO);
|
||||||
|
OPT(SHIFT);
|
||||||
|
OPT(BGR);
|
||||||
|
OPT(SWAP_ALPHA);
|
||||||
|
OPT(SWAP_ENDIAN);
|
||||||
|
OPT(INVERT_ALPHA);
|
||||||
|
OPT(STRIP_FILLER);
|
||||||
|
OPT(STRIP_FILLER_BEFORE);
|
||||||
|
OPT(STRIP_FILLER_AFTER);
|
||||||
|
OPT(GRAY_TO_RGB);
|
||||||
|
OPT(EXPAND_16);
|
||||||
|
OPT(SCALE_16);
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng %s: unrecognized transform\n", opt);
|
||||||
|
usage(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the files: */
|
||||||
|
if (argc > 1 && nfiles > 0)
|
||||||
|
usage(fp); /* Additional files not valid with --dissemble */
|
||||||
|
|
||||||
|
else if (argc > 1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
if (nfiles == INT_MAX)
|
||||||
{
|
{
|
||||||
if (add_one_file(fp, argv[i]))
|
fprintf(stderr, "%s: skipped, too many files\n", argv[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (add_one_file(fp, argv[i]))
|
||||||
|
++nfiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (nfiles == 0) /* Read from stdin without --dissemble */
|
||||||
|
{
|
||||||
|
char filename[FILENAME_MAX+1];
|
||||||
|
|
||||||
|
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||||
|
{
|
||||||
|
size_t len = strlen(filename);
|
||||||
|
|
||||||
|
if (filename[len-1] == '\n')
|
||||||
|
{
|
||||||
|
filename[len-1] = 0;
|
||||||
|
if (nfiles == INT_MAX)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: skipped, too many files\n", filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (add_one_file(fp, filename))
|
||||||
++nfiles;
|
++nfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: file name too long: ...%s\n",
|
||||||
|
filename+len-32);
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(stdin))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: stdin: read error\n");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the test, or produce the --assemble output: */
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
if (nfiles > 0)
|
||||||
|
{
|
||||||
|
if (assembly != NULL)
|
||||||
|
{
|
||||||
|
if (fflush(fp) && !ferror(fp) && fclose(fp))
|
||||||
|
{
|
||||||
|
perror(assembly);
|
||||||
|
fprintf(stderr, "%s: close failed\n", assembly);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = 1;
|
printf("%s %d\n", assembly, nfiles);
|
||||||
break;
|
fflush(stdout);
|
||||||
|
ok = !ferror(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = perform_one_test(fp, nfiles, transforms);
|
||||||
|
(void)fclose(fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
usage(fp);
|
||||||
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
|
else
|
||||||
fprintf(stderr, "timepng: could not open temporary file\n");
|
(void)fclose(fp);
|
||||||
|
|
||||||
/* Exit code 0 on success. */
|
/* Exit code 0 on success. */
|
||||||
return ok == 0;
|
return ok == 0;
|
||||||
}
|
}
|
||||||
|
#else /* !sufficient support */
|
||||||
|
int main(void) { return 77; }
|
||||||
|
#endif /* !sufficient support */
|
||||||
|
|||||||
142
contrib/mips-mmi/linux.c
Normal file
142
contrib/mips-mmi/linux.c
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
|
||||||
|
/* contrib/mips-mmi/linux.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2024 Cosmin Truta
|
||||||
|
* Written by guxiwei, 2023
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/auxv.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse_r var, r - Helper assembler macro for parsing register names.
|
||||||
|
*
|
||||||
|
* This converts the register name in $n form provided in \r to the
|
||||||
|
* corresponding register number, which is assigned to the variable \var. It is
|
||||||
|
* needed to allow explicit encoding of instructions in inline assembly where
|
||||||
|
* registers are chosen by the compiler in $n form, allowing us to avoid using
|
||||||
|
* fixed register numbers.
|
||||||
|
*
|
||||||
|
* It also allows newer instructions (not implemented by the assembler) to be
|
||||||
|
* transparently implemented using assembler macros, instead of needing separate
|
||||||
|
* cases depending on toolchain support.
|
||||||
|
*
|
||||||
|
* Simple usage example:
|
||||||
|
* __asm__ __volatile__("parse_r __rt, %0\n\t"
|
||||||
|
* ".insn\n\t"
|
||||||
|
* "# di %0\n\t"
|
||||||
|
* ".word (0x41606000 | (__rt << 16))"
|
||||||
|
* : "=r" (status);
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Match an individual register number and assign to \var */
|
||||||
|
#define _IFC_REG(n) \
|
||||||
|
".ifc \\r, $" #n "\n\t" \
|
||||||
|
"\\var = " #n "\n\t" \
|
||||||
|
".endif\n\t"
|
||||||
|
|
||||||
|
__asm__(".macro parse_r var r\n\t"
|
||||||
|
"\\var = -1\n\t"
|
||||||
|
_IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3)
|
||||||
|
_IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7)
|
||||||
|
_IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11)
|
||||||
|
_IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
|
||||||
|
_IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
|
||||||
|
_IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
|
||||||
|
_IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
|
||||||
|
_IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
|
||||||
|
".iflt \\var\n\t"
|
||||||
|
".error \"Unable to parse register name \\r\"\n\t"
|
||||||
|
".endif\n\t"
|
||||||
|
".endm");
|
||||||
|
|
||||||
|
#define HWCAP_LOONGSON_CPUCFG (1 << 14)
|
||||||
|
|
||||||
|
static int cpucfg_available(void)
|
||||||
|
{
|
||||||
|
return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int strstart(const char *str, const char *pfx, const char **ptr)
|
||||||
|
{
|
||||||
|
while (*pfx && *pfx == *str) {
|
||||||
|
pfx++;
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
if (!*pfx && ptr)
|
||||||
|
*ptr = str;
|
||||||
|
return !*pfx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Most toolchains have no CPUCFG support yet */
|
||||||
|
static uint32_t read_cpucfg(uint32_t reg)
|
||||||
|
{
|
||||||
|
uint32_t __res;
|
||||||
|
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"parse_r __res,%0\n\t"
|
||||||
|
"parse_r reg,%1\n\t"
|
||||||
|
".insn \n\t"
|
||||||
|
".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t"
|
||||||
|
:"=r"(__res)
|
||||||
|
:"r"(reg)
|
||||||
|
:
|
||||||
|
);
|
||||||
|
return __res;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LOONGSON_CFG1 0x1
|
||||||
|
|
||||||
|
#define LOONGSON_CFG1_MMI (1 << 4)
|
||||||
|
|
||||||
|
static int cpu_flags_cpucfg(void)
|
||||||
|
{
|
||||||
|
int flags = 0;
|
||||||
|
uint32_t cfg1 = read_cpucfg(LOONGSON_CFG1);
|
||||||
|
|
||||||
|
if (cfg1 & LOONGSON_CFG1_MMI)
|
||||||
|
flags = 1;
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpu_flags_cpuinfo(void)
|
||||||
|
{
|
||||||
|
FILE *f = fopen("/proc/cpuinfo", "r");
|
||||||
|
char buf[200];
|
||||||
|
int flags = 0;
|
||||||
|
|
||||||
|
if (!f)
|
||||||
|
return flags;
|
||||||
|
|
||||||
|
while (fgets(buf, sizeof(buf), f)) {
|
||||||
|
/* Legacy kernel may not export MMI in ASEs implemented */
|
||||||
|
if (strstart(buf, "cpu model", NULL)) {
|
||||||
|
if (strstr(buf, "Loongson-3 "))
|
||||||
|
flags = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strstart(buf, "ASEs implemented", NULL)) {
|
||||||
|
if (strstr(buf, " loongson-mmi"))
|
||||||
|
flags = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int png_have_mmi()
|
||||||
|
{
|
||||||
|
if (cpucfg_available())
|
||||||
|
return cpu_flags_cpucfg();
|
||||||
|
else
|
||||||
|
return cpu_flags_cpuinfo();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
83
contrib/mips-msa/README
Normal file
83
contrib/mips-msa/README
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
OPERATING SYSTEM SPECIFIC MIPS MSA DETECTION
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
Detection of the ability to execute MIPS MSA on an MIPS 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 mips/mips_init.c
|
||||||
|
by setting the macro PNG_MIPS_MSA_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 mips/msa_init.o with the required macro definition.
|
||||||
|
|
||||||
|
For any of this code to be used the MIPS MSA code must be enabled and run time
|
||||||
|
checks must be supported. I.e.:
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
This is done in a 'configure' build by passing configure the argument:
|
||||||
|
|
||||||
|
--enable-mips-msa=check
|
||||||
|
|
||||||
|
Apart from the basic Linux implementation in contrib/mips-msa/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_msa(png_structp png_ptr);
|
||||||
|
|
||||||
|
That function must return 1 if MIPS MSA 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.
|
||||||
55
contrib/mips-msa/linux.c
Normal file
55
contrib/mips-msa/linux.c
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
/* contrib/mips-msa/linux.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020-2023 Cosmin Truta
|
||||||
|
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||||
|
* Written by Mandar Sahastrabuddhe, 2016.
|
||||||
|
* Updated by Sui Jingfeng, 2021.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* On Linux, png_have_msa is implemented by reading the pseudo-file
|
||||||
|
* "/proc/self/auxv".
|
||||||
|
*
|
||||||
|
* See contrib/mips-msa/README before reporting bugs.
|
||||||
|
*
|
||||||
|
* STATUS: SUPPORTED
|
||||||
|
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <elf.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_have_msa(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
Elf64_auxv_t aux;
|
||||||
|
int fd;
|
||||||
|
int has_msa = 0;
|
||||||
|
|
||||||
|
fd = open("/proc/self/auxv", O_RDONLY);
|
||||||
|
if (fd >= 0)
|
||||||
|
{
|
||||||
|
while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
|
||||||
|
{
|
||||||
|
if (aux.a_type == AT_HWCAP)
|
||||||
|
{
|
||||||
|
uint64_t hwcap = aux.a_un.a_val;
|
||||||
|
|
||||||
|
has_msa = (hwcap >> 1) & 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
else
|
||||||
|
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return has_msa;
|
||||||
|
}
|
||||||
25
contrib/oss-fuzz/Dockerfile
Normal file
25
contrib/oss-fuzz/Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright 2016 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
|
MAINTAINER glennrp@gmail.com
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y make autoconf automake libtool
|
||||||
|
|
||||||
|
RUN git clone --depth 1 https://github.com/madler/zlib.git
|
||||||
|
RUN git clone --depth 1 https://github.com/glennrp/libpng.git
|
||||||
|
RUN cp libpng/contrib/oss-fuzz/build.sh $SRC
|
||||||
|
WORKDIR libpng
|
||||||
36
contrib/oss-fuzz/README.txt
Normal file
36
contrib/oss-fuzz/README.txt
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
Copyright (c) 2017 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
This code is released under the libpng license.
|
||||||
|
For conditions of distribution and use, see the disclaimer
|
||||||
|
and license in png.h
|
||||||
|
|
||||||
|
Files in this directory are used by the oss-fuzz project
|
||||||
|
(https://github.com/google/oss-fuzz/tree/master/projects/libpng).
|
||||||
|
for "fuzzing" libpng.
|
||||||
|
|
||||||
|
They were licensed by Google Inc, using the BSD-like Chromium license,
|
||||||
|
which may be found at https://cs.chromium.org/chromium/src/LICENSE, or, if
|
||||||
|
noted in the source, under the Apache-2.0 license, which may
|
||||||
|
be found at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||||
|
If they have been modified, the derivatives are copyright Glenn Randers-Pehrson
|
||||||
|
and are released under the same licenses as the originals. Several of
|
||||||
|
the original files (libpng_read_fuzzer.options, png.dict, project.yaml)
|
||||||
|
had no licensing information; we assumed that these were under the Chromium
|
||||||
|
license. Any new files are released under the libpng license (see png.h).
|
||||||
|
|
||||||
|
The files are
|
||||||
|
Original
|
||||||
|
Filename or derived Copyright License
|
||||||
|
========================= ========== ================ ==========
|
||||||
|
Dockerfile* derived 2017, Glenn R-P Apache 2.0
|
||||||
|
build.sh derived 2017, Glenn R-P Apache 2.0
|
||||||
|
libpng_read_fuzzer.cc derived 2017, Glenn R-P Chromium
|
||||||
|
libpng_read_fuzzer.options original 2015, Chrome Devs Chromium
|
||||||
|
png.dict original 2015, Chrome Devs Chromium
|
||||||
|
README.txt (this file) original 2017, Glenn R-P libpng
|
||||||
|
|
||||||
|
* Dockerfile is a copy of the file used by oss-fuzz. build.sh,
|
||||||
|
png.dict and libpng_read_fuzzer.* are the actual files used by oss-fuzz,
|
||||||
|
which retrieves them from the libpng repository at Github.
|
||||||
|
|
||||||
|
To do: exercise the progressive reader and the png encoder.
|
||||||
50
contrib/oss-fuzz/build.sh
Executable file
50
contrib/oss-fuzz/build.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash -eu
|
||||||
|
|
||||||
|
# Copyright 2017-2018 Glenn Randers-Pehrson
|
||||||
|
# Copyright 2016 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# Revisions by Glenn Randers-Pehrson, 2017:
|
||||||
|
# 1. Build only the library, not the tools (changed "make -j$(nproc) all" to
|
||||||
|
# "make -j$(nproc) libpng16.la").
|
||||||
|
# 2. Disabled WARNING and WRITE options in pnglibconf.dfa.
|
||||||
|
# 3. Build zlib alongside libpng
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Disable logging via library build configuration control.
|
||||||
|
cat scripts/pnglibconf.dfa | \
|
||||||
|
sed -e "s/option STDIO/option STDIO disabled/" \
|
||||||
|
-e "s/option WARNING /option WARNING disabled/" \
|
||||||
|
-e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \
|
||||||
|
> scripts/pnglibconf.dfa.temp
|
||||||
|
mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
|
||||||
|
|
||||||
|
# build the libpng library.
|
||||||
|
autoreconf -f -i
|
||||||
|
./configure --with-libpng-prefix=OSS_FUZZ_
|
||||||
|
make -j$(nproc) clean
|
||||||
|
make -j$(nproc) libpng16.la
|
||||||
|
|
||||||
|
# build libpng_read_fuzzer.
|
||||||
|
$CXX $CXXFLAGS -std=c++11 -I. \
|
||||||
|
$SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \
|
||||||
|
-o $OUT/libpng_read_fuzzer \
|
||||||
|
-lFuzzingEngine .libs/libpng16.a -lz
|
||||||
|
|
||||||
|
# add seed corpus.
|
||||||
|
find $SRC/libpng -name "*.png" | grep -v crashers | \
|
||||||
|
xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip
|
||||||
|
|
||||||
|
cp $SRC/libpng/contrib/oss-fuzz/*.dict \
|
||||||
|
$SRC/libpng/contrib/oss-fuzz/*.options $OUT/
|
||||||
208
contrib/oss-fuzz/libpng_read_fuzzer.cc
Normal file
208
contrib/oss-fuzz/libpng_read_fuzzer.cc
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
|
||||||
|
// libpng_read_fuzzer.cc
|
||||||
|
// Copyright 2017-2018 Glenn Randers-Pehrson
|
||||||
|
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that may
|
||||||
|
// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE
|
||||||
|
|
||||||
|
// The modifications in 2017 by Glenn Randers-Pehrson include
|
||||||
|
// 1. addition of a PNG_CLEANUP macro,
|
||||||
|
// 2. setting the option to ignore ADLER32 checksums,
|
||||||
|
// 3. adding "#include <string.h>" which is needed on some platforms
|
||||||
|
// to provide memcpy().
|
||||||
|
// 4. adding read_end_info() and creating an end_info structure.
|
||||||
|
// 5. adding calls to png_set_*() transforms commonly used by browsers.
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define PNG_INTERNAL
|
||||||
|
#include "png.h"
|
||||||
|
|
||||||
|
#define PNG_CLEANUP \
|
||||||
|
if(png_handler.png_ptr) \
|
||||||
|
{ \
|
||||||
|
if (png_handler.row_ptr) \
|
||||||
|
png_free(png_handler.png_ptr, png_handler.row_ptr); \
|
||||||
|
if (png_handler.end_info_ptr) \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\
|
||||||
|
&png_handler.end_info_ptr); \
|
||||||
|
else if (png_handler.info_ptr) \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\
|
||||||
|
nullptr); \
|
||||||
|
else \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); \
|
||||||
|
png_handler.png_ptr = nullptr; \
|
||||||
|
png_handler.row_ptr = nullptr; \
|
||||||
|
png_handler.info_ptr = nullptr; \
|
||||||
|
png_handler.end_info_ptr = nullptr; \
|
||||||
|
}
|
||||||
|
|
||||||
|
struct BufState {
|
||||||
|
const uint8_t* data;
|
||||||
|
size_t bytes_left;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PngObjectHandler {
|
||||||
|
png_infop info_ptr = nullptr;
|
||||||
|
png_structp png_ptr = nullptr;
|
||||||
|
png_infop end_info_ptr = nullptr;
|
||||||
|
png_voidp row_ptr = nullptr;
|
||||||
|
BufState* buf_state = nullptr;
|
||||||
|
|
||||||
|
~PngObjectHandler() {
|
||||||
|
if (row_ptr)
|
||||||
|
png_free(png_ptr, row_ptr);
|
||||||
|
if (end_info_ptr)
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr);
|
||||||
|
else if (info_ptr)
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||||
|
else
|
||||||
|
png_destroy_read_struct(&png_ptr, nullptr, nullptr);
|
||||||
|
delete buf_state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void user_read_data(png_structp png_ptr, png_bytep data, size_t length) {
|
||||||
|
BufState* buf_state = static_cast<BufState*>(png_get_io_ptr(png_ptr));
|
||||||
|
if (length > buf_state->bytes_left) {
|
||||||
|
png_error(png_ptr, "read error");
|
||||||
|
}
|
||||||
|
memcpy(data, buf_state->data, length);
|
||||||
|
buf_state->bytes_left -= length;
|
||||||
|
buf_state->data += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* limited_malloc(png_structp, png_alloc_size_t size) {
|
||||||
|
// libpng may allocate large amounts of memory that the fuzzer reports as
|
||||||
|
// an error. In order to silence these errors, make libpng fail when trying
|
||||||
|
// to allocate a large amount. This allocator used to be in the Chromium
|
||||||
|
// version of this fuzzer.
|
||||||
|
// This number is chosen to match the default png_user_chunk_malloc_max.
|
||||||
|
if (size > 8000000)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void default_free(png_structp, png_voidp ptr) {
|
||||||
|
return free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int kPngHeaderSize = 8;
|
||||||
|
|
||||||
|
// Entry point for LibFuzzer.
|
||||||
|
// Roughly follows the libpng book example:
|
||||||
|
// http://www.libpng.org/pub/png/book/chapter13.html
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
|
if (size < kPngHeaderSize) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned char> v(data, data + size);
|
||||||
|
if (png_sig_cmp(v.data(), 0, kPngHeaderSize)) {
|
||||||
|
// not a PNG.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PngObjectHandler png_handler;
|
||||||
|
png_handler.png_ptr = nullptr;
|
||||||
|
png_handler.row_ptr = nullptr;
|
||||||
|
png_handler.info_ptr = nullptr;
|
||||||
|
png_handler.end_info_ptr = nullptr;
|
||||||
|
|
||||||
|
png_handler.png_ptr = png_create_read_struct
|
||||||
|
(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
|
||||||
|
if (!png_handler.png_ptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_handler.info_ptr = png_create_info_struct(png_handler.png_ptr);
|
||||||
|
if (!png_handler.info_ptr) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_handler.end_info_ptr = png_create_info_struct(png_handler.png_ptr);
|
||||||
|
if (!png_handler.end_info_ptr) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use a custom allocator that fails for large allocations to avoid OOM.
|
||||||
|
png_set_mem_fn(png_handler.png_ptr, nullptr, limited_malloc, default_free);
|
||||||
|
|
||||||
|
png_set_crc_action(png_handler.png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
|
||||||
|
#ifdef PNG_IGNORE_ADLER32
|
||||||
|
png_set_option(png_handler.png_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Setting up reading from buffer.
|
||||||
|
png_handler.buf_state = new BufState();
|
||||||
|
png_handler.buf_state->data = data + kPngHeaderSize;
|
||||||
|
png_handler.buf_state->bytes_left = size - kPngHeaderSize;
|
||||||
|
png_set_read_fn(png_handler.png_ptr, png_handler.buf_state, user_read_data);
|
||||||
|
png_set_sig_bytes(png_handler.png_ptr, kPngHeaderSize);
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_handler.png_ptr))) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reading.
|
||||||
|
png_read_info(png_handler.png_ptr, png_handler.info_ptr);
|
||||||
|
|
||||||
|
// reset error handler to put png_deleter into scope.
|
||||||
|
if (setjmp(png_jmpbuf(png_handler.png_ptr))) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32 width, height;
|
||||||
|
int bit_depth, color_type, interlace_type, compression_type;
|
||||||
|
int filter_type;
|
||||||
|
|
||||||
|
if (!png_get_IHDR(png_handler.png_ptr, png_handler.info_ptr, &width,
|
||||||
|
&height, &bit_depth, &color_type, &interlace_type,
|
||||||
|
&compression_type, &filter_type)) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is going to be too slow.
|
||||||
|
if (width && height > 100000000 / width) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set several transforms that browsers typically use:
|
||||||
|
png_set_gray_to_rgb(png_handler.png_ptr);
|
||||||
|
png_set_expand(png_handler.png_ptr);
|
||||||
|
png_set_packing(png_handler.png_ptr);
|
||||||
|
png_set_scale_16(png_handler.png_ptr);
|
||||||
|
png_set_tRNS_to_alpha(png_handler.png_ptr);
|
||||||
|
|
||||||
|
int passes = png_set_interlace_handling(png_handler.png_ptr);
|
||||||
|
|
||||||
|
png_read_update_info(png_handler.png_ptr, png_handler.info_ptr);
|
||||||
|
|
||||||
|
png_handler.row_ptr = png_malloc(
|
||||||
|
png_handler.png_ptr, png_get_rowbytes(png_handler.png_ptr,
|
||||||
|
png_handler.info_ptr));
|
||||||
|
|
||||||
|
for (int pass = 0; pass < passes; ++pass) {
|
||||||
|
for (png_uint_32 y = 0; y < height; ++y) {
|
||||||
|
png_read_row(png_handler.png_ptr,
|
||||||
|
static_cast<png_bytep>(png_handler.row_ptr), nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
|
||||||
|
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
2
contrib/oss-fuzz/libpng_read_fuzzer.options
Normal file
2
contrib/oss-fuzz/libpng_read_fuzzer.options
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[libfuzzer]
|
||||||
|
dict = png.dict
|
||||||
39
contrib/oss-fuzz/png.dict
Normal file
39
contrib/oss-fuzz/png.dict
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#
|
||||||
|
# AFL dictionary for PNG images
|
||||||
|
# -----------------------------
|
||||||
|
#
|
||||||
|
# Just the basic, standard-originating sections; does not include vendor
|
||||||
|
# extensions.
|
||||||
|
#
|
||||||
|
# Created by Michal Zalewski <lcamtuf@google.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
header_png="\x89PNG\x0d\x0a\x1a\x0a"
|
||||||
|
|
||||||
|
section_IDAT="IDAT"
|
||||||
|
section_IEND="IEND"
|
||||||
|
section_IHDR="IHDR"
|
||||||
|
section_PLTE="PLTE"
|
||||||
|
section_bKGD="bKGD"
|
||||||
|
section_cHRM="cHRM"
|
||||||
|
section_eXIf="eXIf"
|
||||||
|
section_fRAc="fRAc"
|
||||||
|
section_gAMA="gAMA"
|
||||||
|
section_gIFg="gIFg"
|
||||||
|
section_gIFt="gIFt"
|
||||||
|
section_gIFx="gIFx"
|
||||||
|
section_hIST="hIST"
|
||||||
|
section_iCCP="iCCP"
|
||||||
|
section_iTXt="iTXt"
|
||||||
|
section_oFFs="oFFs"
|
||||||
|
section_pCAL="pCAL"
|
||||||
|
section_pHYs="pHYs"
|
||||||
|
section_sBIT="sBIT"
|
||||||
|
section_sCAL="sCAL"
|
||||||
|
section_sPLT="sPLT"
|
||||||
|
section_sRGB="sRGB"
|
||||||
|
section_sTER="sTER"
|
||||||
|
section_tEXt="tEXt"
|
||||||
|
section_tIME="tIME"
|
||||||
|
section_tRNS="tRNS"
|
||||||
|
section_zTXt="zTXt"
|
||||||
11
contrib/pngminus/.gitignore
vendored
Normal file
11
contrib/pngminus/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Compiled executables
|
||||||
|
png2pnm
|
||||||
|
png2pnm.exe
|
||||||
|
png2pnm-static*
|
||||||
|
pnm2png
|
||||||
|
pnm2png.exe
|
||||||
|
pnm2png-static*
|
||||||
|
|
||||||
|
# Test artifacts
|
||||||
|
*.png
|
||||||
|
*.p[abgnp]m
|
||||||
14
contrib/pngminus/CHANGES.txt
Normal file
14
contrib/pngminus/CHANGES.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||||
|
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||||
|
|
||||||
|
version 1.0 - 1999.10.15 - First version.
|
||||||
|
1.1 - 2015.07.29 - Fix memory leaks (Glenn Randers-Pehrson)
|
||||||
|
1.2 - 2017.04.22 - Add buffer-size check
|
||||||
|
1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||||
|
(Glenn Randers-Pehrson)
|
||||||
|
1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
|
||||||
|
1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
|
||||||
|
1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
|
||||||
|
1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)
|
||||||
|
1.8 - 2024.01.09 - Fix, improve, modernize (Cosmin Truta)
|
||||||
41
contrib/pngminus/CMakeLists.txt
Normal file
41
contrib/pngminus/CMakeLists.txt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (c) 2018-2024 Cosmin Truta
|
||||||
|
#
|
||||||
|
# This software is released under the MIT license. For conditions of
|
||||||
|
# distribution and use, see the LICENSE file part of this package.
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
project(PNGMINUS C)
|
||||||
|
|
||||||
|
option(PNGMINUS_USE_SYSTEM_PNG
|
||||||
|
"Use the libpng build found in the system" OFF)
|
||||||
|
|
||||||
|
add_executable(png2pnm png2pnm.c)
|
||||||
|
add_executable(pnm2png pnm2png.c)
|
||||||
|
|
||||||
|
if(PNGMINUS_USE_SYSTEM_PNG)
|
||||||
|
# Use the system libpng.
|
||||||
|
find_package(PNG REQUIRED)
|
||||||
|
target_link_libraries(png2pnm PRIVATE PNG::PNG)
|
||||||
|
target_link_libraries(pnm2png PRIVATE PNG::PNG)
|
||||||
|
else()
|
||||||
|
# Build and use the internal libpng.
|
||||||
|
# Configure libpng for static linking, to produce single-file executables.
|
||||||
|
set(PNG_STATIC ON
|
||||||
|
CACHE STRING "Build the internal libpng as a static library" FORCE)
|
||||||
|
set(PNG_SHARED OFF
|
||||||
|
CACHE STRING "Build the internal libpng as a shared library" FORCE)
|
||||||
|
set(PNG_FRAMEWORK OFF
|
||||||
|
CACHE STRING "Build the internal libpng as a framework bundle" FORCE)
|
||||||
|
add_subdirectory(../.. libpng)
|
||||||
|
target_include_directories(png2pnm PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
|
||||||
|
)
|
||||||
|
target_include_directories(pnm2png PRIVATE
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
|
||||||
|
)
|
||||||
|
target_link_libraries(png2pnm PRIVATE png_static)
|
||||||
|
target_link_libraries(pnm2png PRIVATE png_static)
|
||||||
|
endif()
|
||||||
22
contrib/pngminus/LICENSE.txt
Normal file
22
contrib/pngminus/LICENSE.txt
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||||
|
|
||||||
|
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
The software is provided "as is", without warranty of any kind, express or
|
||||||
|
implied, including but not limited to the warranties of merchantability,
|
||||||
|
fitness for a particular purpose and noninfringement. In no event shall the
|
||||||
|
authors or copyright holders be liable for any claim, damages or other
|
||||||
|
liability, whether in an action of contract, tort or otherwise, arising from,
|
||||||
|
out of or in connection with the software or the use or other dealings in the
|
||||||
|
software.
|
||||||
62
contrib/pngminus/Makefile
Normal file
62
contrib/pngminus/Makefile
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# Makefile for PngMinus (png2pnm and pnm2png)
|
||||||
|
# Linux / Unix
|
||||||
|
|
||||||
|
#CC = cc
|
||||||
|
CC = gcc
|
||||||
|
LD = $(CC)
|
||||||
|
|
||||||
|
RM = rm -f
|
||||||
|
|
||||||
|
PNGINC = -I../..
|
||||||
|
PNGLIB_SHARED = -L../.. -lpng
|
||||||
|
PNGLIB_STATIC = ../../libpng.a
|
||||||
|
|
||||||
|
# Uncomment the following if you have a custom zlib build at ../../../zlib
|
||||||
|
#ZINC = -I../../../zlib
|
||||||
|
#ZLIB_SHARED = -L../../../zlib -lz
|
||||||
|
#ZLIB_STATIC = ../../../zlib/libz.a
|
||||||
|
|
||||||
|
# Use the system zlib otherwise
|
||||||
|
ZLIB_SHARED = -lz
|
||||||
|
ZLIB_STATIC = -lz
|
||||||
|
|
||||||
|
CPPFLAGS = $(PNGINC) $(ZINC)
|
||||||
|
CFLAGS =
|
||||||
|
LDFLAGS =
|
||||||
|
LIBS_SHARED = $(PNGLIB_SHARED) $(ZLIB_SHARED)
|
||||||
|
LIBS_STATIC = $(PNGLIB_STATIC) $(ZLIB_STATIC)
|
||||||
|
|
||||||
|
EXEEXT =
|
||||||
|
#EXEEXT = .exe
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
|
||||||
|
all: png2pnm$(EXEEXT) pnm2png$(EXEEXT) png2pnm-static$(EXEEXT) pnm2png-static$(EXEEXT)
|
||||||
|
|
||||||
|
png2pnm.o: png2pnm.c
|
||||||
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm.c
|
||||||
|
|
||||||
|
pnm2png.o: pnm2png.c
|
||||||
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png.c
|
||||||
|
|
||||||
|
png2pnm$(EXEEXT): png2pnm.o
|
||||||
|
$(LD) $(LDFLAGS) -o png2pnm$(EXEEXT) png2pnm.o $(LIBS_SHARED) -lm
|
||||||
|
|
||||||
|
pnm2png$(EXEEXT): pnm2png.o
|
||||||
|
$(LD) $(LDFLAGS) -o pnm2png$(EXEEXT) pnm2png.o $(LIBS_SHARED) -lm
|
||||||
|
|
||||||
|
png2pnm-static$(EXEEXT): png2pnm.o
|
||||||
|
$(LD) $(LDFLAGS) -o png2pnm-static$(EXEEXT) png2pnm.o $(LIBS_STATIC) -lm
|
||||||
|
|
||||||
|
pnm2png-static$(EXEEXT): pnm2png.o
|
||||||
|
$(LD) $(LDFLAGS) -o pnm2png-static$(EXEEXT) pnm2png.o $(LIBS_STATIC) -lm
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) png2pnm.o
|
||||||
|
$(RM) pnm2png.o
|
||||||
|
$(RM) png2pnm$(EXEEXT)
|
||||||
|
$(RM) pnm2png$(EXEEXT)
|
||||||
|
$(RM) png2pnm-static$(EXEEXT)
|
||||||
|
$(RM) pnm2png-static$(EXEEXT)
|
||||||
|
|
||||||
|
# End of makefile for png2pnm / pnm2png
|
||||||
@@ -1,26 +1,16 @@
|
|||||||
PngMinus
|
PngMinus
|
||||||
--------
|
--------
|
||||||
(copyright Willem van Schaik, 1999)
|
(copyright Willem van Schaik, 1999-2019)
|
||||||
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software and
|
|
||||||
its documentation for any purpose and without fee is hereby granted,
|
|
||||||
provided that the above copyright notice appear in all copies and
|
|
||||||
that both that copyright notice and this permission notice appear in
|
|
||||||
supporting documentation. This software is provided "as is" without
|
|
||||||
express or implied warranty.
|
|
||||||
|
|
||||||
|
|
||||||
Some history
|
Some history
|
||||||
------------
|
------------
|
||||||
Soon after the creation of PNG in 1995, the need was felt for a set of
|
Soon after the creation of PNG in 1995, the need was felt for a set of
|
||||||
pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
|
pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I
|
||||||
(Willem van Schaik) started such a project. Luckily we discovered this
|
(Willem van Schaik) started such a project. Luckily we discovered this
|
||||||
and merged the two together into pnmtopng.tar.gz, which is available
|
and merged the two, which later became part of NetPBM, available from
|
||||||
from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
|
SourceForge.
|
||||||
|
|
||||||
These two utilities have many, many options and make use of most of the
|
These two utilities have many, many options and make use of most of the
|
||||||
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
|
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
|
||||||
@@ -35,8 +25,8 @@ makes the whole setup a bit bulky. But that's unavoidable given the many
|
|||||||
features of pnmtopng.
|
features of pnmtopng.
|
||||||
|
|
||||||
|
|
||||||
What now
|
What now (1999)
|
||||||
--------
|
---------------
|
||||||
At this moment libpng is in a very stable state and can do much of the
|
At this moment libpng is in a very stable state and can do much of the
|
||||||
work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
|
work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
|
||||||
interface of libpng. Hence, it is time for a rewrite from the ground up
|
interface of libpng. Hence, it is time for a rewrite from the ground up
|
||||||
@@ -49,8 +39,8 @@ a small prototype that contains only the basic functionality. It doesn't
|
|||||||
have any of the options to read or write special chunks and it will do
|
have any of the options to read or write special chunks and it will do
|
||||||
no gamma correction. But this makes it also a simple program that is
|
no gamma correction. But this makes it also a simple program that is
|
||||||
quite easy to understand and can serve well as a template for other
|
quite easy to understand and can serve well as a template for other
|
||||||
software developments. (By now there are of course a couple of programs,
|
software developments. By now there are of course a couple of programs,
|
||||||
like Greg Roelofs' rpng/wpng, that can be used just as good.)
|
like Greg Roelofs' rpng/wpng, that can be used just as good.
|
||||||
|
|
||||||
|
|
||||||
Can and can not
|
Can and can not
|
||||||
@@ -60,7 +50,8 @@ PngMinus. Because I started this development in good-old Turbo-C, I
|
|||||||
avoided the use the netpbm library, which requires DOS extenders. Again,
|
avoided the use the netpbm library, which requires DOS extenders. Again,
|
||||||
another reason to call it PngMinus (minus netpbm :-). So, part of the
|
another reason to call it PngMinus (minus netpbm :-). So, part of the
|
||||||
program are some elementary routines to read / write pgm- and ppm-files.
|
program are some elementary routines to read / write pgm- and ppm-files.
|
||||||
It does not read b&w pbm-files.
|
It does not handle B&W pbm-files, but instead you could do pgm with bit-
|
||||||
|
depth 1.
|
||||||
|
|
||||||
The downside of this approach is that you can not use them on images
|
The downside of this approach is that you can not use them on images
|
||||||
that require blocks of memory bigger than 64k (the DOS version). For
|
that require blocks of memory bigger than 64k (the DOS version). For
|
||||||
@@ -96,58 +87,34 @@ To list the options type "png2pnm -h" or "pnm2png -h".
|
|||||||
|
|
||||||
Just like Scandinavian furniture
|
Just like Scandinavian furniture
|
||||||
--------------------------------
|
--------------------------------
|
||||||
You have to put it together yourself. I did test the software under
|
You have to put it together yourself. I developed the software on MS-DOS
|
||||||
MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
|
with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
|
||||||
cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
|
libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
|
||||||
however some older libpng versions have a bug in pngmem.c when using
|
more current versions are OK.
|
||||||
Turbo-C 3.0 (see below).
|
|
||||||
|
|
||||||
You can build it using one of the two makefiles (make -f makefile.###)
|
The makefile assumes that the libpng libraries can be found in ../.. and
|
||||||
or use the batch/script files pngminus.bat / pngminus.sh. This assumes
|
libz in ../../../zlib. But you can change this to for example ../libpng
|
||||||
that you have built the libraries in ../libpng and ../zlib. Using Linux,
|
and ../zlib. The makefile creates two versions of each program, one with
|
||||||
make sure that you have built libpng with makefile.std and not
|
static library support and the other using shared libraries.
|
||||||
makefile.linux (also called .lnx in earlier versions of libpng). The
|
|
||||||
latter creates a .so shared-library, while the PngMinus makefile assumes
|
|
||||||
a normal .a static library.
|
|
||||||
|
|
||||||
If you create a ../pngsuite directory and then store the basn####.png
|
If you create a ../pngsuite directory and then store the basn####.png
|
||||||
files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
|
files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
|
||||||
test in one go the proper functioning of PngMinus, see png2pnm.bat and
|
test the proper functioning of PngMinus by running pngminus.sh.
|
||||||
pnm2png.bat (or the .sh versions).
|
|
||||||
|
|
||||||
|
|
||||||
Warranty
|
Warranty
|
||||||
-------
|
-------
|
||||||
Please, remember that this was just a small experiment to learn a few
|
Please, remember that this was just a small experiment to learn a few
|
||||||
things. It will have many unforeseen features <vbg>. Who said bugs? Use
|
things. It will have many unforeseen features <vbg> ... who said bugs? Use
|
||||||
it when you are in need for something simple or when you want to start
|
it when you are in need for something simple or when you want a starting
|
||||||
developing your own stuff.
|
point for developing your own stuff.
|
||||||
|
|
||||||
|
|
||||||
The Turbo bug
|
|
||||||
-------------
|
|
||||||
** pngmem.old
|
|
||||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
|
||||||
hptr += 16L;
|
|
||||||
** pngmem.c
|
|
||||||
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
|
|
||||||
hptr = hptr + 16L;
|
|
||||||
**
|
|
||||||
|
|
||||||
** pngmem.old
|
|
||||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
|
||||||
hptr += (png_uint_32)65536L;
|
|
||||||
** pngmem.c
|
|
||||||
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
|
|
||||||
hptr = hptr + 65536L;
|
|
||||||
**
|
|
||||||
|
|
||||||
|
|
||||||
The end
|
The end
|
||||||
-------
|
-------
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
mailto:willem@schaik.com
|
mailto:willem at schaik dot com
|
||||||
http://www.schaik.com/png/
|
http://www.schaik.com/png/
|
||||||
-------
|
|
||||||
Oct 1999
|
Oct 1999, Jan 2019
|
||||||
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
|
||||||
# Linux / Unix
|
|
||||||
|
|
||||||
#CC=cc
|
|
||||||
CC=gcc
|
|
||||||
LD=$(CC)
|
|
||||||
|
|
||||||
RM=rm -f
|
|
||||||
|
|
||||||
#PNGPATH = /usr/local
|
|
||||||
#PNGINC = -I$(PNGPATH)/include/libpng16
|
|
||||||
#PNGLIB = -L$(PNGPATH)/lib -lpng16
|
|
||||||
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
|
|
||||||
PNGINC = -I../..
|
|
||||||
PNGLIB = -L../.. -lpng
|
|
||||||
PNGLIBS = ../../libpng.a
|
|
||||||
|
|
||||||
#ZPATH = /usr/local
|
|
||||||
#ZINC = -I$(ZPATH)/include
|
|
||||||
#ZLIB = -L$(ZPATH)/lib -lz
|
|
||||||
#ZLIBS = $(ZPATH)/lib/libz.a
|
|
||||||
ZINC = -I../../../zlib
|
|
||||||
ZLIB = -L../../../zlib -lz
|
|
||||||
ZLIBS = ../../../zlib/libz.a
|
|
||||||
|
|
||||||
CPPFLAGS=$(PNGINC) $(ZINC)
|
|
||||||
CFLAGS=
|
|
||||||
LDLIBS=$(PNGLIB) $(ZLIB)
|
|
||||||
LDLIBSS=$(PNGLIBS) $(ZLIBS)
|
|
||||||
C=.c
|
|
||||||
O=.o
|
|
||||||
L=.a
|
|
||||||
E=
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
|
|
||||||
#all: png2pnm$(E) pnm2png$(E)
|
|
||||||
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
|
|
||||||
|
|
||||||
png2pnm$(O): png2pnm$(C)
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
|
||||||
|
|
||||||
png2pnm$(E): png2pnm$(O)
|
|
||||||
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
|
|
||||||
|
|
||||||
png2pnm-static$(E): png2pnm$(O)
|
|
||||||
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
|
|
||||||
|
|
||||||
pnm2png$(O): pnm2png$(C)
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
|
||||||
|
|
||||||
pnm2png$(E): pnm2png$(O)
|
|
||||||
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
|
|
||||||
|
|
||||||
pnm2png-static$(E): pnm2png$(O)
|
|
||||||
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) png2pnm$(O)
|
|
||||||
$(RM) pnm2png$(O)
|
|
||||||
$(RM) png2pnm$(E)
|
|
||||||
$(RM) pnm2png$(E)
|
|
||||||
$(RM) png2pnm-static$(E)
|
|
||||||
$(RM) pnm2png-static$(E)
|
|
||||||
|
|
||||||
# End of makefile for png2pnm / pnm2png
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# Makefile for PngMinus (png2pnm and pnm2png)
|
|
||||||
# TurboC++ 3.0
|
|
||||||
|
|
||||||
CC=tcc -Ic:\tc3\inc
|
|
||||||
LD=tcc -Lc:\tc3\lib
|
|
||||||
LB=tlib
|
|
||||||
RM=del
|
|
||||||
CP=copy
|
|
||||||
MODEL=l
|
|
||||||
CPPFLAGS=-I..\libpng -I..\zlib
|
|
||||||
CFLAGS=-O -m$(MODEL)
|
|
||||||
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
|
|
||||||
C=.c
|
|
||||||
O=.obj
|
|
||||||
L=.lib
|
|
||||||
E=.exe
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
|
|
||||||
all: png2pnm$(E) pnm2png$(E)
|
|
||||||
|
|
||||||
png2pnm$(O): png2pnm$(C)
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
|
|
||||||
|
|
||||||
png2pnm$(E): png2pnm$(O)
|
|
||||||
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
|
|
||||||
|
|
||||||
pnm2png$(O): pnm2png$(C)
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
|
|
||||||
|
|
||||||
pnm2png$(E): pnm2png$(O)
|
|
||||||
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) *$(O)
|
|
||||||
$(RM) *$(E)
|
|
||||||
|
|
||||||
# End of makefile for png2pnm / pnm2png
|
|
||||||
@@ -1,71 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
||||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||||
*
|
*
|
||||||
* version 1.0 - 1999.10.15 - First version.
|
* This software is released under the MIT license. For conditions of
|
||||||
*
|
* distribution and use, see the LICENSE file part of this package.
|
||||||
* Permission to use, copy, modify, and distribute this software and
|
|
||||||
* its documentation for any purpose and without fee is hereby granted,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear in
|
|
||||||
* supporting documentation. This software is provided "as is" without
|
|
||||||
* express or implied warranty.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef __TURBOC__
|
|
||||||
#include <mem.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
#endif
|
#endif
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE (BOOL) 1
|
#define TRUE ((BOOL) 1)
|
||||||
#endif
|
#endif
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE (BOOL) 0
|
#define FALSE ((BOOL) 0)
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __TURBOC__
|
|
||||||
#define STDIN 0
|
|
||||||
#define STDOUT 1
|
|
||||||
#define STDERR 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* to make png2pnm verbose so we can find problems (needs to be before png.h) */
|
|
||||||
#ifndef PNG_DEBUG
|
|
||||||
#define PNG_DEBUG 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
|
||||||
#ifndef png_jmpbuf
|
|
||||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
|
|
||||||
int main (int argc, char *argv[]);
|
int main (int argc, char *argv[]);
|
||||||
void usage ();
|
void usage ();
|
||||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
|
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL raw, BOOL alpha);
|
||||||
|
BOOL do_png2pnm (png_struct *png_ptr, png_info *info_ptr,
|
||||||
|
FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL raw, BOOL alpha);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp_rd = stdin;
|
FILE *fp_rd = stdin;
|
||||||
FILE *fp_wr = stdout;
|
FILE *fp_wr = stdout;
|
||||||
FILE *fp_al = NULL;
|
FILE *fp_al = NULL;
|
||||||
|
const char *fname_wr = NULL;
|
||||||
|
const char *fname_al = NULL;
|
||||||
BOOL raw = TRUE;
|
BOOL raw = TRUE;
|
||||||
BOOL alpha = FALSE;
|
BOOL alpha = FALSE;
|
||||||
int argi;
|
int argi;
|
||||||
|
int ret;
|
||||||
|
|
||||||
for (argi = 1; argi < argc; argi++)
|
for (argi = 1; argi < argc; argi++)
|
||||||
{
|
{
|
||||||
@@ -84,21 +65,23 @@ int main(int argc, char *argv[])
|
|||||||
argi++;
|
argi++;
|
||||||
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
||||||
{
|
{
|
||||||
|
fname_al = argv[argi];
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
|
fprintf (stderr, "Error: cannot create alpha-channel file %s\n",
|
||||||
|
argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage ();
|
||||||
exit(0);
|
exit (0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||||
usage();
|
usage ();
|
||||||
exit(1);
|
exit (1);
|
||||||
break;
|
break;
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
}
|
}
|
||||||
@@ -106,17 +89,18 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fp_wr == stdout)
|
else if (fp_wr == stdout)
|
||||||
{
|
{
|
||||||
|
fname_wr = argv[argi];
|
||||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: can not create file %s\n", argv[argi]);
|
fprintf (stderr, "Error: cannot create file %s\n", argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,30 +108,21 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: too many parameters\n");
|
fprintf (stderr, "Error: too many parameters\n");
|
||||||
usage();
|
usage ();
|
||||||
exit(1);
|
exit (1);
|
||||||
}
|
}
|
||||||
} /* end for */
|
} /* end for */
|
||||||
|
|
||||||
#ifdef __TURBOC__
|
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||||
/* set stdin/stdout if required to binary */
|
/* set stdin/stdout if required to binary */
|
||||||
if (fp_rd == stdin)
|
if (fp_rd == stdin)
|
||||||
{
|
setmode (fileno (stdin), O_BINARY);
|
||||||
setmode (STDIN, O_BINARY);
|
|
||||||
}
|
|
||||||
if ((raw) && (fp_wr == stdout))
|
if ((raw) && (fp_wr == stdout))
|
||||||
{
|
setmode (fileno (stdout), O_BINARY);
|
||||||
setmode (STDOUT, O_BINARY);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* call the conversion program itself */
|
/* call the conversion program itself */
|
||||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
ret = png2pnm (fp_rd, fp_wr, fp_al, raw, alpha);
|
||||||
{
|
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
|
||||||
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close input file */
|
/* close input file */
|
||||||
fclose (fp_rd);
|
fclose (fp_rd);
|
||||||
@@ -157,6 +132,17 @@ int main(int argc, char *argv[])
|
|||||||
if (alpha)
|
if (alpha)
|
||||||
fclose (fp_al);
|
fclose (fp_al);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
|
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||||
|
if (fname_wr)
|
||||||
|
remove (fname_wr); /* no broken output file shall remain behind */
|
||||||
|
if (fname_al)
|
||||||
|
remove (fname_al); /* ditto */
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,21 +150,18 @@ int main(int argc, char *argv[])
|
|||||||
* usage
|
* usage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void usage()
|
void usage ()
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||||
#ifdef __TURBOC__
|
|
||||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
|
||||||
#else
|
|
||||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
|
||||||
#endif
|
|
||||||
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
|
||||||
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
fprintf (stderr, " or: ... | png2pnm [options]\n");
|
||||||
fprintf (stderr, "Options:\n");
|
fprintf (stderr, "Options:\n");
|
||||||
fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
fprintf (stderr,
|
||||||
|
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||||
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
|
||||||
fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
fprintf (stderr,
|
||||||
|
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||||
fprintf (stderr, " -h | -? print this help-information\n");
|
fprintf (stderr, " -h | -? print this help-information\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,112 +169,96 @@ void usage()
|
|||||||
* png2pnm
|
* png2pnm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
|
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL raw, BOOL alpha)
|
||||||
{
|
{
|
||||||
png_struct *png_ptr = NULL;
|
png_struct *png_ptr;
|
||||||
png_info *info_ptr = NULL;
|
png_info *info_ptr;
|
||||||
png_byte buf[8];
|
BOOL ret;
|
||||||
png_byte *png_pixels = NULL;
|
|
||||||
png_byte **row_pointers = NULL;
|
|
||||||
png_byte *pix_ptr = NULL;
|
|
||||||
png_uint_32 row_bytes;
|
|
||||||
|
|
||||||
|
/* initialize the libpng context for reading from png_file */
|
||||||
|
|
||||||
|
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
if (!png_ptr)
|
||||||
|
return FALSE; /* out of memory */
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct (png_ptr);
|
||||||
|
if (!info_ptr)
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
||||||
|
return FALSE; /* out of memory */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp (png_jmpbuf (png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
return FALSE; /* generic libpng error */
|
||||||
|
}
|
||||||
|
|
||||||
|
png_init_io (png_ptr, png_file);
|
||||||
|
|
||||||
|
/* do the actual conversion */
|
||||||
|
ret = do_png2pnm (png_ptr, info_ptr, pnm_file, alpha_file, raw, alpha);
|
||||||
|
|
||||||
|
/* clean up the libpng structures and their internally-managed data */
|
||||||
|
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* do_png2pnm - does the conversion in a fully-initialized libpng context
|
||||||
|
*/
|
||||||
|
|
||||||
|
BOOL do_png2pnm (png_struct *png_ptr, png_info *info_ptr,
|
||||||
|
FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL raw, BOOL alpha)
|
||||||
|
{
|
||||||
|
png_byte **row_pointers;
|
||||||
|
png_byte *pix_ptr;
|
||||||
png_uint_32 width;
|
png_uint_32 width;
|
||||||
png_uint_32 height;
|
png_uint_32 height;
|
||||||
int bit_depth;
|
int bit_depth;
|
||||||
int channels;
|
int channels;
|
||||||
int color_type;
|
int color_type;
|
||||||
int alpha_present;
|
int alpha_present;
|
||||||
int row, col;
|
png_uint_32 row, col, i;
|
||||||
int ret;
|
|
||||||
int i;
|
|
||||||
long dep_16;
|
long dep_16;
|
||||||
|
|
||||||
/* read and check signature in PNG file */
|
/* set up the image transformations that are necessary for the PNM format */
|
||||||
ret = fread (buf, 1, 8, png_file);
|
|
||||||
if (ret != 8)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
ret = png_sig_cmp (buf, 0, 8);
|
/* set up (if applicable) the expansion of paletted images to full-color rgb,
|
||||||
if (ret)
|
* and the expansion of transparency maps to full alpha-channel */
|
||||||
return FALSE;
|
png_set_expand (png_ptr);
|
||||||
|
|
||||||
/* create png and info structures */
|
/* set up (if applicable) the expansion of grayscale images to bit-depth 8 */
|
||||||
|
png_set_expand_gray_1_2_4_to_8 (png_ptr);
|
||||||
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
if (!png_ptr)
|
|
||||||
return FALSE; /* out of memory */
|
|
||||||
|
|
||||||
info_ptr = png_create_info_struct (png_ptr);
|
|
||||||
if (!info_ptr)
|
|
||||||
{
|
|
||||||
png_destroy_read_struct (&png_ptr, NULL, NULL);
|
|
||||||
return FALSE; /* out of memory */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setjmp (png_jmpbuf(png_ptr)))
|
|
||||||
{
|
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up the input control for C streams */
|
|
||||||
png_init_io (png_ptr, png_file);
|
|
||||||
png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
|
|
||||||
|
|
||||||
/* read the file information */
|
|
||||||
png_read_info (png_ptr, info_ptr);
|
|
||||||
|
|
||||||
/* get size and bit-depth of the PNG-image */
|
|
||||||
png_get_IHDR (png_ptr, info_ptr,
|
|
||||||
&width, &height, &bit_depth, &color_type,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* set-up the transformations */
|
|
||||||
|
|
||||||
/* transform paletted images into full-color rgb */
|
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
|
||||||
png_set_expand (png_ptr);
|
|
||||||
/* expand images to bit-depth 8 (only applicable for grayscale images) */
|
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
|
||||||
png_set_expand (png_ptr);
|
|
||||||
/* transform transparency maps into full alpha-channel */
|
|
||||||
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
|
|
||||||
png_set_expand (png_ptr);
|
|
||||||
|
|
||||||
#ifdef NJET
|
#ifdef NJET
|
||||||
/* downgrade 16-bit images to 8 bit */
|
/* downgrade 16-bit images to 8-bit */
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
png_set_strip_16 (png_ptr);
|
png_set_strip_16 (png_ptr);
|
||||||
/* transform grayscale images into full-color */
|
/* transform grayscale images into full-color */
|
||||||
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);
|
||||||
/* only if file has a file gamma, we do a correction */
|
/* if the PNG image has a gAMA chunk then gamma-correct the output image */
|
||||||
if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
|
|
||||||
png_set_gamma (png_ptr, (double) 2.2, file_gamma);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* all transformations have been registered; now update info_ptr data,
|
|
||||||
* get rowbytes and channels, and allocate image memory */
|
|
||||||
|
|
||||||
png_read_update_info (png_ptr, info_ptr);
|
|
||||||
|
|
||||||
/* get the new color-type and bit-depth (after expansion/stripping) */
|
|
||||||
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* check for 16-bit files */
|
|
||||||
if (bit_depth == 16)
|
|
||||||
{
|
{
|
||||||
raw = FALSE;
|
double file_gamma;
|
||||||
#ifdef __TURBOC__
|
if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
|
||||||
pnm_file->flags &= ~((unsigned) _F_BIN);
|
png_set_gamma (png_ptr, (double) 2.2, file_gamma);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* calculate new number of channels and store alpha-presence */
|
/* read the image file, with all of the above image transforms applied */
|
||||||
|
png_read_png (png_ptr, info_ptr, 0, NULL);
|
||||||
|
|
||||||
|
/* get the image size, bit-depth and color-type */
|
||||||
|
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
/* calculate the number of channels and store alpha-presence */
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||||
channels = 1;
|
channels = 1;
|
||||||
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
@@ -308,38 +275,12 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
if (alpha && !alpha_present)
|
if (alpha && !alpha_present)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNG2PNM\n");
|
fprintf (stderr, "PNG2PNM\n");
|
||||||
fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n");
|
fprintf (stderr, "Warning: no alpha channel in PNG file\n");
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
|
||||||
row_bytes = png_get_rowbytes (png_ptr, info_ptr);
|
|
||||||
|
|
||||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
|
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
/* get address of internally-allocated image data */
|
||||||
{
|
row_pointers = png_get_rows (png_ptr, info_ptr);
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
|
||||||
free (png_pixels);
|
|
||||||
png_pixels = NULL;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the individual row_pointers to point at the correct offsets */
|
|
||||||
for (i = 0; i < (height); i++)
|
|
||||||
row_pointers[i] = png_pixels + i * row_bytes;
|
|
||||||
|
|
||||||
/* now we can go ahead and just read the whole image */
|
|
||||||
png_read_image (png_ptr, row_pointers);
|
|
||||||
|
|
||||||
/* read rest of file, and get additional chunks in info_ptr - REQUIRED */
|
|
||||||
png_read_end (png_ptr, info_ptr);
|
|
||||||
|
|
||||||
/* clean up after the read, and free any memory allocated - REQUIRED */
|
|
||||||
png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
|
|
||||||
|
|
||||||
/* write header of PNM file */
|
/* write header of PNM file */
|
||||||
|
|
||||||
@@ -370,45 +311,67 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* write data to PNM file */
|
/* write data to PNM file */
|
||||||
pix_ptr = png_pixels;
|
|
||||||
|
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < height; row++)
|
||||||
{
|
{
|
||||||
|
pix_ptr = row_pointers[row];
|
||||||
for (col = 0; col < width; col++)
|
for (col = 0; col < width; col++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (channels - alpha_present); i++)
|
for (i = 0; i < (png_uint_32) (channels - alpha_present); i++)
|
||||||
{
|
{
|
||||||
if (raw)
|
if (raw)
|
||||||
fputc ((int) *pix_ptr++ , pnm_file);
|
{
|
||||||
|
fputc ((int) *pix_ptr++, pnm_file);
|
||||||
|
if (bit_depth == 16)
|
||||||
|
fputc ((int) *pix_ptr++, pnm_file);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if (bit_depth == 16){
|
{
|
||||||
dep_16 = (long) *pix_ptr++;
|
if (bit_depth == 16)
|
||||||
fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
|
{
|
||||||
|
dep_16 = ((long) *pix_ptr++) << 8;
|
||||||
|
dep_16 += ((long) *pix_ptr++);
|
||||||
|
fprintf (pnm_file, "%ld ", dep_16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (alpha_present)
|
if (alpha_present)
|
||||||
{
|
{
|
||||||
if (!alpha)
|
if (!alpha)
|
||||||
{
|
{
|
||||||
pix_ptr++; /* alpha */
|
/* skip the alpha-channel */
|
||||||
|
pix_ptr++;
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
pix_ptr++;
|
pix_ptr++;
|
||||||
}
|
}
|
||||||
else /* output alpha-channel as pgm file */
|
else
|
||||||
{
|
{
|
||||||
|
/* output the alpha-channel as pgm file */
|
||||||
if (raw)
|
if (raw)
|
||||||
fputc ((int) *pix_ptr++ , alpha_file);
|
{
|
||||||
|
fputc ((int) *pix_ptr++, alpha_file);
|
||||||
|
if (bit_depth == 16)
|
||||||
|
fputc ((int) *pix_ptr++, alpha_file);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if (bit_depth == 16){
|
{
|
||||||
dep_16 = (long) *pix_ptr++;
|
if (bit_depth == 16)
|
||||||
fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
|
{
|
||||||
|
dep_16 = ((long) *pix_ptr++) << 8;
|
||||||
|
dep_16 += ((long) *pix_ptr++);
|
||||||
|
fprintf (alpha_file, "%ld ", dep_16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} /* if alpha_present */
|
} /* end if alpha_present */
|
||||||
|
|
||||||
if (!raw)
|
if (!raw)
|
||||||
if (col % 4 == 3)
|
if (col % 4 == 3)
|
||||||
@@ -420,12 +383,5 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a
|
|||||||
fprintf (pnm_file, "\n");
|
fprintf (pnm_file, "\n");
|
||||||
} /* end for row */
|
} /* end for row */
|
||||||
|
|
||||||
if (row_pointers != (unsigned char**) NULL)
|
|
||||||
free (row_pointers);
|
|
||||||
if (png_pixels != (unsigned char*) NULL)
|
|
||||||
free (png_pixels);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} /* end of source */
|
} /* end of source */
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||||
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
|
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||||
*
|
*
|
||||||
* version 1.0 - 1999.10.15 - First version.
|
* This software is released under the MIT license. For conditions of
|
||||||
*
|
* distribution and use, see the LICENSE file part of this package.
|
||||||
* Permission to use, copy, modify, and distribute this software and
|
|
||||||
* its documentation for any purpose and without fee is hereby granted,
|
|
||||||
* provided that the above copyright notice appear in all copies and
|
|
||||||
* that both that copyright notice and this permission notice appear in
|
|
||||||
* supporting documentation. This software is provided "as is" without
|
|
||||||
* express or implied warranty.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef __TURBOC__
|
|
||||||
#include <mem.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#ifndef BOOL
|
#ifndef BOOL
|
||||||
#define BOOL unsigned char
|
#define BOOL unsigned char
|
||||||
#endif
|
#endif
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE (BOOL) 1
|
#define TRUE ((BOOL) 1)
|
||||||
#endif
|
#endif
|
||||||
#ifndef FALSE
|
#ifndef FALSE
|
||||||
#define FALSE (BOOL) 0
|
#define FALSE ((BOOL) 0)
|
||||||
#endif
|
|
||||||
|
|
||||||
#define STDIN 0
|
|
||||||
#define STDOUT 1
|
|
||||||
#define STDERR 2
|
|
||||||
|
|
||||||
/* to make pnm2png verbose so we can find problems (needs to be before png.h) */
|
|
||||||
#ifndef PNG_DEBUG
|
|
||||||
#define PNG_DEBUG 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "png.h"
|
#include "png.h"
|
||||||
|
|
||||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
|
||||||
#ifndef png_jmpbuf
|
|
||||||
# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* function prototypes */
|
/* function prototypes */
|
||||||
|
|
||||||
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,
|
||||||
void get_token(FILE *pnm_file, char *token);
|
BOOL interlace, BOOL alpha);
|
||||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
|
||||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL interlace, BOOL alpha);
|
||||||
|
int fscan_pnm_magic (FILE *pnm_file, char *magic_buf, size_t magic_buf_size);
|
||||||
|
int fscan_pnm_token (FILE *pnm_file, char *token_buf, size_t token_buf_size);
|
||||||
|
int fscan_pnm_uint_32 (FILE *pnm_file, png_uint_32 *num_ptr);
|
||||||
|
png_uint_32 get_pnm_data (FILE *pnm_file, int depth);
|
||||||
|
png_uint_32 get_pnm_value (FILE *pnm_file, int depth);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* main
|
* main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp_rd = stdin;
|
FILE *fp_rd = stdin;
|
||||||
FILE *fp_al = NULL;
|
FILE *fp_al = NULL;
|
||||||
FILE *fp_wr = stdout;
|
FILE *fp_wr = stdout;
|
||||||
|
const char *fname_wr = NULL;
|
||||||
BOOL interlace = FALSE;
|
BOOL interlace = FALSE;
|
||||||
BOOL alpha = FALSE;
|
BOOL alpha = FALSE;
|
||||||
int argi;
|
int argi;
|
||||||
|
int ret;
|
||||||
|
|
||||||
for (argi = 1; argi < argc; argi++)
|
for (argi = 1; argi < argc; argi++)
|
||||||
{
|
{
|
||||||
@@ -84,20 +69,20 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
||||||
argv[argi]);
|
argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
usage();
|
usage ();
|
||||||
exit(0);
|
exit (0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||||
usage();
|
usage ();
|
||||||
exit(1);
|
exit (1);
|
||||||
break;
|
break;
|
||||||
} /* end switch */
|
} /* end switch */
|
||||||
}
|
}
|
||||||
@@ -112,10 +97,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (fp_wr == stdout)
|
else if (fp_wr == stdout)
|
||||||
{
|
{
|
||||||
|
fname_wr = argv[argi];
|
||||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: can not create PNG-file %s\n", argv[argi]);
|
fprintf (stderr, "Error: cannot create PNG-file %s\n", argv[argi]);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,30 +109,23 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, "Error: too many parameters\n");
|
fprintf (stderr, "Error: too many parameters\n");
|
||||||
usage();
|
usage ();
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
} /* end for */
|
} /* end for */
|
||||||
|
|
||||||
#ifdef __TURBOC__
|
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||||
/* set stdin/stdout to binary, we're reading the PNM always! in binary format */
|
/* set stdin/stdout to binary,
|
||||||
|
* we're reading the PNM always! in binary format
|
||||||
|
*/
|
||||||
if (fp_rd == stdin)
|
if (fp_rd == stdin)
|
||||||
{
|
setmode (fileno (stdin), O_BINARY);
|
||||||
setmode (STDIN, O_BINARY);
|
|
||||||
}
|
|
||||||
if (fp_wr == stdout)
|
if (fp_wr == stdout)
|
||||||
{
|
setmode (fileno (stdout), O_BINARY);
|
||||||
setmode (STDOUT, O_BINARY);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* call the conversion program itself */
|
/* call the conversion program itself */
|
||||||
if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE)
|
ret = pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha);
|
||||||
{
|
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
|
||||||
fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close input file */
|
/* close input file */
|
||||||
fclose (fp_rd);
|
fclose (fp_rd);
|
||||||
@@ -156,6 +135,15 @@ int main(int argc, char *argv[])
|
|||||||
if (alpha)
|
if (alpha)
|
||||||
fclose (fp_al);
|
fclose (fp_al);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
|
fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
|
||||||
|
if (fname_wr)
|
||||||
|
remove (fname_wr); /* no broken output file shall remain behind */
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,20 +151,16 @@ int main(int argc, char *argv[])
|
|||||||
* usage
|
* usage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void usage()
|
void usage ()
|
||||||
{
|
{
|
||||||
fprintf (stderr, "PNM2PNG\n");
|
fprintf (stderr, "PNM2PNG\n");
|
||||||
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
fprintf (stderr, " by Willem van Schaik, 1999\n");
|
||||||
#ifdef __TURBOC__
|
|
||||||
fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
|
|
||||||
#else
|
|
||||||
fprintf (stderr, " for Linux (and Unix) compilers\n");
|
|
||||||
#endif
|
|
||||||
fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n");
|
fprintf (stderr, "Usage: pnm2png [options] <file>.<pnm> [<file>.png]\n");
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,102 +168,101 @@ 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;
|
||||||
png_info *info_ptr = NULL;
|
png_info *info_ptr;
|
||||||
png_byte *png_pixels = NULL;
|
BOOL ret;
|
||||||
png_byte **row_pointers = NULL;
|
|
||||||
png_byte *pix_ptr = NULL;
|
|
||||||
png_uint_32 row_bytes;
|
|
||||||
|
|
||||||
char type_token[16];
|
/* initialize the libpng context for writing to png_file */
|
||||||
char width_token[16];
|
|
||||||
char height_token[16];
|
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL),
|
||||||
char maxval_token[16];
|
NULL, NULL, NULL);
|
||||||
|
if (!png_ptr)
|
||||||
|
return FALSE; /* out of memory */
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct (png_ptr);
|
||||||
|
if (!info_ptr)
|
||||||
|
{
|
||||||
|
png_destroy_write_struct (&png_ptr, NULL);
|
||||||
|
return FALSE; /* out of memory */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp (png_jmpbuf (png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||||
|
return FALSE; /* generic libpng error */
|
||||||
|
}
|
||||||
|
|
||||||
|
png_init_io (png_ptr, png_file);
|
||||||
|
|
||||||
|
/* do the actual conversion */
|
||||||
|
ret = do_pnm2png (png_ptr, info_ptr, pnm_file, alpha_file, interlace, alpha);
|
||||||
|
|
||||||
|
/* clean up the libpng structures and their internally-managed data */
|
||||||
|
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* do_pnm2png - does the conversion in a fully-initialized libpng context
|
||||||
|
*/
|
||||||
|
|
||||||
|
BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
|
||||||
|
FILE *pnm_file, FILE *alpha_file,
|
||||||
|
BOOL interlace, BOOL alpha)
|
||||||
|
{
|
||||||
|
png_byte **row_pointers;
|
||||||
|
png_byte *pix_ptr;
|
||||||
|
int bit_depth;
|
||||||
int color_type;
|
int color_type;
|
||||||
unsigned long ul_width=0, ul_alpha_width=0;
|
|
||||||
unsigned long ul_height=0, ul_alpha_height=0;
|
|
||||||
unsigned long ul_maxval=0;
|
|
||||||
png_uint_32 width, alpha_width;
|
|
||||||
png_uint_32 height, alpha_height;
|
|
||||||
png_uint_32 maxval;
|
|
||||||
int bit_depth = 0;
|
|
||||||
int channels;
|
int channels;
|
||||||
int alpha_depth = 0;
|
char magic_token[4];
|
||||||
int alpha_present;
|
BOOL raw;
|
||||||
int row, col;
|
png_uint_32 width, height, maxval;
|
||||||
BOOL raw, alpha_raw = FALSE;
|
png_uint_32 row_bytes;
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
png_uint_32 row, col;
|
||||||
|
png_uint_32 val16, i;
|
||||||
|
png_uint_32 alpha_width = 0, alpha_height = 0;
|
||||||
|
int alpha_depth = 0, alpha_present = 0;
|
||||||
|
BOOL alpha_raw = FALSE;
|
||||||
BOOL packed_bitmap = FALSE;
|
BOOL packed_bitmap = FALSE;
|
||||||
#endif
|
|
||||||
png_uint_32 tmp16;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* read header of PNM file */
|
/* read header of PNM file */
|
||||||
|
|
||||||
get_token(pnm_file, type_token);
|
if (fscan_pnm_magic (pnm_file, magic_token, sizeof (magic_token)) != 1)
|
||||||
if (type_token[0] != 'P')
|
return FALSE; /* not a PNM file */
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
|
||||||
{
|
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
|
||||||
raw = (type_token[1] == '4');
|
|
||||||
color_type = PNG_COLOR_TYPE_GRAY;
|
|
||||||
get_token(pnm_file, width_token);
|
|
||||||
sscanf (width_token, "%lu", &ul_width);
|
|
||||||
width = (png_uint_32) ul_width;
|
|
||||||
get_token(pnm_file, height_token);
|
|
||||||
sscanf (height_token, "%lu", &ul_height);
|
|
||||||
height = (png_uint_32) ul_height;
|
|
||||||
bit_depth = 1;
|
|
||||||
packed_bitmap = TRUE;
|
|
||||||
#else
|
|
||||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
|
||||||
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
|
||||||
{
|
|
||||||
raw = (type_token[1] == '5');
|
|
||||||
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;
|
|
||||||
get_token(pnm_file, maxval_token);
|
|
||||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
|
||||||
maxval = (png_uint_32) ul_maxval;
|
|
||||||
|
|
||||||
if (maxval <= 1)
|
if ((magic_token[1] == '1') || (magic_token[1] == '4'))
|
||||||
bit_depth = 1;
|
|
||||||
else if (maxval <= 3)
|
|
||||||
bit_depth = 2;
|
|
||||||
else if (maxval <= 15)
|
|
||||||
bit_depth = 4;
|
|
||||||
else if (maxval <= 255)
|
|
||||||
bit_depth = 8;
|
|
||||||
else /* if (maxval <= 65535) */
|
|
||||||
bit_depth = 16;
|
|
||||||
}
|
|
||||||
else if ((type_token[1] == '3') || (type_token[1] == '6'))
|
|
||||||
{
|
{
|
||||||
raw = (type_token[1] == '6');
|
if ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
|
||||||
color_type = PNG_COLOR_TYPE_RGB;
|
(fscan_pnm_uint_32 (pnm_file, &height) != 1))
|
||||||
get_token(pnm_file, width_token);
|
return FALSE; /* bad PBM file header */
|
||||||
sscanf (width_token, "%lu", &ul_width);
|
} else if ((magic_token[1] == '2') || (magic_token[1] == '5') ||
|
||||||
width = (png_uint_32) ul_width;
|
(magic_token[1] == '3') || (magic_token[1] == '6'))
|
||||||
get_token(pnm_file, height_token);
|
{
|
||||||
sscanf (height_token, "%lu", &ul_height);
|
if ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
|
||||||
height = (png_uint_32) ul_height;
|
(fscan_pnm_uint_32 (pnm_file, &height) != 1) ||
|
||||||
get_token(pnm_file, maxval_token);
|
(fscan_pnm_uint_32 (pnm_file, &maxval) != 1))
|
||||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
return FALSE; /* bad PGM/PPM file header */
|
||||||
maxval = (png_uint_32) ul_maxval;
|
}
|
||||||
if (maxval <= 1)
|
|
||||||
|
if ((magic_token[1] == '1') || (magic_token[1] == '4'))
|
||||||
|
{
|
||||||
|
raw = (magic_token[1] == '4');
|
||||||
|
bit_depth = 1;
|
||||||
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
packed_bitmap = TRUE;
|
||||||
|
}
|
||||||
|
else if ((magic_token[1] == '2') || (magic_token[1] == '5'))
|
||||||
|
{
|
||||||
|
raw = (magic_token[1] == '5');
|
||||||
|
color_type = PNG_COLOR_TYPE_GRAY;
|
||||||
|
if (maxval == 0)
|
||||||
|
return FALSE;
|
||||||
|
else if (maxval == 1)
|
||||||
bit_depth = 1;
|
bit_depth = 1;
|
||||||
else if (maxval <= 3)
|
else if (maxval <= 3)
|
||||||
bit_depth = 2;
|
bit_depth = 2;
|
||||||
@@ -287,8 +270,34 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
bit_depth = 4;
|
bit_depth = 4;
|
||||||
else if (maxval <= 255)
|
else if (maxval <= 255)
|
||||||
bit_depth = 8;
|
bit_depth = 8;
|
||||||
else /* if (maxval <= 65535) */
|
else if (maxval <= 65535U)
|
||||||
bit_depth = 16;
|
bit_depth = 16;
|
||||||
|
else /* maxval > 65535U */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if ((magic_token[1] == '3') || (magic_token[1] == '6'))
|
||||||
|
{
|
||||||
|
raw = (magic_token[1] == '6');
|
||||||
|
color_type = PNG_COLOR_TYPE_RGB;
|
||||||
|
if (maxval == 0)
|
||||||
|
return FALSE;
|
||||||
|
else if (maxval == 1)
|
||||||
|
bit_depth = 1;
|
||||||
|
else if (maxval <= 3)
|
||||||
|
bit_depth = 2;
|
||||||
|
else if (maxval <= 15)
|
||||||
|
bit_depth = 4;
|
||||||
|
else if (maxval <= 255)
|
||||||
|
bit_depth = 8;
|
||||||
|
else if (maxval <= 65535U)
|
||||||
|
bit_depth = 16;
|
||||||
|
else /* maxval > 65535U */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (magic_token[1] == '7')
|
||||||
|
{
|
||||||
|
fprintf (stderr, "PNM2PNG can't read PAM (P7) files\n");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -299,49 +308,36 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
|
|
||||||
if (alpha)
|
if (alpha)
|
||||||
{
|
{
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
if ((fscan_pnm_magic (alpha_file, magic_token, sizeof (magic_token)) != 1)
|
||||||
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
|| ((magic_token[1] != '2') && (magic_token[1] != '5')))
|
||||||
if (color_type == PNG_COLOR_TYPE_RGB)
|
return FALSE; /* not a PGM file */
|
||||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
|
||||||
|
|
||||||
get_token(alpha_file, type_token);
|
if ((fscan_pnm_uint_32 (alpha_file, &alpha_width) != 1) ||
|
||||||
if (type_token[0] != 'P')
|
(fscan_pnm_uint_32 (alpha_file, &alpha_height) != 1) ||
|
||||||
{
|
(fscan_pnm_uint_32 (alpha_file, &maxval) != 1))
|
||||||
|
return FALSE; /* bad PGM file header */
|
||||||
|
|
||||||
|
if ((alpha_width != width) || (alpha_height != height))
|
||||||
|
return FALSE; /* mismatched PGM dimensions */
|
||||||
|
|
||||||
|
alpha_raw = (magic_token[1] == '5');
|
||||||
|
color_type |= PNG_COLOR_MASK_ALPHA;
|
||||||
|
if (maxval == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
else if (maxval == 1)
|
||||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
alpha_depth = 1;
|
||||||
{
|
else if (maxval <= 3)
|
||||||
alpha_raw = (type_token[1] == '5');
|
alpha_depth = 2;
|
||||||
get_token(alpha_file, width_token);
|
else if (maxval <= 15)
|
||||||
sscanf (width_token, "%lu", &ul_alpha_width);
|
alpha_depth = 4;
|
||||||
alpha_width=(png_uint_32) ul_alpha_width;
|
else if (maxval <= 255)
|
||||||
if (alpha_width != width)
|
alpha_depth = 8;
|
||||||
return FALSE;
|
else if (maxval <= 65535U)
|
||||||
get_token(alpha_file, height_token);
|
alpha_depth = 16;
|
||||||
sscanf (height_token, "%lu", &ul_alpha_height);
|
else /* maxval > 65535U */
|
||||||
alpha_height = (png_uint_32) ul_alpha_height;
|
return FALSE;
|
||||||
if (alpha_height != height)
|
if (alpha_depth != bit_depth)
|
||||||
return FALSE;
|
|
||||||
get_token(alpha_file, maxval_token);
|
|
||||||
sscanf (maxval_token, "%lu", &ul_maxval);
|
|
||||||
maxval = (png_uint_32) ul_maxval;
|
|
||||||
if (maxval <= 1)
|
|
||||||
alpha_depth = 1;
|
|
||||||
else if (maxval <= 3)
|
|
||||||
alpha_depth = 2;
|
|
||||||
else if (maxval <= 15)
|
|
||||||
alpha_depth = 4;
|
|
||||||
else if (maxval <= 255)
|
|
||||||
alpha_depth = 8;
|
|
||||||
else /* if (maxval <= 65535) */
|
|
||||||
alpha_depth = 16;
|
|
||||||
if (alpha_depth != bit_depth)
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
} /* end if alpha */
|
} /* end if alpha */
|
||||||
|
|
||||||
/* calculate the number of channels and store alpha-presence */
|
/* calculate the number of channels and store alpha-presence */
|
||||||
@@ -354,196 +350,258 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
|||||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||||
channels = 4;
|
channels = 4;
|
||||||
else
|
else
|
||||||
channels = 0; /* should not happen */
|
return FALSE; /* NOTREACHED */
|
||||||
|
|
||||||
alpha_present = (channels - 1) % 2;
|
alpha_present = (channels - 1) % 2;
|
||||||
|
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
|
||||||
if (packed_bitmap)
|
if (packed_bitmap)
|
||||||
|
{
|
||||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
{
|
||||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||||
|
}
|
||||||
|
|
||||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
if ((row_bytes == 0) ||
|
||||||
|
((size_t) height > (size_t) (-1) / (size_t) row_bytes))
|
||||||
|
{
|
||||||
|
/* too big */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* read data from PNM file */
|
/* allocate the rows using the same memory layout as libpng, and transfer
|
||||||
pix_ptr = png_pixels;
|
* their ownership to libpng, with the responsibility to clean everything up;
|
||||||
|
* please note the use of png_calloc instead of png_malloc */
|
||||||
|
row_pointers = (png_byte **)
|
||||||
|
png_calloc (png_ptr, height * sizeof (png_byte *));
|
||||||
|
png_set_rows (png_ptr, info_ptr, row_pointers);
|
||||||
|
png_data_freer (png_ptr, info_ptr, PNG_DESTROY_WILL_FREE_DATA, PNG_FREE_ALL);
|
||||||
|
for (row = 0; row < height; row++)
|
||||||
|
{
|
||||||
|
/* the individual rows should only be allocated after all the previous
|
||||||
|
* steps completed successfully, because libpng must handle correctly
|
||||||
|
* any image allocation left incomplete after an out-of-memory error */
|
||||||
|
row_pointers[row] = (png_byte *) png_malloc (png_ptr, row_bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read the data from PNM file */
|
||||||
|
|
||||||
for (row = 0; row < height; row++)
|
for (row = 0; row < height; row++)
|
||||||
{
|
{
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
pix_ptr = row_pointers[row];
|
||||||
if (packed_bitmap) {
|
if (packed_bitmap)
|
||||||
|
{
|
||||||
for (i = 0; i < row_bytes; i++)
|
for (i = 0; i < row_bytes; i++)
|
||||||
|
{
|
||||||
/* png supports this format natively so no conversion is needed */
|
/* png supports this format natively so no conversion is needed */
|
||||||
*pix_ptr++ = get_data (pnm_file, 8);
|
*pix_ptr++ = get_pnm_data (pnm_file, 8);
|
||||||
} else
|
}
|
||||||
#endif
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
for (col = 0; col < width; col++)
|
for (col = 0; col < width; col++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < (channels - alpha_present); i++)
|
for (i = 0; i < (png_uint_32) (channels - alpha_present); i++)
|
||||||
{
|
{
|
||||||
if (raw)
|
if (raw)
|
||||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
{
|
||||||
|
*pix_ptr++ = get_pnm_data (pnm_file, bit_depth);
|
||||||
|
if (bit_depth == 16)
|
||||||
|
*pix_ptr++ = get_pnm_data (pnm_file, bit_depth);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (bit_depth <= 8)
|
if (bit_depth <= 8)
|
||||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
{
|
||||||
|
*pix_ptr++ = get_pnm_value (pnm_file, bit_depth);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp16 = get_value (pnm_file, bit_depth);
|
val16 = get_pnm_value (pnm_file, bit_depth);
|
||||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
*pix_ptr = (png_byte) ((val16 >> 8) & 0xFF);
|
||||||
pix_ptr++;
|
pix_ptr++;
|
||||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
*pix_ptr = (png_byte) (val16 & 0xFF);
|
||||||
pix_ptr++;
|
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_pnm_data (alpha_file, alpha_depth);
|
||||||
|
if (alpha_depth == 16)
|
||||||
|
*pix_ptr++ = get_pnm_data (alpha_file, alpha_depth);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (alpha_depth <= 8)
|
if (alpha_depth <= 8)
|
||||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
{
|
||||||
|
*pix_ptr++ = get_pnm_value (alpha_file, bit_depth);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp16 = get_value (alpha_file, bit_depth);
|
val16 = get_pnm_value (alpha_file, bit_depth);
|
||||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
*pix_ptr++ = (png_byte) ((val16 >> 8) & 0xFF);
|
||||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
*pix_ptr++ = (png_byte) (val16 & 0xFF);
|
||||||
}
|
}
|
||||||
} /* if alpha */
|
}
|
||||||
} /* if packed_bitmap */
|
} /* end if alpha */
|
||||||
|
} /* end if packed_bitmap */
|
||||||
} /* end for col */
|
} /* end for col */
|
||||||
} /* end for row */
|
} /* end for row */
|
||||||
|
|
||||||
/* prepare the standard PNG structures */
|
/* we're going to write more or less the same PNG as the input file */
|
||||||
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
|
||||||
if (!png_ptr)
|
(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
|
||||||
{
|
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
info_ptr = png_create_info_struct (png_ptr);
|
|
||||||
if (!info_ptr)
|
|
||||||
{
|
|
||||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
|
||||||
if (packed_bitmap == TRUE)
|
if (packed_bitmap == TRUE)
|
||||||
{
|
{
|
||||||
png_set_packing (png_ptr);
|
png_set_packing (png_ptr);
|
||||||
png_set_invert_mono (png_ptr);
|
png_set_invert_mono (png_ptr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
|
||||||
if (setjmp (png_jmpbuf(png_ptr)))
|
|
||||||
{
|
|
||||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the png structure */
|
|
||||||
png_init_io (png_ptr, png_file);
|
|
||||||
|
|
||||||
/* we're going to write more or less the same PNG as the input file */
|
|
||||||
png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
|
|
||||||
(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
|
|
||||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
|
||||||
|
|
||||||
/* write the file header information */
|
/* write the file header information */
|
||||||
png_write_info (png_ptr, info_ptr);
|
png_write_info (png_ptr, info_ptr);
|
||||||
|
|
||||||
/* if needed we will allocate memory for an new array of row-pointers */
|
|
||||||
if (row_pointers == (unsigned char**) NULL)
|
|
||||||
{
|
|
||||||
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
|
|
||||||
{
|
|
||||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the individual row_pointers to point at the correct offsets */
|
|
||||||
for (i = 0; i < (height); i++)
|
|
||||||
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 */
|
|
||||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
|
||||||
|
|
||||||
if (row_pointers != (unsigned char**) NULL)
|
|
||||||
free (row_pointers);
|
|
||||||
if (png_pixels != (unsigned char*) NULL)
|
|
||||||
free (png_pixels);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} /* end of pnm2png */
|
} /* end of pnm2png */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_token() - gets the first string after whitespace
|
* fscan_pnm_magic - like fscan_pnm_token below, but expects the magic string
|
||||||
|
* to start immediately, without any comment or whitespace,
|
||||||
|
* and to match the regex /^P[1-9]$/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void get_token(FILE *pnm_file, char *token)
|
int fscan_pnm_magic (FILE *pnm_file, char *magic_buf, size_t magic_buf_size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int ret;
|
||||||
|
|
||||||
|
ret = fgetc (pnm_file);
|
||||||
|
if (ret == EOF) return 0;
|
||||||
|
ungetc (ret, pnm_file);
|
||||||
|
if (ret != 'P') return 0;
|
||||||
|
|
||||||
|
/* the string buffer must be at least four bytes long, i.e., the capacity
|
||||||
|
* required for strings of at least three characters long, i.e., the minimum
|
||||||
|
* required for ensuring that our magic string is exactly two characters long
|
||||||
|
*/
|
||||||
|
if (magic_buf_size < 4) return -1;
|
||||||
|
|
||||||
|
ret = fscan_pnm_token (pnm_file, magic_buf, magic_buf_size);
|
||||||
|
if (ret < 1) return ret;
|
||||||
|
|
||||||
|
if ((magic_buf[1] < '1') || (magic_buf[1] > '9')) return 0;
|
||||||
|
if (magic_buf[2] != '\0') return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* fscan_pnm_token - extracts the first string token after whitespace,
|
||||||
|
* and (like fscanf) returns the number of successful
|
||||||
|
* extractions, which can be either 0 or 1
|
||||||
|
*/
|
||||||
|
|
||||||
|
int fscan_pnm_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* remove white-space and comment lines */
|
/* remove white-space and comment lines */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = fgetc(pnm_file);
|
ret = fgetc (pnm_file);
|
||||||
if (ret == '#') {
|
if (ret == '#')
|
||||||
|
{
|
||||||
/* the rest of this line is a comment */
|
/* the rest of this line is a comment */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = fgetc(pnm_file);
|
ret = fgetc (pnm_file);
|
||||||
}
|
}
|
||||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||||
}
|
}
|
||||||
if (ret == EOF) break;
|
if (ret == EOF) break;
|
||||||
token[i] = (unsigned char) ret;
|
token_buf[i] = (char) ret;
|
||||||
}
|
}
|
||||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
while ((ret == '\n') || (ret == '\r') || (ret == ' '));
|
||||||
|
|
||||||
/* read string */
|
/* read string */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = fgetc(pnm_file);
|
ret = fgetc (pnm_file);
|
||||||
if (ret == EOF) break;
|
if (ret == EOF) break;
|
||||||
i++;
|
if (ret == '0')
|
||||||
token[i] = (unsigned char) ret;
|
{
|
||||||
|
/* avoid storing more than one leading '0' in the token buffer,
|
||||||
|
* to ensure that all valid (in-range) numeric inputs can fit in. */
|
||||||
|
if ((i == 0) && (token_buf[i] == '0')) continue;
|
||||||
|
}
|
||||||
|
if (++i == token_buf_size - 1) break;
|
||||||
|
token_buf[i] = (char) ret;
|
||||||
}
|
}
|
||||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
while ((ret != '\n') && (ret != '\r') && (ret != ' '));
|
||||||
|
|
||||||
token[i] = '\0';
|
token_buf[i] = '\0';
|
||||||
|
return (i > 0) ? 1 : 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_data() - takes first byte and converts into next pixel value,
|
* fscan_pnm_uint_32 - like fscan_token above, but expects the extracted token
|
||||||
* taking as much bits as defined by bit-depth and
|
* to be numeric, and converts it to an unsigned 32-bit int
|
||||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
png_uint_32 get_data (FILE *pnm_file, int depth)
|
int fscan_pnm_uint_32 (FILE *pnm_file, png_uint_32 *num_ptr)
|
||||||
|
{
|
||||||
|
char token[16];
|
||||||
|
unsigned long token_value;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = fscan_pnm_token (pnm_file, token, sizeof (token));
|
||||||
|
if (ret < 1) return ret;
|
||||||
|
|
||||||
|
if ((token[0] < '0') && (token[0] > '9'))
|
||||||
|
return 0; /* the token starts with junk, or a +/- sign, which is invalid */
|
||||||
|
|
||||||
|
ret = sscanf (token, "%lu%*c", &token_value);
|
||||||
|
if (ret != 1)
|
||||||
|
return 0; /* the token ends with junk */
|
||||||
|
|
||||||
|
*num_ptr = (png_uint_32) token_value;
|
||||||
|
|
||||||
|
#if ULONG_MAX > 0xFFFFFFFFUL
|
||||||
|
/* saturate the converted number, following the fscanf convention */
|
||||||
|
if (token_value > 0xFFFFFFFFUL)
|
||||||
|
*num_ptr = 0xFFFFFFFFUL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get_pnm_data - takes first byte and converts into next pixel value,
|
||||||
|
* taking as many bits as defined by bit-depth and
|
||||||
|
* using the bit-depth to fill up a byte (0x0A -> 0xAA)
|
||||||
|
*/
|
||||||
|
|
||||||
|
png_uint_32 get_pnm_data (FILE *pnm_file, int depth)
|
||||||
{
|
{
|
||||||
static int bits_left = 0;
|
static int bits_left = 0;
|
||||||
static int old_value = 0;
|
static int old_value = 0;
|
||||||
static int mask = 0;
|
static int mask = 0;
|
||||||
int i;
|
|
||||||
png_uint_32 ret_value;
|
png_uint_32 ret_value;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
for (i = 0; i < depth; i++)
|
for (i = 0; i < depth; i++)
|
||||||
@@ -551,7 +609,11 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
|
|||||||
|
|
||||||
if (bits_left <= 0)
|
if (bits_left <= 0)
|
||||||
{
|
{
|
||||||
|
/* FIXME:
|
||||||
|
* signal the premature end of file, instead of pretending to read zeroes
|
||||||
|
*/
|
||||||
old_value = fgetc (pnm_file);
|
old_value = fgetc (pnm_file);
|
||||||
|
if (old_value == EOF) return 0;
|
||||||
bits_left = 8;
|
bits_left = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,25 +628,28 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_value() - takes first (numeric) string and converts into number,
|
* get_pnm_value - takes first (numeric) string and converts into number,
|
||||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
* using the bit-depth to fill up a byte (0x0A -> 0xAA)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
png_uint_32 get_value (FILE *pnm_file, int depth)
|
png_uint_32 get_pnm_value (FILE *pnm_file, int depth)
|
||||||
{
|
{
|
||||||
static png_uint_32 mask = 0;
|
static png_uint_32 mask = 0;
|
||||||
png_byte token[16];
|
|
||||||
unsigned long ul_ret_value;
|
|
||||||
png_uint_32 ret_value;
|
png_uint_32 ret_value;
|
||||||
int i = 0;
|
int i;
|
||||||
|
|
||||||
if (mask == 0)
|
if (mask == 0)
|
||||||
for (i = 0; i < depth; i++)
|
for (i = 0; i < depth; i++)
|
||||||
mask = (mask << 1) | 0x01;
|
mask = (mask << 1) | 0x01;
|
||||||
|
|
||||||
get_token (pnm_file, (char *) token);
|
if (fscan_pnm_uint_32 (pnm_file, &ret_value) != 1)
|
||||||
sscanf ((const char *) token, "%lu", &ul_ret_value);
|
{
|
||||||
ret_value = (png_uint_32) ul_ret_value;
|
/* FIXME:
|
||||||
|
* signal the invalid numeric tokens or the premature end of file,
|
||||||
|
* instead of pretending to read zeroes
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret_value &= mask;
|
ret_value &= mask;
|
||||||
|
|
||||||
@@ -596,4 +661,3 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* end of source */
|
/* end of source */
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm
|
|||||||
REM -- full-color
|
REM -- full-color
|
||||||
png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm
|
png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.ppm
|
||||||
png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm
|
png2pnm.exe -noraw ..\pngsuite\basn2c16.png basn2c16.ppm
|
||||||
REM -- palletted
|
REM -- paletted
|
||||||
png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm
|
png2pnm.exe -noraw ..\pngsuite\basn3p01.png basn3p01.ppm
|
||||||
png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm
|
png2pnm.exe -noraw ..\pngsuite\basn3p02.png basn3p02.ppm
|
||||||
png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm
|
png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm
|
||||||
@@ -27,7 +27,7 @@ png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm
|
|||||||
REM -- full-color
|
REM -- full-color
|
||||||
png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm
|
png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.ppm
|
||||||
png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm
|
png2pnm.exe -raw ..\pngsuite\basn2c16.png rawn2c16.ppm
|
||||||
REM -- palletted
|
REM -- paletted
|
||||||
png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm
|
png2pnm.exe -raw ..\pngsuite\basn3p01.png rawn3p01.ppm
|
||||||
png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm
|
png2pnm.exe -raw ..\pngsuite\basn3p02.png rawn3p02.ppm
|
||||||
png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm
|
png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm
|
||||||
4
contrib/pngminus/png2pnm.sh → contrib/pngminus/test_png2pnm.sh
Normal file → Executable file
4
contrib/pngminus/png2pnm.sh → contrib/pngminus/test_png2pnm.sh
Normal file → Executable file
@@ -8,7 +8,7 @@
|
|||||||
# -- full-color
|
# -- full-color
|
||||||
./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm
|
./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm
|
||||||
./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm
|
./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm
|
||||||
# -- palletted
|
# -- paletted
|
||||||
./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm
|
./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm
|
||||||
./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm
|
./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm
|
||||||
./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm
|
./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
# -- full-color
|
# -- full-color
|
||||||
./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm
|
./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm
|
||||||
./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm
|
./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm
|
||||||
# -- palletted
|
# -- paletted
|
||||||
./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm
|
./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm
|
||||||
./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm
|
./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm
|
||||||
./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm
|
./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm
|
||||||
2
contrib/pngminus/pngminus.bat → contrib/pngminus/test_pngminus.bat
Normal file → Executable file
2
contrib/pngminus/pngminus.bat → contrib/pngminus/test_pngminus.bat
Normal file → Executable file
@@ -1,4 +1,4 @@
|
|||||||
make -f makefile.tc3
|
make
|
||||||
call png2pnm.bat
|
call png2pnm.bat
|
||||||
call pnm2png.bat
|
call pnm2png.bat
|
||||||
|
|
||||||
2
contrib/pngminus/pngminus.sh → contrib/pngminus/test_pngminus.sh
Normal file → Executable file
2
contrib/pngminus/pngminus.sh → contrib/pngminus/test_pngminus.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
make -f makefile.std
|
make
|
||||||
sh png2pnm.sh
|
sh png2pnm.sh
|
||||||
sh pnm2png.sh
|
sh pnm2png.sh
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ pnm2png.exe basn0g16.pgm basn0g16.png
|
|||||||
REM -- full-color
|
REM -- full-color
|
||||||
pnm2png.exe basn2c08.ppm basn2c08.png
|
pnm2png.exe basn2c08.ppm basn2c08.png
|
||||||
pnm2png.exe basn2c16.ppm basn2c16.png
|
pnm2png.exe basn2c16.ppm basn2c16.png
|
||||||
REM -- palletted
|
REM -- paletted
|
||||||
pnm2png.exe basn3p01.ppm basn3p01.png
|
pnm2png.exe basn3p01.ppm basn3p01.png
|
||||||
pnm2png.exe basn3p02.ppm basn3p02.png
|
pnm2png.exe basn3p02.ppm basn3p02.png
|
||||||
pnm2png.exe basn3p04.ppm basn3p04.png
|
pnm2png.exe basn3p04.ppm basn3p04.png
|
||||||
@@ -27,7 +27,7 @@ pnm2png.exe rawn0g16.pgm rawn0g16.png
|
|||||||
REM -- full-color
|
REM -- full-color
|
||||||
pnm2png.exe rawn2c08.ppm rawn2c08.png
|
pnm2png.exe rawn2c08.ppm rawn2c08.png
|
||||||
pnm2png.exe rawn2c16.ppm rawn2c16.png
|
pnm2png.exe rawn2c16.ppm rawn2c16.png
|
||||||
REM -- palletted
|
REM -- paletted
|
||||||
pnm2png.exe rawn3p01.ppm rawn3p01.png
|
pnm2png.exe rawn3p01.ppm rawn3p01.png
|
||||||
pnm2png.exe rawn3p02.ppm rawn3p02.png
|
pnm2png.exe rawn3p02.ppm rawn3p02.png
|
||||||
pnm2png.exe rawn3p04.ppm rawn3p04.png
|
pnm2png.exe rawn3p04.ppm rawn3p04.png
|
||||||
4
contrib/pngminus/pnm2png.sh → contrib/pngminus/test_pnm2png.sh
Normal file → Executable file
4
contrib/pngminus/pnm2png.sh → contrib/pngminus/test_pnm2png.sh
Normal file → Executable file
@@ -8,7 +8,7 @@
|
|||||||
# -- full-color
|
# -- full-color
|
||||||
./pnm2png basn2c08.ppm basn2c08.png
|
./pnm2png basn2c08.ppm basn2c08.png
|
||||||
./pnm2png basn2c16.ppm basn2c16.png
|
./pnm2png basn2c16.ppm basn2c16.png
|
||||||
# -- palletted
|
# -- paletted
|
||||||
./pnm2png basn3p01.ppm basn3p01.png
|
./pnm2png basn3p01.ppm basn3p01.png
|
||||||
./pnm2png basn3p02.ppm basn3p02.png
|
./pnm2png basn3p02.ppm basn3p02.png
|
||||||
./pnm2png basn3p04.ppm basn3p04.png
|
./pnm2png basn3p04.ppm basn3p04.png
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
# -- full-color
|
# -- full-color
|
||||||
./pnm2png rawn2c08.ppm rawn2c08.png
|
./pnm2png rawn2c08.ppm rawn2c08.png
|
||||||
./pnm2png rawn2c16.ppm rawn2c16.png
|
./pnm2png rawn2c16.ppm rawn2c16.png
|
||||||
# -- palletted
|
# -- paletted
|
||||||
./pnm2png rawn3p01.ppm rawn3p01.png
|
./pnm2png rawn3p01.ppm rawn3p01.png
|
||||||
./pnm2png rawn3p02.ppm rawn3p02.png
|
./pnm2png rawn3p02.ppm rawn3p02.png
|
||||||
./pnm2png rawn3p04.ppm rawn3p04.png
|
./pnm2png rawn3p04.ppm rawn3p04.png
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
pngsuite
|
pngsuite
|
||||||
--------
|
--------
|
||||||
(c) Willem van Schaik, 1999, 2011, 2012
|
Copyright (c) Willem van Schaik, 1999, 2011, 2012
|
||||||
Two images are by Glenn Randers-Pehrson, 2012
|
Two images (ftbbn0g01.png and ftbbn0g02.png) are by Glenn Randers-Pehrson, 2012
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute these images for any
|
Permission to use, copy, modify, and distribute these images for any
|
||||||
purpose and without fee is hereby granted.
|
purpose and without fee is hereby granted.
|
||||||
@@ -16,6 +16,8 @@ chunks, etc.
|
|||||||
The "ft*.png" images are "free/libre" replacements for the transparent
|
The "ft*.png" images are "free/libre" replacements for the transparent
|
||||||
corresponding t*.png images in the PngSuite.
|
corresponding t*.png images in the PngSuite.
|
||||||
|
|
||||||
|
The "i*.png" images are the same images, but interlaced.
|
||||||
|
|
||||||
The images in this directory represent the basic PNG color-types:
|
The images in this directory represent the basic PNG color-types:
|
||||||
grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
|
grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
|
||||||
(1-8 bit) and grayscale or color images with alpha channel. You
|
(1-8 bit) and grayscale or color images with alpha channel. You
|
||||||
@@ -101,5 +103,5 @@ Testing basn6a16.png: PASS (1072 zero samples)
|
|||||||
libpng passes test
|
libpng passes test
|
||||||
|
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
<willem@schaik.com>
|
<willem at schaik.com>
|
||||||
October 1999
|
October 1999
|
||||||
|
|||||||
9
contrib/pngsuite/bad_interlace_conversions.txt
Normal file
9
contrib/pngsuite/bad_interlace_conversions.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
basn0g01.png
|
||||||
|
basn0g02.png
|
||||||
|
basn0g04.png
|
||||||
|
basn3p01.png
|
||||||
|
basn3p02.png
|
||||||
|
basn3p04.png
|
||||||
|
ftbbn0g01.png
|
||||||
|
ftbbn0g02.png
|
||||||
|
ftbbn0g04.png
|
||||||
BIN
contrib/pngsuite/ibasn0g08.png
Normal file
BIN
contrib/pngsuite/ibasn0g08.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 237 B |
BIN
contrib/pngsuite/ibasn0g16.png
Normal file
BIN
contrib/pngsuite/ibasn0g16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
BIN
contrib/pngsuite/ibasn2c08.png
Normal file
BIN
contrib/pngsuite/ibasn2c08.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 299 B |
BIN
contrib/pngsuite/ibasn2c16.png
Normal file
BIN
contrib/pngsuite/ibasn2c16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 558 B |
BIN
contrib/pngsuite/ibasn3p08.png
Normal file
BIN
contrib/pngsuite/ibasn3p08.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
contrib/pngsuite/ibasn4a08.png
Normal file
BIN
contrib/pngsuite/ibasn4a08.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 198 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user