mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
1239 Commits
v1.6.32rc0
...
v1.6.43
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed217e3e60 | ||
|
|
e1fa61daa8 | ||
|
|
80691b9da2 | ||
|
|
890231026d | ||
|
|
3b9a73ed3e | ||
|
|
e05ebfba7c | ||
|
|
ec2e58c16a | ||
|
|
7b888092b9 | ||
|
|
14a348ddc8 | ||
|
|
29e31f622f | ||
|
|
d165a20ae4 | ||
|
|
aa95dee697 | ||
|
|
e7ba9c0dfc | ||
|
|
6b5a2da072 | ||
|
|
dddaf0c625 | ||
|
|
72c4520d3c | ||
|
|
0fa3c0f698 | ||
|
|
4191872d0d | ||
|
|
42c8fcbff9 | ||
|
|
f74d5ecce8 | ||
|
|
fb65436e06 | ||
|
|
63c715b7d7 | ||
|
|
1cdde11877 | ||
|
|
8120345c89 | ||
|
|
7a6148290f | ||
|
|
c6ee62af2e | ||
|
|
46b79d4716 | ||
|
|
49eeb1f8ba | ||
|
|
366c9c6a24 | ||
|
|
920db2ecc0 | ||
|
|
cc8006c48d | ||
|
|
aa9023bbd0 | ||
|
|
c9ac5bdba4 | ||
|
|
ab6d97b7c8 | ||
|
|
9138be341b | ||
|
|
ce1f1f001e | ||
|
|
805ed7a2d4 | ||
|
|
2aebfb4aa9 | ||
|
|
7f1f960d4f | ||
|
|
59a68c83f0 | ||
|
|
3bd304e5f4 | ||
|
|
f0c578748b | ||
|
|
2d7da9db8a | ||
|
|
4356cb0709 | ||
|
|
35d9f5ea52 | ||
|
|
31439b6b8d | ||
|
|
537c66660e | ||
|
|
ac944e2b36 | ||
|
|
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 | ||
|
|
fbff8986e7 | ||
|
|
8c552ddf5b | ||
|
|
b363e01e6b | ||
|
|
0a181e1665 | ||
|
|
e4b59e5583 | ||
|
|
35cbe7640b | ||
|
|
eb5cdf0c64 | ||
|
|
0c29ab2b31 | ||
|
|
5a8b04137f | ||
|
|
87c14c528a | ||
|
|
5756fcab2f | ||
|
|
047737496a | ||
|
|
b9c62013ef | ||
|
|
287fb89248 | ||
|
|
2b667e4923 | ||
|
|
070a616b82 | ||
|
|
da7a1e79af | ||
|
|
eed640dbe8 | ||
|
|
d55c4f32fc | ||
|
|
238e7646a8 | ||
|
|
d21eae44e7 | ||
|
|
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 |
79
.appveyor.yml
Normal file
79
.appveyor.yml
Normal file
@@ -0,0 +1,79 @@
|
||||
version: 1.6.x-{build}
|
||||
|
||||
branches:
|
||||
except:
|
||||
- /libpng[0-1][0-7]/
|
||||
- /v[0-1][.][0-7][.][0-9]+/
|
||||
|
||||
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
|
||||
43
.editorconfig
Normal file
43
.editorconfig
Normal file
@@ -0,0 +1,43 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.txt]
|
||||
indent_style = space
|
||||
|
||||
[*.[chS]]
|
||||
indent_style = space
|
||||
max_doc_length = 80
|
||||
max_line_length = 80
|
||||
|
||||
[*.dfa]
|
||||
indent_style = space
|
||||
max_doc_length = 80
|
||||
max_line_length = 80
|
||||
|
||||
[*.{awk,cmake}]
|
||||
indent_style = space
|
||||
max_doc_length = 80
|
||||
max_line_length = 100
|
||||
|
||||
[*.{in,sh}]
|
||||
indent_style = space
|
||||
max_doc_length = 100
|
||||
max_line_length = 100
|
||||
|
||||
[{Makefile.in,ltmain.sh}]
|
||||
indent_style = unset
|
||||
insert_final_newline = unset
|
||||
max_doc_length = unset
|
||||
max_line_length = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[COMMIT_EDITMSG]
|
||||
indent_style = space
|
||||
max_doc_length = unset
|
||||
max_line_length = 72
|
||||
27
.github/workflows/lint.yml
vendored
Normal file
27
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Linting libpng
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- libpng16
|
||||
pull_request:
|
||||
branches:
|
||||
- libpng16
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Set up the cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/pip.txt') }}
|
||||
restore-keys: ${{ runner.os }}-pip-
|
||||
- name: Install yamllint
|
||||
run: pip install yamllint
|
||||
- name: Check out the code
|
||||
uses: actions/checkout@v4
|
||||
- name: Run the linting script
|
||||
run: bash ./ci/ci_lint.sh
|
||||
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/
|
||||
34
.travis.yml
Normal file
34
.travis.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
branches:
|
||||
except:
|
||||
- /libpng[0-1][0-7]/
|
||||
- /v[0-1][.][0-7][.][0-9]+/
|
||||
|
||||
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'
|
||||
7
.yamllint.yml
Normal file
7
.yamllint.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
extends: default
|
||||
rules:
|
||||
document-start: disable
|
||||
document-end: disable
|
||||
line-length: disable
|
||||
truthy:
|
||||
check-keys: false
|
||||
150
ANNOUNCE
150
ANNOUNCE
@@ -1,117 +1,63 @@
|
||||
Libpng 1.6.32rc02 - August 22, 2017
|
||||
libpng 1.6.43 - February 23, 2024
|
||||
=================================
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
This is a public release of libpng, intended for use in production code.
|
||||
|
||||
Files available for download:
|
||||
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
Files available for download
|
||||
----------------------------
|
||||
|
||||
1.6.32rc02.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.32rc02.tar.gz
|
||||
Source files with LF line endings (for Unix/Linux):
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
* libpng-1.6.43.tar.xz (LZMA-compressed, recommended)
|
||||
* libpng-1.6.43.tar.gz (deflate-compressed)
|
||||
|
||||
lp1632r02.7z (LZMA-compressed, recommended)
|
||||
lp1632r02.zip
|
||||
Source files with CRLF line endings (for Windows):
|
||||
|
||||
* lpng1643.7z (LZMA-compressed, recommended)
|
||||
* lpng1643.zip (deflate-compressed)
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.32rc02-README.txt
|
||||
1.6.32rc02-LICENSE.txt
|
||||
libpng-1.6.32rc02-*.asc (armored detached GPG signatures)
|
||||
* README.md
|
||||
* LICENSE.md
|
||||
* AUTHORS.md
|
||||
* TRADEMARK.md
|
||||
|
||||
Changes since the last public release (1.6.31):
|
||||
|
||||
Version 1.6.32beta01 [July 31, 2017]
|
||||
Avoid possible NULL dereference in png_handle_eXIf when benign_errors
|
||||
are allowed. Avoid leaking the input buffer "eXIf_buf".
|
||||
Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif
|
||||
to arguments for png_get_eXIf() and png_set_eXIf().
|
||||
Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in
|
||||
pngwrite.c, and made various other fixes to png_write_eXIf().
|
||||
Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and
|
||||
png_set_eXIf_1(), respectively, to avoid breaking API compatibility
|
||||
with libpng-1.6.31.
|
||||
Changes from version 1.6.42 to version 1.6.43
|
||||
---------------------------------------------
|
||||
|
||||
Version 1.6.32beta02 [August 1, 2017]
|
||||
Updated contrib/libtests/pngunknown.c with eXIf chunk.
|
||||
* Fixed the row width check in png_check_IHDR().
|
||||
This corrected a bug that was specific to the 16-bit platforms,
|
||||
and removed a spurious compiler warning from the 64-bit builds.
|
||||
(Reported by Jacek Caban; fixed by John Bowler)
|
||||
* Added eXIf chunk support to the push-mode reader in pngpread.c.
|
||||
(Contributed by Chris Blume)
|
||||
* Added contrib/pngexif for the benefit of the users who would like
|
||||
to inspect the content of eXIf chunks.
|
||||
* Added contrib/conftest/basic.dfa, a basic build-time configuration.
|
||||
(Contributed by John Bowler)
|
||||
* Fixed a preprocessor condition in pngread.c that broke build-time
|
||||
configurations like contrib/conftest/pngcp.dfa.
|
||||
(Contributed by John Bowler)
|
||||
* Added CMake build support for LoongArch LSX.
|
||||
(Contributed by GuXiWei)
|
||||
* Fixed a CMake build error that occurred under a peculiar state of the
|
||||
dependency tree. This was a regression introduced in libpng-1.6.41.
|
||||
(Contributed by Dan Rosser)
|
||||
* Marked the installed libpng headers as system headers in CMake.
|
||||
(Contributed by Benjamin Buch)
|
||||
* Updated the build support for RISCOS.
|
||||
(Contributed by Cameron Cawley)
|
||||
* Updated the makefiles to allow cross-platform builds to initialize
|
||||
conventional make variables like AR and ARFLAGS.
|
||||
* Added various improvements to the CI scripts in areas like version
|
||||
consistency verification and text linting.
|
||||
* Added version consistency verification to pngtest.c also.
|
||||
|
||||
Version 1.6.32beta03 [August 2, 2017]
|
||||
Initialized btoa[] in pngstest.c
|
||||
Stop memory leak when returning from png_handle_eXIf() with an error
|
||||
(Bug report from the OSS-fuzz project).
|
||||
|
||||
Version 1.6.32beta04 [August 2, 2017]
|
||||
Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf().
|
||||
Update libpng.3 and libpng-manual.txt about eXIf functions.
|
||||
|
||||
Version 1.6.32beta05 [August 2, 2017]
|
||||
Restored png_get_eXIf() and png_set_eXIf() to maintain API compatability.
|
||||
|
||||
Version 1.6.32beta06 [August 2, 2017]
|
||||
Removed png_get_eXIf_1() and png_set_eXIf_1().
|
||||
|
||||
Version 1.6.32beta07 [August 3, 2017]
|
||||
Check length of all chunks except IDAT against user limit to fix an
|
||||
OSS-fuzz issue.
|
||||
|
||||
Version 1.6.32beta08 [August 3, 2017]
|
||||
Check length of IDAT against maximum possible IDAT size, accounting
|
||||
for height, rowbytes, interlacing and zlib/deflate overhead.
|
||||
Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf)
|
||||
does not work (the eXIf chunk data can contain zeroes).
|
||||
|
||||
Version 1.6.32beta09 [August 3, 2017]
|
||||
Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
|
||||
no longer using deprecated cmake LOCATION feature (Clifford Yapp).
|
||||
Fixed five-byte error in the calculation of IDAT maximum possible size.
|
||||
|
||||
Version 1.6.32beta10 [August 5, 2017]
|
||||
Moved chunk-length check into a png_check_chunk_length() private
|
||||
function (Suggested by Max Stepin).
|
||||
Moved bad pngs from tests to contrib/libtests/crashers
|
||||
Moved testing of bad pngs into a separate tests/pngtest-badpngs script
|
||||
Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL
|
||||
in the output but PASS for the libpng test.
|
||||
Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp).
|
||||
Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the
|
||||
num_exif argument to png_get_eXIf_1() (Github Issue 171).
|
||||
|
||||
Version 1.6.32beta11 [August 7, 2017]
|
||||
Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks().
|
||||
Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers.
|
||||
Make pngtest --strict, --relax, --xfail options imply -m (multiple).
|
||||
Removed unused chunk_name parameter from png_check_chunk_length().
|
||||
Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak.
|
||||
Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue.
|
||||
Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR.
|
||||
Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue.
|
||||
Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account
|
||||
for the minimum 'deflate' stream, and relocate the test to a point
|
||||
after the keyword has been read.
|
||||
Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM".
|
||||
|
||||
Version 1.6.32rc01 [August 18, 2017]
|
||||
Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers,
|
||||
one for each known chunk type, with length = 2GB-1.
|
||||
Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts
|
||||
in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706,
|
||||
and 162707).
|
||||
Renamed chunks in contrib/testpngs/crashers to avoid having files whose
|
||||
names differ only in case; this causes problems with some platforms
|
||||
(github issue #172).
|
||||
|
||||
Version 1.6.32rc02 [August 22, 2017]
|
||||
Added contrib/oss-fuzz directory which contains files used by the oss-fuzz
|
||||
project (https://github.com/google/oss-fuzz/tree/master/projects/libpng).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
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
|
||||
to subscribe)
|
||||
or to glennrp at users.sourceforge.net
|
||||
|
||||
Glenn R-P
|
||||
to subscribe.
|
||||
|
||||
61
AUTHORS
Normal file
61
AUTHORS
Normal file
@@ -0,0 +1,61 @@
|
||||
PNG REFERENCE LIBRARY AUTHORS
|
||||
=============================
|
||||
|
||||
This is the list of PNG Reference Library ("libpng") Contributing
|
||||
Authors, for copyright and licensing purposes.
|
||||
|
||||
* Adam Richter
|
||||
* Andreas Dilger
|
||||
* Chris Blume
|
||||
* 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.
|
||||
271
CHANGES
271
CHANGES
@@ -1,4 +1,3 @@
|
||||
#if 0
|
||||
CHANGES - changes for libpng
|
||||
|
||||
version 0.1 [March 29, 1995]
|
||||
@@ -205,7 +204,7 @@ Version 0.97 [January, 1998]
|
||||
Added simple sRGB support (Glenn R-P)
|
||||
Easier conditional compiling, e.g.,
|
||||
define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
|
||||
all configurable options can be selected from command-line instead
|
||||
all configurable options can be selected from command line instead
|
||||
of having to edit pngconf.h (Glenn R-P)
|
||||
Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
|
||||
Added more conditions for png_do_background, to avoid changing
|
||||
@@ -833,7 +832,7 @@ Version 1.0.7beta11 [May 7, 2000]
|
||||
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
||||
which are no longer used.
|
||||
Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
|
||||
defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED
|
||||
defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED
|
||||
is defined.
|
||||
Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
|
||||
overrun when old applications fill the info_ptr->text structure directly.
|
||||
@@ -943,7 +942,7 @@ Version 1.0.8 [July 24, 2000]
|
||||
Version 1.0.9beta1 [November 10, 2000]
|
||||
Fixed typo in scripts/makefile.hpux
|
||||
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
|
||||
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
|
||||
Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
|
||||
Changed "cdrom.com" in documentation to "libpng.org"
|
||||
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
|
||||
Changed type of "params" from voidp to png_voidp in png_read|write_png().
|
||||
@@ -1454,7 +1453,7 @@ Version 1.2.6beta4 [July 28, 2004]
|
||||
sequential read support.
|
||||
Added some "#if PNG_WRITE_SUPPORTED" blocks.
|
||||
Added #ifdef to remove some redundancy in png_malloc_default().
|
||||
Use png_malloc instead of png_zalloc to allocate the pallete.
|
||||
Use png_malloc instead of png_zalloc to allocate the palette.
|
||||
|
||||
Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004]
|
||||
Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS().
|
||||
@@ -2296,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009]
|
||||
Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
|
||||
|
||||
Version 1.4.0beta59 [May 15, 2009]
|
||||
Reformated sources in libpng style (3-space intentation, comment format)
|
||||
Reformatted sources in libpng style (3-space indentation, comment format)
|
||||
Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
|
||||
Added sections about the git repository and our coding style to the
|
||||
documentation
|
||||
@@ -2662,7 +2661,7 @@ Version 1.4.1beta06 [January 28, 2010]
|
||||
|
||||
Version 1.4.1beta07 [February 6, 2010]
|
||||
Folded some long lines in the source files.
|
||||
Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
|
||||
Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
|
||||
and a PNG_USER_LIMITS_SUPPORTED flag.
|
||||
Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
|
||||
png_ptr->png_user_chunk_malloc_max.
|
||||
@@ -3259,7 +3258,7 @@ Version 1.5.2beta01 [February 13, 2011]
|
||||
Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the
|
||||
old VisualC++ preprocessor.
|
||||
Turned on interlace handling in png_read_png().
|
||||
Fixed gcc pendantic warnings.
|
||||
Fixed gcc pedantic warnings.
|
||||
Handle longjmp in Cygwin.
|
||||
Fixed png_get_current_row_number() in the interlaced case.
|
||||
Cleaned up ALPHA flags and transformations.
|
||||
@@ -3359,7 +3358,7 @@ Version 1.5.3beta05 [May 6, 2011]
|
||||
Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
|
||||
was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691.
|
||||
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
|
||||
optimization configureable.
|
||||
optimization configurable.
|
||||
IDAT compression failed if preceded by a compressed text chunk (bug
|
||||
introduced in libpng-1.5.3beta01-02). This was because the attempt to
|
||||
reset the zlib stream in png_write_IDAT happened after the first IDAT
|
||||
@@ -3643,7 +3642,7 @@ Version 1.5.6beta05 [October 12, 2011]
|
||||
Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01.
|
||||
|
||||
Version 1.5.6beta06 [October 17, 2011]
|
||||
Removed two redundant tests for unitialized row.
|
||||
Removed two redundant tests for uninitialized row.
|
||||
Fixed a relatively harmless memory overwrite in compressed text writing
|
||||
with a 1 byte zlib buffer.
|
||||
Add ability to call png_read_update_info multiple times to pngvalid.c.
|
||||
@@ -3689,7 +3688,7 @@ Version 1.5.7beta01 [November 4, 2011]
|
||||
crash. The pngmem.c implementation of png_malloc() included a cast
|
||||
to png_size_t which would fail on large allocations on 16-bit systems.
|
||||
Fix for the preprocessor of the Intel C compiler. The preprocessor
|
||||
splits adjacent @ signs with a space; this changes the concatentation
|
||||
splits adjacent @ signs with a space; this changes the concatenation
|
||||
token from @-@-@ to PNG_JOIN; that should work with all compiler
|
||||
preprocessors.
|
||||
Paeth filter speed improvements from work by Siarhei Siamashka. This
|
||||
@@ -3735,7 +3734,7 @@ Version 1.5.7beta03 [November 17, 2011]
|
||||
gray (on palette) itself.
|
||||
Fixes for C++ compilation using g++ When libpng source is compiled
|
||||
using g++. The compiler imposes C++ rules on the C source; thus it
|
||||
is desireable to make the source work with either C or C++ rules
|
||||
is desirable to make the source work with either C or C++ rules
|
||||
without throwing away useful error information. This change adds
|
||||
png_voidcast to allow C semantic (void*) cases or the corresponding
|
||||
C++ static_cast operation, as appropriate.
|
||||
@@ -3887,7 +3886,7 @@ Version 1.6.0beta06 [January 24, 2012]
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
current versions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
@@ -3920,7 +3919,7 @@ Version 1.6.0beta08 [February 1, 2012]
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option is now done automagically only when required, so that command-line
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
@@ -4053,7 +4052,7 @@ Version 1.6.0beta16 [March 6, 2012]
|
||||
(in fact this is harmless, but the PNG data produced may be sub-optimal).
|
||||
|
||||
Version 1.6.0beta17 [March 10, 2012]
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Deflate/inflate was reworked to move common zlib calls into single
|
||||
functions [rw]util.c. A new shared keyword check routine was also added
|
||||
@@ -4061,7 +4060,7 @@ Version 1.6.0beta17 [March 10, 2012]
|
||||
possible to call png_inflate() incrementally. A warning is no longer
|
||||
issued if the language tag or translated keyword in the iTXt chunk
|
||||
has zero length.
|
||||
If benign errors are disabled use maximum window on ancilliary inflate.
|
||||
If benign errors are disabled use maximum window on ancillary inflate.
|
||||
This works round a bug introduced in 1.5.4 where compressed ancillary
|
||||
chunks could end up with a too-small windowBits value in the deflate
|
||||
header.
|
||||
@@ -4176,7 +4175,7 @@ Version 1.6.0beta27 [August 11, 2012]
|
||||
declared even though the functions are never actually defined. This
|
||||
change provides a dummy definition so that the declarations work, yet any
|
||||
implementation will fail to compile because of an incomplete type.
|
||||
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
|
||||
Re-eliminated the use of strcpy() in pngtest.c. An unnecessary use of
|
||||
strcpy() was accidentally re-introduced in libpng16; this change replaces
|
||||
it with strncpy().
|
||||
Eliminated use of png_sizeof(); use sizeof() instead.
|
||||
@@ -4309,7 +4308,7 @@ Version 1.6.0beta31 [November 1, 2012]
|
||||
resulting in VS2010 having to update the files.
|
||||
Removed non-working ICC profile support code that was mostly added to
|
||||
libpng-1.6.0beta29 and beta30. There was too much code for too little
|
||||
gain; implementing full ICC color correction may be desireable but is left
|
||||
gain; implementing full ICC color correction may be desirable but is left
|
||||
up to applications.
|
||||
|
||||
Version 1.6.0beta32 [November 25, 2012]
|
||||
@@ -4592,7 +4591,7 @@ Version 1.6.3beta07 [June 8, 2013]
|
||||
the optimizations ('check' vs 'api') are exposed in the public header files
|
||||
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
|
||||
decision about whether or not to use the optimizations.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS usage.
|
||||
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
|
||||
on __ARM_NEON__ from configure time to compile time. This breaks symbol
|
||||
prefixing because the definition of the special png_init_filter_functions
|
||||
@@ -4963,7 +4962,7 @@ Version 1.6.13beta01 [July 4, 2014]
|
||||
Changed "if defined(__ARM_NEON__)" to
|
||||
"if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu).
|
||||
Fixed clang no-warning builds: png_digit was defined but never used.
|
||||
|
||||
|
||||
Version 1.6.13beta02 [July 21, 2014]
|
||||
Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32
|
||||
(bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11.
|
||||
@@ -5454,7 +5453,7 @@ Version 1.6.21beta01 [December 11, 2015]
|
||||
Version 1.6.21beta02 [December 14, 2015]
|
||||
Moved png_check_keyword() from pngwutil.c to pngset.c
|
||||
Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
|
||||
in the BigEndian tests by not testing it, making the BE code the same
|
||||
in the BigEndian tests by not testing it, making the BE code the same
|
||||
as the LE version.
|
||||
Fixes to pngvalid for various reduced build configurations (eliminate unused
|
||||
statics) and a fix for the case in rgb_to_gray when the digitize option
|
||||
@@ -5518,7 +5517,7 @@ Version 1.6.22beta03 [March 9, 2016]
|
||||
Added a common-law trademark notice and export control information
|
||||
to the LICENSE file, png.h, and the man page.
|
||||
Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
|
||||
were accidentally removed from libpng-1.6.17.
|
||||
were accidentally removed from libpng-1.6.17.
|
||||
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
|
||||
(Robert C. Seacord).
|
||||
Removed dubious "#if INT_MAX" test from png.h that was added to
|
||||
@@ -5635,7 +5634,7 @@ Version 1.6.24beta02 [June 23, 2016]
|
||||
to All and adds a list of the warnings that need to be turned off. This is
|
||||
semi-documentary; the intent is to tell libpng users which warnings have
|
||||
been examined and judged non-fixable at present. The warning about
|
||||
structure padding is fixable, but it would be a signficant change (moving
|
||||
structure padding is fixable, but it would be a significant change (moving
|
||||
structure members around).
|
||||
|
||||
Version 1.6.24beta03 [July 4, 2016]
|
||||
@@ -5781,7 +5780,7 @@ Version 1.6.28rc01 [January 3, 2017]
|
||||
Added option to Cmake build allowing a custom location of zlib to be
|
||||
specified in a scenario where libpng is being built as a subproject
|
||||
alongside zlib by another project (Sam Serrels).
|
||||
Changed png_ptr->options from a png_byte to png_uint_32, to accomodate
|
||||
Changed png_ptr->options from a png_byte to png_uint_32, to accommodate
|
||||
up to 16 options.
|
||||
|
||||
Version 1.6.28rc02 [January 4, 2017]
|
||||
@@ -5928,18 +5927,18 @@ Version 1.6.32beta03 [August 2, 2017]
|
||||
(Bug report from the OSS-fuzz project).
|
||||
|
||||
Version 1.6.32beta04 [August 2, 2017]
|
||||
Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf().
|
||||
Replaced local eXIf_buf with info_ptr->eXIf_buf in png_handle_eXIf().
|
||||
Update libpng.3 and libpng-manual.txt about eXIf functions.
|
||||
|
||||
Version 1.6.32beta05 [August 2, 2017]
|
||||
Restored png_get_eXIf() and png_set_eXIf() to maintain API compatability.
|
||||
Restored png_get_eXIf() and png_set_eXIf() to maintain API compatibility.
|
||||
|
||||
Version 1.6.32beta06 [August 2, 2017]
|
||||
Removed png_get_eXIf_1() and png_set_eXIf_1().
|
||||
|
||||
Version 1.6.32beta07 [August 3, 2017]
|
||||
Check length of all chunks except IDAT against user limit to fix an
|
||||
OSS-fuzz issue.
|
||||
OSS-fuzz issue (Fixes CVE-2017-12652).
|
||||
|
||||
Version 1.6.32beta08 [August 3, 2017]
|
||||
Check length of IDAT against maximum possible IDAT size, accounting
|
||||
@@ -5951,7 +5950,7 @@ Version 1.6.32beta09 [August 3, 2017]
|
||||
Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
|
||||
no longer using deprecated cmake LOCATION feature (Clifford Yapp).
|
||||
Fixed five-byte error in the calculation of IDAT maximum possible size.
|
||||
|
||||
|
||||
Version 1.6.32beta10 [August 5, 2017]
|
||||
Moved chunk-length check into a png_check_chunk_length() private
|
||||
function (Suggested by Max Stepin).
|
||||
@@ -5991,11 +5990,213 @@ Version 1.6.32rc02 [August 22, 2017]
|
||||
Added contrib/oss-fuzz directory which contains files used by the oss-fuzz
|
||||
project (https://github.com/google/oss-fuzz/tree/master/projects/libpng).
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe)
|
||||
or to glennrp at users.sourceforge.net
|
||||
Version 1.6.32 [August 24, 2017]
|
||||
No changes.
|
||||
|
||||
Glenn R-P
|
||||
#endif
|
||||
Version 1.6.33beta01 [August 28, 2017]
|
||||
Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
|
||||
parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
|
||||
Fixed off-by-one error in png_do_check_palette_indexes() (Bug report
|
||||
by Mick P., Source Forge Issue #269).
|
||||
|
||||
Version 1.6.33beta02 [September 3, 2017]
|
||||
Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
|
||||
to fix shortlived oss-fuzz issue 3234.
|
||||
Compute a larger limit on IDAT because some applications write a deflate
|
||||
buffer for each row (Bug report by Andrew Church).
|
||||
Use current date (DATE) instead of release-date (RDATE) in last
|
||||
changed date of contrib/oss-fuzz files.
|
||||
Enabled ARM support in CMakeLists.txt (Bernd Kuhls).
|
||||
|
||||
Version 1.6.33beta03 [September 14, 2017]
|
||||
Fixed incorrect typecast of some arguments to png_malloc() and
|
||||
png_calloc() that were png_uint_32 instead of png_alloc_size_t
|
||||
(Bug report by "irwir" in Github libpng issue #175).
|
||||
Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github
|
||||
issue 162, by rcdailey).
|
||||
|
||||
Version 1.6.33rc01 [September 20, 2017]
|
||||
Initialize memory allocated by png_inflate to zero, using memset, to
|
||||
stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2()
|
||||
due to truncated iTXt or zTXt chunk.
|
||||
Initialize memory allocated by png_read_buffer to zero, using memset, to
|
||||
stop an oss-fuzz "use of uninitialized value" detection in
|
||||
png_icc_check_tag_table() due to truncated iCCP chunk.
|
||||
Removed a redundant test (suggested by "irwir" in Github issue #180).
|
||||
|
||||
Version 1.6.33rc02 [September 23, 2017]
|
||||
Added an interlaced version of each file in contrib/pngsuite.
|
||||
Relocate new memset() call in pngrutil.c.
|
||||
Removed more redundant tests (suggested by "irwir" in Github issue #180).
|
||||
Add support for loading images with associated alpha in the Simplified
|
||||
API (Samuel Williams).
|
||||
|
||||
Version 1.6.33 [September 28, 2017]
|
||||
Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state.
|
||||
Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
|
||||
Add end_info structure and png_read_end() to the libpng fuzzer.
|
||||
|
||||
Version 1.6.34 [September 29, 2017]
|
||||
Removed contrib/pngsuite/i*.png; some of them caused test failures.
|
||||
|
||||
Version 1.6.35beta01 [March 6, 2018]
|
||||
Restored 21 of the contrib/pngsuite/i*.png, which do not cause test
|
||||
failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png.
|
||||
Added calls to png_set_*() transforms commonly used by browsers to
|
||||
the fuzzer.
|
||||
Removed some unnecessary brackets in pngrtran.c
|
||||
Fixed miscellaneous typos (Patch by github user "luzpaz").
|
||||
Change "ASM C" to "C ASM" in CMakeLists.txt
|
||||
Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin)
|
||||
Added hardware optimization directories to zip and 7z distributions.
|
||||
Fixed incorrect bitmask for options.
|
||||
Fixed many spelling typos.
|
||||
|
||||
Version 1.6.35beta02 [March 28, 2018]
|
||||
Make png_get_iCCP consistent with man page (allow compression-type argument
|
||||
to be NULL, bug report by Lenard Szolnoki).
|
||||
|
||||
Version 1.6.35 [July 15, 2018]
|
||||
Replaced the remaining uses of png_size_t with size_t (Cosmin)
|
||||
Fixed the calculation of row_factor in png_check_chunk_length
|
||||
(reported by Thuan Pham in SourceForge issue #278)
|
||||
Added missing parentheses to a macro definition
|
||||
(suggested by "irwir" in GitHub issue #216)
|
||||
|
||||
Version 1.6.36 [December 1, 2018]
|
||||
Optimized png_do_expand_palette for ARM processors.
|
||||
Improved performance by around 10-22% on a recent ARM Chromebook.
|
||||
(Contributed by Richard Townsend, ARM Holdings)
|
||||
Fixed manipulation of machine-specific optimization options.
|
||||
(Contributed by Vicki Pfau)
|
||||
Used memcpy instead of manual pointer arithmetic on Intel SSE2.
|
||||
(Contributed by Samuel Williams)
|
||||
Fixed build errors with MSVC on ARM64.
|
||||
(Contributed by Zhijie Liang)
|
||||
Fixed detection of libm in CMakeLists.
|
||||
(Contributed by Cameron Cawley)
|
||||
Fixed incorrect creation of pkg-config file in CMakeLists.
|
||||
(Contributed by Kyle Bentley)
|
||||
Fixed the CMake build on Windows MSYS by avoiding symlinks.
|
||||
Fixed a build warning on OpenBSD.
|
||||
(Contributed by Theo Buehler)
|
||||
Fixed various typos in comments.
|
||||
(Contributed by "luz.paz")
|
||||
Raised the minimum required CMake version from 3.0.2 to 3.1.
|
||||
Removed yet more of the vestigial support for pre-ANSI C compilers.
|
||||
Removed ancient makefiles for ancient systems that have been broken
|
||||
across all previous libpng-1.6.x versions.
|
||||
Removed the Y2K compliance statement and the export control
|
||||
information.
|
||||
Applied various code style and documentation fixes.
|
||||
|
||||
Version 1.6.37 [April 14, 2019]
|
||||
Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
|
||||
Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
|
||||
Fixed a memory leak in pngtest.c.
|
||||
Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
|
||||
contrib/pngminus; refactor.
|
||||
Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
|
||||
(Contributed by Willem van Schaik)
|
||||
Fixed a typo in the libpng license v2.
|
||||
(Contributed by Miguel Ojeda)
|
||||
Added makefiles for AddressSanitizer-enabled builds.
|
||||
Cleaned up various makefiles.
|
||||
|
||||
Version 1.6.38 [September 14, 2022]
|
||||
Added configurations and scripts for continuous integration.
|
||||
Fixed various errors in the handling of tRNS, hIST and eXIf.
|
||||
Implemented many stability improvements across all platforms.
|
||||
Updated the internal documentation.
|
||||
|
||||
Version 1.6.39 [November 20, 2022]
|
||||
Changed the error handler of oversized chunks (i.e. larger than
|
||||
PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
|
||||
Fixed a buffer overflow error in contrib/tools/pngfix.
|
||||
Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
|
||||
Disabled the ARM Neon optimizations by default in the CMake file,
|
||||
following the default behavior of the configure script.
|
||||
Allowed configure.ac to work with the trunk version of autoconf.
|
||||
Removed the support for "install" targets from the legacy makefiles;
|
||||
removed the obsolete makefile.cegcc.
|
||||
Cleaned up the code and updated the internal documentation.
|
||||
|
||||
Version 1.6.40 [June 21, 2023]
|
||||
Fixed the eXIf chunk multiplicity checks.
|
||||
Fixed a memory leak in pCAL processing.
|
||||
Corrected the validity report about tRNS inside png_get_valid().
|
||||
Fixed various build issues on *BSD, Mac and Windows.
|
||||
Updated the configurations and the scripts for continuous integration.
|
||||
Cleaned up the code, the build scripts, and the documentation.
|
||||
|
||||
Version 1.6.41 [January 24, 2024]
|
||||
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)
|
||||
|
||||
Version 1.6.42 [January 29, 2024]
|
||||
Fixed the implementation of the macro function png_check_sig().
|
||||
This was an API regression, introduced in libpng-1.6.41.
|
||||
(Reported by Matthieu Darbois)
|
||||
Fixed and updated the libpng manual.
|
||||
|
||||
Version 1.6.43 [February 23, 2024]
|
||||
Fixed the row width check in png_check_IHDR().
|
||||
This corrected a bug that was specific to the 16-bit platforms,
|
||||
and removed a spurious compiler warning from the 64-bit builds.
|
||||
(Reported by Jacek Caban; fixed by John Bowler)
|
||||
Added eXIf chunk support to the push-mode reader in pngpread.c.
|
||||
(Contributed by Chris Blume)
|
||||
Added contrib/pngexif for the benefit of the users who would like
|
||||
to inspect the content of eXIf chunks.
|
||||
Added contrib/conftest/basic.dfa, a basic build-time configuration.
|
||||
(Contributed by John Bowler)
|
||||
Fixed a preprocessor condition in pngread.c that broke build-time
|
||||
configurations like contrib/conftest/pngcp.dfa.
|
||||
(Contributed by John Bowler)
|
||||
Added CMake build support for LoongArch LSX.
|
||||
(Contributed by GuXiWei)
|
||||
Fixed a CMake build error that occurred under a peculiar state of the
|
||||
dependency tree. This was a regression introduced in libpng-1.6.41.
|
||||
(Contributed by Dan Rosser)
|
||||
Marked the installed libpng headers as system headers in CMake.
|
||||
(Contributed by Benjamin Buch)
|
||||
Updated the build support for RISCOS.
|
||||
(Contributed by Cameron Cawley)
|
||||
Updated the makefiles to allow cross-platform builds to initialize
|
||||
conventional make variables like AR and ARFLAGS.
|
||||
Added various improvements to the CI scripts in areas like version
|
||||
consistency verification and text linting.
|
||||
Added version consistency verification to pngtest.c also.
|
||||
|
||||
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
|
||||
to subscribe.
|
||||
|
||||
1340
CMakeLists.txt
1340
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
89
INSTALL
89
INSTALL
@@ -128,16 +128,18 @@ Your directory structure should look like this:
|
||||
README
|
||||
*.h, *.c => libpng source files
|
||||
CMakeLists.txt => "cmake" script
|
||||
ci
|
||||
ci_*.sh
|
||||
configuration files:
|
||||
configure.ac, configure, Makefile.am, Makefile.in,
|
||||
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
|
||||
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
|
||||
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||
pngminus, pngsuite, tools, visupng
|
||||
projects
|
||||
cbuilder5, owatcom, visualc71, vstudio, xcode
|
||||
owatcom, visualc71, vstudio
|
||||
scripts
|
||||
makefile.*
|
||||
*.def (module definition files)
|
||||
@@ -145,7 +147,7 @@ Your directory structure should look like this:
|
||||
pngtest.png
|
||||
etc.
|
||||
zlib
|
||||
README, *.h, *.c contrib, etc.
|
||||
README, *.h, *.c, contrib, etc.
|
||||
|
||||
If the line endings in the files look funny, you may wish to get the other
|
||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||
@@ -153,28 +155,27 @@ endings) and zip (DOS style line endings) formats.
|
||||
|
||||
VI. Building with project files
|
||||
|
||||
If you are building libpng with MSVC, you can enter the
|
||||
libpng projects\visualc71 or vstudio directory and follow the instructions
|
||||
in README.txt.
|
||||
If you are building libpng with Microsoft Visual Studio, you can enter
|
||||
the directory projects\visualc71 or projects\vstudio and follow the
|
||||
instructions in README.txt.
|
||||
|
||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
||||
then come back here and run "configure" or choose the appropriate
|
||||
makefile.sys in the scripts directory.
|
||||
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
|
||||
scripts directory into this directory, for example
|
||||
|
||||
MSDOS example:
|
||||
|
||||
copy scripts\makefile.msc makefile
|
||||
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
|
||||
|
||||
UNIX example:
|
||||
|
||||
cp scripts/makefile.std makefile
|
||||
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||
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
|
||||
target directories to match your preferences.
|
||||
@@ -191,36 +192,33 @@ test. For more confidence, you can run another test by typing
|
||||
Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
|
||||
your output with the result shown in contrib/pngsuite/README.
|
||||
|
||||
Most of the makefiles will allow you to run "make install" to
|
||||
put the library in its final resting place (if you want to
|
||||
do that, run "make install" in the zlib directory first if necessary).
|
||||
Some also allow you to run "make test-installed" after you have
|
||||
run "make install".
|
||||
Most of the makefiles used to allow you to run "make install" to put
|
||||
the library in its final resting place, but that feature is no longer
|
||||
supported. The only tested and supported manners to install libpng are
|
||||
the conventional build and install procedures driven by the configure
|
||||
script or by the CMake file.
|
||||
|
||||
VIII. Configuring libpng for 16-bit platforms
|
||||
VIII. Configuring for DOS and other 16-bit platforms
|
||||
|
||||
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||
it cannot allocate more than 64K at a time. Even if you can, the memory
|
||||
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
||||
|
||||
IX. Configuring for DOS
|
||||
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.
|
||||
|
||||
X. Configuring for Medium Model
|
||||
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.
|
||||
|
||||
Libpng's support for medium model has been tested on most of the popular
|
||||
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||
all set. Everything in the library (except for zlib's structure) is
|
||||
expecting far data. You must use the typedefs with the p or pp on
|
||||
the end for pointers (or at least look at them and be careful). Make
|
||||
note that the rows of data are defined as png_bytepp, which is
|
||||
an "unsigned char far * far *".
|
||||
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.
|
||||
|
||||
XI. Prepending a prefix to exported symbols
|
||||
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
|
||||
@@ -231,7 +229,7 @@ identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||
transparent to applications; their function calls get transformed by
|
||||
the macros to use the modified names.
|
||||
|
||||
XII. Configuring for compiler xxx:
|
||||
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.
|
||||
@@ -243,7 +241,7 @@ As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||
that previously appeared in the public headers.
|
||||
|
||||
XIII. Removing unwanted object code
|
||||
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
|
||||
@@ -282,9 +280,9 @@ library to fail if they call functions not available in your library.
|
||||
The size of the library itself should not be an issue, because only
|
||||
those sections that are actually used will be loaded into memory.
|
||||
|
||||
XIV. Enabling or disabling hardware optimizations
|
||||
XII. Enabling or disabling hardware optimizations
|
||||
|
||||
Certain hardware capabilites, such as the Intel SSE instructions,
|
||||
Certain hardware capabilities, such as the Intel SSE instructions,
|
||||
are normally detected at run time. Enable them with configure options
|
||||
such as one of
|
||||
|
||||
@@ -332,7 +330,7 @@ or disable them all at once with
|
||||
|
||||
cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
|
||||
|
||||
XV. Changes to the build and configuration of libpng in libpng-1.5.x
|
||||
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
|
||||
@@ -423,7 +421,7 @@ $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.
|
||||
|
||||
XVI. Setjmp/longjmp issues
|
||||
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
|
||||
@@ -441,7 +439,7 @@ 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.
|
||||
|
||||
XVII. Common linking failures
|
||||
XV. Common linking failures
|
||||
|
||||
If your application fails to find libpng or zlib entries while linking:
|
||||
|
||||
@@ -453,12 +451,13 @@ If your application fails to find libpng or zlib entries while linking:
|
||||
If you are using the vstudio project, observe the WARNING in
|
||||
project/vstudio/README.txt.
|
||||
|
||||
XVIII. Other sources of information about libpng:
|
||||
XVI. Other sources of information about libpng:
|
||||
|
||||
Further information can be found in the README and libpng-manual.txt
|
||||
files, in the individual makefiles, in png.h, and the manual pages
|
||||
libpng.3 and png.5.
|
||||
|
||||
Copyright (c) 2022 Cosmin Truta
|
||||
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
|
||||
177
LICENSE
177
LICENSE
@@ -1,53 +1,82 @@
|
||||
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||
=========================================
|
||||
|
||||
This copy of the libpng notices is provided for your convenience. In case of
|
||||
any discrepancy between this copy and the notices in the file png.h that is
|
||||
included in the libpng distribution, the latter shall prevail.
|
||||
PNG Reference Library License version 2
|
||||
---------------------------------------
|
||||
|
||||
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
|
||||
this sentence.
|
||||
The software is supplied "as is", without warranty of any kind,
|
||||
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.0.7, July 1, 2000 through 1.6.32rc02, August 22, 2017 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||
1. The origin of this software must not be misrepresented; you
|
||||
must not claim that you wrote the original software. If you
|
||||
use this software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated, but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
|
||||
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
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
|
||||
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:
|
||||
|
||||
There is no warranty against interference with your enjoyment of the
|
||||
library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
the user.
|
||||
There is no warranty against interference with your enjoyment of
|
||||
the library or against infringement. There is no warranty that our
|
||||
efforts or the library will fulfill any of your particular purposes
|
||||
or needs. This library is provided with all faults, and the entire
|
||||
risk of satisfactory quality, performance, accuracy, and effort is
|
||||
with the user.
|
||||
|
||||
Some files in the "contrib" directory and some configure-generated
|
||||
files that are distributed with libpng have other copyright owners and
|
||||
files that are distributed with libpng have other copyright owners, and
|
||||
are released under other open source licenses.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
libpng-0.96, and are distributed according to the same disclaimer and
|
||||
license as libpng-0.96, with the following individuals added to the list
|
||||
of Contributing Authors:
|
||||
license as libpng-0.96, with the following individuals added to the
|
||||
list of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
@@ -55,14 +84,14 @@ and are distributed according to the same disclaimer and license as
|
||||
libpng-0.88, with the following individuals added to the list of
|
||||
Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
John Bowler
|
||||
Kevin Bracey
|
||||
Sam Bushell
|
||||
Magnus Holmgren
|
||||
Greg Roelofs
|
||||
Tom Tanner
|
||||
|
||||
Some files in the "scripts" directory have other copyright owners
|
||||
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
|
||||
@@ -71,63 +100,35 @@ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
For the purposes of this copyright and license, "Contributing Authors"
|
||||
is defined as the following set of individuals:
|
||||
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
Andreas Dilger
|
||||
Dave Martindale
|
||||
Guy Eric Schalnat
|
||||
Paul Schmidt
|
||||
Tim Wegner
|
||||
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
||||
including, without limitation, the warranties of merchantability and of
|
||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
||||
or consequential damages, which may result from the use of the PNG
|
||||
Reference Library, even if advised of the possibility of such damage.
|
||||
The PNG Reference Library is supplied "AS IS". The Contributing
|
||||
Authors and Group 42, Inc. disclaim all warranties, expressed or
|
||||
implied, including, without limitation, the warranties of
|
||||
merchantability and of fitness for any purpose. The Contributing
|
||||
Authors and Group 42, Inc. assume no liability for direct, indirect,
|
||||
incidental, special, exemplary, or consequential damages, which may
|
||||
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
|
||||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
fee, and encourage the use of this source code as a component to
|
||||
supporting the PNG file format in commercial products. If you use this
|
||||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
|
||||
|
||||
TRADEMARK:
|
||||
|
||||
The name "libpng" has not been registered by the Copyright owner
|
||||
as a trademark in any jurisdiction. However, because libpng has
|
||||
been distributed and maintained world-wide, continually since 1995,
|
||||
the Copyright owner claims "common-law trademark protection" in any
|
||||
jurisdiction where common-law trademark is recognized.
|
||||
|
||||
OSI CERTIFICATION:
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
EXPORT CONTROL:
|
||||
|
||||
The Copyright owner believes that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because
|
||||
it is open source, publicly available software, that does not contain
|
||||
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
||||
734.7(b).
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
April 1, 2017
|
||||
The Contributing Authors and Group 42, Inc. specifically permit,
|
||||
without fee, and encourage the use of this source code as a component
|
||||
to supporting the PNG file format in commercial products. If you use
|
||||
this source code in a product, acknowledgment is not required but would
|
||||
be appreciated.
|
||||
|
||||
54
Makefile.am
54
Makefile.am
@@ -1,7 +1,7 @@
|
||||
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||
#
|
||||
# Copyright (c) 2018-2024 Cosmin Truta
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -9,16 +9,24 @@
|
||||
|
||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
ACLOCAL_AMFLAGS = -I scripts/autoconf
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
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
|
||||
if ENABLE_TOOLS
|
||||
bin_PROGRAMS= pngfix png-fix-itxt
|
||||
else
|
||||
bin_PROGRAMS=
|
||||
endif
|
||||
|
||||
# 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,
|
||||
@@ -30,6 +38,7 @@ bin_PROGRAMS= pngfix png-fix-itxt
|
||||
# always wrong and always very confusing.
|
||||
BUILT_SOURCES = pnglibconf.h
|
||||
|
||||
if ENABLE_TESTS
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
@@ -48,19 +57,22 @@ 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_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||
|
||||
pngcp_SOURCES = contrib/tools/pngcp.c
|
||||
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
endif
|
||||
|
||||
# Generally these are single line shell scripts to run a test with a particular
|
||||
# set of parameters:
|
||||
if ENABLE_TESTS
|
||||
TESTS =\
|
||||
tests/pngtest\
|
||||
tests/pngtest-badpngs\
|
||||
tests/pngtest-all\
|
||||
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
||||
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
||||
tests/pngvalid-gamma-expand16-background\
|
||||
@@ -76,6 +88,7 @@ TESTS =\
|
||||
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
||||
tests/pngimage-quick tests/pngimage-full
|
||||
endif
|
||||
|
||||
# man pages
|
||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||
@@ -95,7 +108,8 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
|
||||
if PNG_ARM_NEON
|
||||
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
|
||||
@@ -103,6 +117,13 @@ 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
|
||||
@@ -113,6 +134,15 @@ 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
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
||||
@@ -133,6 +163,10 @@ else
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
||||
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/*
|
||||
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
|
||||
pkginclude_HEADERS= png.h pngconf.h
|
||||
@@ -147,9 +181,9 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
# from those directories being included. This only works if the configure is
|
||||
# not done in the source directory!
|
||||
EXTRA_DIST= \
|
||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
|
||||
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 \
|
||||
CMakeLists.txt example.c libpng-manual.txt
|
||||
|
||||
|
||||
2550
Makefile.in
Normal file
2550
Makefile.in
Normal file
File diff suppressed because it is too large
Load Diff
350
README
350
README
@@ -1,56 +1,88 @@
|
||||
README for libpng version 1.6.32rc02 - August 22, 2017 (shared library 16.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
README for libpng version 1.6.43
|
||||
================================
|
||||
|
||||
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-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get `libpng-*.tar.gz`
|
||||
or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
|
||||
files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been in
|
||||
extensive use and testing since mid-1995. 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 < 1.0. Version 1.0.0 was released in
|
||||
March 1998.
|
||||
For a detailed description on using libpng, read `libpng-manual.txt`.
|
||||
For 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`.
|
||||
|
||||
****
|
||||
Note that some of the changes to the png_info structure render this
|
||||
You should use zlib 1.0.4 or later to run this, but it _may_ work with
|
||||
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
|
||||
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
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
`filler` parameter for `png_set_filler()` has changed from `png_byte`
|
||||
to `png_uint_32`, which will affect shared-library applications that
|
||||
use this function.
|
||||
|
||||
To avoid problems with changes to the internals of the 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
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
access to `info_ptr`. These functions are the `png_set_<chunk>` and
|
||||
`png_get_<chunk>` functions. These functions should be used when
|
||||
accessing/storing the `info_struct` data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
be a transitional release, members of the `png_struct` and the
|
||||
`info_struct` can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
Windows DLL, and new APIs for accessing data in the info struct.
|
||||
Experimental functions include the ability to set weighting and cost
|
||||
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->8 bit color
|
||||
conversion.
|
||||
reside in private `pngstruct.h` and `pnginfo.h` header files that are
|
||||
not accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in `example.c` and `pngtest.c`),
|
||||
and older programs be converted to the new format, to facilitate
|
||||
upgrades in the future.
|
||||
|
||||
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
|
||||
@@ -60,163 +92,93 @@ 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
|
||||
critical or an ancillary chunk.
|
||||
|
||||
The changes made to the library, and bugs fixed are based on discussions
|
||||
on the PNG-implement mailing list and not on material submitted
|
||||
privately to Guy, Andreas, or Glenn. They will forward any good
|
||||
suggestions to the list.
|
||||
The additions since 0.90 include the ability to compile libpng as a
|
||||
Windows DLL, and new APIs for accessing data in the `info_struct`.
|
||||
Experimental functions included the ability to set weighting and cost
|
||||
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
|
||||
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
|
||||
Files included in this distribution
|
||||
-----------------------------------
|
||||
|
||||
I have included a general makefile, as well as several machine and
|
||||
compiler specific ones, but you may have to modify one for your own needs.
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
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 ARM Neon
|
||||
intel/ => Optimized code for INTEL SSE2
|
||||
loongarch/ => Optimized code for LoongArch LSX
|
||||
mips/ => Optimized code for MIPS MSA and MIPS MMI
|
||||
powerpc/ => Optimized code for PowerPC VSX
|
||||
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
|
||||
pngexif/ => Program to inspect the EXIF information in PNG files
|
||||
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
|
||||
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.
|
||||
Good luck, and happy coding!
|
||||
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||
|
||||
This code is currently being archived at libpng.sourceforge.io in the
|
||||
[DOWNLOAD] area, and at http://libpng.download/src . If you
|
||||
can't find it in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
I am not a lawyer, but I believe that the Export Control Classification
|
||||
Number (ECCN) for libpng is EAR99, which means not subject to export
|
||||
controls or International Traffic in Arms Regulations (ITAR) because it
|
||||
is open source, publicly available software, that does not contain any
|
||||
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
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 twenty years now, and it is official and
|
||||
finished. If you have suggestions for libpng, however, I'll
|
||||
gladly listen. Even if your suggestion is not used immediately,
|
||||
it may be used later.
|
||||
|
||||
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
|
||||
powerpc => Contains optimized code for the PowerPC platform
|
||||
contrib => Contributions
|
||||
arm-neon => Optimized code for ARM-NEON platform
|
||||
powerpc-vsx => Optimized code for POWERPC-VSX platform
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
libtests => Test programs
|
||||
mips-msa => Optimized code for MIPS-MSA platform
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
testpngs
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
intel => Optimized code for INTEL-SSE2 platform
|
||||
mips => Optimized code for MIPS platform
|
||||
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
|
||||
* Cosmin Truta (current maintainer, since 2018)
|
||||
* Glenn Randers-Pehrson (former maintainer, 1998-2018)
|
||||
* Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||
(formerly of Group 42, Inc.)
|
||||
|
||||
49
TODO
49
TODO
@@ -1,30 +1,23 @@
|
||||
/*
|
||||
TODO - list of things to do for libpng:
|
||||
|
||||
Final bug fixes.
|
||||
Better C++ wrapper/full C++ implementation?
|
||||
Fix problem with C++ and EXTERN "C".
|
||||
cHRM transformation.
|
||||
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
|
||||
this, minimize the use of png_error(), replacing them with
|
||||
png_warning(); return(0); or similar.
|
||||
Palette creation.
|
||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
Improved dithering.
|
||||
Multi-lingual error and warning message support.
|
||||
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
||||
Man pages for function calls.
|
||||
Better documentation.
|
||||
Better filter selection
|
||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
||||
Histogram creation.
|
||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
||||
Avoid building gamma tables whenever possible.
|
||||
Use greater precision when changing to linear gamma for compositing against
|
||||
background and doing rgb-to-gray transformation.
|
||||
Investigate pre-incremented loop counters and other loop constructions.
|
||||
Add interpolated method of handling interlacing.
|
||||
Extend pngvalid.c to validate more of the libpng transformations.
|
||||
Refactor preprocessor conditionals to compile entire statements
|
||||
|
||||
*/
|
||||
* Fix all defects (duh!)
|
||||
* Better C++ wrapper / full C++ implementation (?)
|
||||
* Fix the problems with C++ and 'extern "C"'.
|
||||
* cHRM transformation.
|
||||
* Palette creation.
|
||||
* "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||
* Improved dithering.
|
||||
* Multi-lingual error and warning message support.
|
||||
* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
|
||||
* Man pages for function calls.
|
||||
* Better documentation.
|
||||
* Better filter selection
|
||||
(e.g., counting huffman bits/precompression; filter inertia; filter costs).
|
||||
* Histogram creation.
|
||||
* Text conversion between different code pages (e.g., Latin-1 -> Mac).
|
||||
* Avoid building gamma tables whenever possible.
|
||||
* Greater precision in changing to linear gamma for compositing against
|
||||
background, and in doing rgb-to-gray transformations.
|
||||
* Investigate pre-incremented loop counters and other loop constructions.
|
||||
* Interpolated method of handling interlacing.
|
||||
* More validations for 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,17 +1,16 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018-2022 Cosmin Truta
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* 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
|
||||
|
||||
#include "../pngpriv.h"
|
||||
@@ -32,21 +31,26 @@
|
||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# if defined(__aarch64__) || defined(_M_ARM64)
|
||||
/* 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
|
||||
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
#include PNG_ARM_NEON_FILE
|
||||
|
||||
#else /* PNG_ARM_NEON_FILE */
|
||||
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||
#endif /* PNG_ARM_NEON_FILE */
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
# include PNG_ARM_NEON_FILE
|
||||
#endif
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -19,7 +18,11 @@
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#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,
|
||||
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||
@@ -33,6 +36,11 @@
|
||||
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||
* warning; note that the code is safe because there never is an alias between
|
||||
* the input and output pointers.
|
||||
*
|
||||
* 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)\
|
||||
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||
@@ -125,12 +133,15 @@ png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
uint8x8x4_t vrp = *vrpt;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
|
||||
|
||||
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||
}
|
||||
|
||||
PNG_UNUSED(prev_row)
|
||||
@@ -223,6 +234,7 @@ png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
@@ -240,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] = 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,6 +372,7 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
uint8x8x4_t *vrpt, *vppt;
|
||||
uint8x8x4_t vrp, vpp;
|
||||
uint32x2x4_t *temp_pointer;
|
||||
uint32x2x4_t vdest_val;
|
||||
|
||||
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||
@@ -378,7 +392,8 @@ png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 */
|
||||
@@ -77,13 +77,14 @@ libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
|
||||
config.sub configure depcomp install-sh ltmain.sh missing\
|
||||
test-driver"
|
||||
#
|
||||
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
|
||||
# Files generated by versions of autoconf >2.68 or automake >1.13 (i.e. later
|
||||
# versions than those required by configure.ac):
|
||||
libpng_autotools_extra="compile config.h.in~"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
||||
libpng_libtool_files="scripts/autoconf/libtool.m4 scripts/autoconf/ltoptions.m4\
|
||||
scripts/autoconf/ltsugar.m4 scripts/autoconf/ltversion.m4\
|
||||
scripts/autoconf/lt~obsolete.m4"
|
||||
|
||||
libpng_autotools_dirs="autom4te.cache" # not required
|
||||
#
|
||||
@@ -194,7 +195,7 @@ case "$mode" in
|
||||
if test -d .git
|
||||
then
|
||||
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 " autotools generated files if Makefile.am or configure.ac"
|
||||
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 "expressions don't expand in single quotes, use double quotes"
|
||||
# advice. We need the regular expressions to remain uninterpolated.
|
||||
disable=SC2016
|
||||
|
||||
# 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
|
||||
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.
|
||||
140
ci/ci_lint.sh
Executable file
140
ci/ci_lint.sh
Executable file
@@ -0,0 +1,140 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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"
|
||||
|
||||
# Initialize the global constants CI_{...}{CHECK,CHECKER,LINT}.
|
||||
CI_SHELLCHECK="${CI_SHELLCHECK:-shellcheck}"
|
||||
CI_EDITORCONFIG_CHECKER="${CI_EDITORCONFIG_CHECKER:-editorconfig-checker}"
|
||||
CI_YAMLLINT="${CI_YAMLLINT:-yamllint}"
|
||||
|
||||
# Initialize the global lint status.
|
||||
CI_LINT_STATUS=0
|
||||
|
||||
function ci_init_lint {
|
||||
ci_info "## START OF LINTING ##"
|
||||
local my_program
|
||||
# Complete the initialization of CI_SHELLCHECK.
|
||||
# Set it to the empty string if the shellcheck program is unavailable.
|
||||
my_program="$(command -v "$CI_SHELLCHECK")" || {
|
||||
ci_warn "program not found: '$CI_SHELLCHECK'"
|
||||
}
|
||||
CI_SHELLCHECK="$my_program"
|
||||
# Complete the initialization of CI_EDITORCONFIG_CHECKER.
|
||||
# Set it to the empty string if the editorconfig-checker program is unavailable.
|
||||
my_program="$(command -v "$CI_EDITORCONFIG_CHECKER")" || {
|
||||
ci_warn "program not found: '$CI_EDITORCONFIG_CHECKER'"
|
||||
}
|
||||
CI_EDITORCONFIG_CHECKER="$my_program"
|
||||
# Complete the initialization of CI_YAMLLINT.
|
||||
# Set it to the empty string if the yamllint program is unavailable.
|
||||
my_program="$(command -v "$CI_YAMLLINT")" || {
|
||||
ci_warn "program not found: '$CI_YAMLLINT'"
|
||||
}
|
||||
CI_YAMLLINT="$my_program"
|
||||
}
|
||||
|
||||
function ci_finish_lint {
|
||||
ci_info "## END OF LINTING ##"
|
||||
if [[ $CI_LINT_STATUS -eq 0 ]]
|
||||
then
|
||||
ci_info "## SUCCESS ##"
|
||||
else
|
||||
ci_info "linting failed"
|
||||
fi
|
||||
return "$CI_LINT_STATUS"
|
||||
}
|
||||
|
||||
function ci_lint_ci_scripts {
|
||||
[[ -x $CI_SHELLCHECK ]] || {
|
||||
ci_warn "## NOT LINTING: CI scripts ##"
|
||||
return 0
|
||||
}
|
||||
ci_info "## LINTING: CI scripts ##"
|
||||
ci_spawn "$CI_SHELLCHECK" --version
|
||||
find ./ci -maxdepth 1 -name "*.sh" | {
|
||||
local my_file
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
ci_spawn "$CI_SHELLCHECK" -x "$my_file" || {
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
function ci_lint_text_files {
|
||||
[[ -x $CI_EDITORCONFIG_CHECKER ]] || {
|
||||
ci_warn "## NOT LINTING: text files ##"
|
||||
return 0
|
||||
}
|
||||
ci_info "## LINTING: text files ##"
|
||||
ci_spawn "$CI_EDITORCONFIG_CHECKER" --version
|
||||
ci_spawn "$CI_EDITORCONFIG_CHECKER" || {
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
function ci_lint_yaml_files {
|
||||
[[ -x $CI_YAMLLINT ]] || {
|
||||
ci_warn "## NOT LINTING: YAML files ##"
|
||||
return 0
|
||||
}
|
||||
ci_info "## LINTING: YAML files ##"
|
||||
ci_spawn "$CI_YAMLLINT" --version
|
||||
find . \( -iname "*.yml" -o -iname "*.yaml" \) -not -path "./out/*" | {
|
||||
local my_file
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
ci_spawn "$CI_YAMLLINT" --strict "$my_file" || {
|
||||
# Linting failed.
|
||||
return 1
|
||||
}
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
function ci_lint {
|
||||
ci_init_lint
|
||||
ci_lint_ci_scripts || CI_LINT_STATUS=1
|
||||
ci_lint_text_files || CI_LINT_STATUS=1
|
||||
ci_lint_yaml_files || CI_LINT_STATUS=1
|
||||
# TODO: ci_lint_png_files, etc.
|
||||
ci_finish_lint
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>]"
|
||||
echo "options: -?|-h|--help"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] || {
|
||||
echo >&2 "error: unexpected argument: '$1'"
|
||||
usage 2
|
||||
}
|
||||
# And... go!
|
||||
ci_lint
|
||||
}
|
||||
|
||||
main "$@"
|
||||
92
ci/ci_shellify.sh
Executable file
92
ci/ci_shellify.sh
Executable file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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"
|
||||
|
||||
function ci_shellify_c {
|
||||
# Convert C preprocessor text, specifically originating
|
||||
# from png.h, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNG_LIBPNG_*.
|
||||
sed -n -e '/^\# *define * PNG_LIBPNG_[^ ]* * ["0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^\# *define * PNG\([^ ]*\) * \([^ ]*\)/PNG\1=\2/' \
|
||||
-e 's/=PNG\([0-9A-Za-z_]*\)/=\${PNG\1}/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify_autoconf {
|
||||
# Convert autoconf (M4) text, specifically originating
|
||||
# from configure.ac, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *PNGLIB_[^ ]*=[$"0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^ *PNG\([0-9A-Za-z_]*\)=\([^# ]*\).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify_cmake {
|
||||
# Convert CMake lists text, specifically originating
|
||||
# from CMakeLists.txt, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *set *(PNGLIB_[^ ]* * [$"0-9A-Za-z_].*)/ p' |
|
||||
sed -e 's/^ *set *(PNG\([^ ]*\) * \([^() ]*\)).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify {
|
||||
local arg filename
|
||||
for arg in "$@"
|
||||
do
|
||||
test -f "$arg" || ci_err "no such file: '$arg'"
|
||||
filename="$(basename -- "$arg")"
|
||||
case "$filename" in
|
||||
( *.[ch] )
|
||||
[[ $filename == png.h ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'png.h')"
|
||||
}
|
||||
ci_shellify_c <"$arg" ;;
|
||||
( config* | *.ac )
|
||||
[[ $filename == configure.ac ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'configure.ac')"
|
||||
}
|
||||
ci_shellify_autoconf <"$arg" ;;
|
||||
( *CMake* | *cmake* | *.txt )
|
||||
[[ $filename == [Cc][Mm]ake[Ll]ists.txt ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'CMakeLists.txt')"
|
||||
}
|
||||
ci_shellify_cmake <"$arg" ;;
|
||||
( * )
|
||||
ci_err "unable to shellify: '$arg'" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] <files>..."
|
||||
echo "options: -?|-h|--help"
|
||||
echo "files: png.h|configure.ac|CMakeLists.txt"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
# And... go!
|
||||
ci_shellify "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
219
ci/ci_verify_cmake.sh
Executable file
219
ci/ci_verify_cmake.sh
Executable file
@@ -0,0 +1,219 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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}"
|
||||
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"
|
||||
}
|
||||
elif [[ -x $(command -v ninja) ]]
|
||||
then
|
||||
CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
|
||||
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_FORCE: '$CI_FORCE'"
|
||||
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 {
|
||||
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||
[[ ! -e $CI_BUILD_DIR && ! -e $CI_INSTALL_DIR ]] || {
|
||||
ci_spawn rm -fr "$CI_BUILD_DIR"
|
||||
ci_spawn rm -fr "$CI_INSTALL_DIR"
|
||||
}
|
||||
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||
}
|
||||
|
||||
function ci_build {
|
||||
ci_info "## START OF BUILD ##"
|
||||
# Adjust the CI environment variables, as needed.
|
||||
CI_CMAKE="$(command -v "$CI_CMAKE")" || ci_err "bad or missing \$CI_CMAKE"
|
||||
ci_spawn "$CI_CMAKE" --version
|
||||
CI_CTEST="$(command -v "$CI_CTEST")" || ci_err "bad or missing \$CI_CTEST"
|
||||
ci_spawn "$CI_CTEST" --version
|
||||
[[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && {
|
||||
CI_NINJA="$(command -v ninja)" || ci_err "bad or missing ninja, no pun intended"
|
||||
ci_spawn "$CI_NINJA" --version
|
||||
}
|
||||
[[ $CI_AR ]] && {
|
||||
# Use the full path of CI_AR to work around a mysterious CMake error.
|
||||
CI_AR="$(command -v "$CI_AR")" || ci_err "bad or missing \$CI_AR"
|
||||
}
|
||||
[[ $CI_RANLIB ]] && {
|
||||
# Use the full path of CI_RANLIB to work around a mysterious CMake error.
|
||||
CI_RANLIB="$(command -v "$CI_RANLIB")" || ci_err "bad or missing \$CI_RANLIB"
|
||||
}
|
||||
# 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"
|
||||
}
|
||||
# Initialize and populate the local arrays.
|
||||
local all_cmake_vars=()
|
||||
local all_cmake_build_flags=()
|
||||
local all_ctest_flags=()
|
||||
[[ $CI_CMAKE_TOOLCHAIN_FILE ]] && {
|
||||
all_cmake_vars+=("-DCMAKE_TOOLCHAIN_FILE=$CI_CMAKE_TOOLCHAIN_FILE")
|
||||
}
|
||||
[[ $CI_CC ]] && {
|
||||
all_cmake_vars+=("-DCMAKE_C_COMPILER=$CI_CC")
|
||||
}
|
||||
[[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && {
|
||||
[[ $CI_SANITIZERS ]] && CI_CC_FLAGS+="${CI_CC_FLAGS:+" "}-fsanitize=$CI_SANITIZERS"
|
||||
all_cmake_vars+=("-DCMAKE_C_FLAGS=$CI_CC_FLAGS")
|
||||
}
|
||||
[[ $CI_AR ]] && {
|
||||
all_cmake_vars+=("-DCMAKE_AR=$CI_AR")
|
||||
}
|
||||
[[ $CI_RANLIB ]] && {
|
||||
all_cmake_vars+=("-DCMAKE_RANLIB=$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)
|
||||
all_cmake_build_flags+=($CI_CMAKE_BUILD_FLAGS)
|
||||
all_ctest_flags+=($CI_CTEST_FLAGS)
|
||||
# And... 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 [<options>]"
|
||||
echo "options: -?|-h|--help"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
# And... go!
|
||||
ci_init_build
|
||||
ci_trace_build
|
||||
[[ $# -eq 0 ]] || {
|
||||
echo >&2 "error: unexpected argument: '$1'"
|
||||
echo >&2 "note: this program accepts environment options only"
|
||||
usage 2
|
||||
}
|
||||
ci_cleanup_old_build
|
||||
ci_build
|
||||
}
|
||||
|
||||
main "$@"
|
||||
175
ci/ci_verify_configure.sh
Executable file
175
ci/ci_verify_configure.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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_FORCE: '$CI_FORCE'"
|
||||
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 {
|
||||
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||
[[ ! -e $CI_BUILD_DIR && ! -e $CI_INSTALL_DIR ]] || {
|
||||
ci_spawn rm -fr "$CI_BUILD_DIR"
|
||||
ci_spawn rm -fr "$CI_INSTALL_DIR"
|
||||
}
|
||||
[[ ! -e "$CI_SRC_DIR/config.status" ]] || {
|
||||
ci_warn "unexpected build configuration file: '$CI_SRC_DIR/config.status'"
|
||||
if ci_expr $((CI_FORCE))
|
||||
then
|
||||
# Delete the old config and (possibly) the old build.
|
||||
ci_info "note: forcing an in-tree build cleanup"
|
||||
if [[ -f $CI_SRC_DIR/Makefile ]]
|
||||
then
|
||||
ci_spawn make -C "$CI_SRC_DIR" distclean
|
||||
else
|
||||
ci_spawn rm -fr "$CI_SRC_DIR"/config.{log,status}
|
||||
fi
|
||||
else
|
||||
# Alert the user, but do not delete their files.
|
||||
ci_warn "the configure script might fail"
|
||||
ci_info "hint: consider using the option \$CI_FORCE=1"
|
||||
fi
|
||||
}
|
||||
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||
}
|
||||
|
||||
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="${CFLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS"
|
||||
ci_spawn export LDFLAGS="${LDFLAGS}${LDFLAGS:+" "}-fsanitize=$CI_SANITIZERS"
|
||||
}
|
||||
# And... 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 [<options>]"
|
||||
echo "options: -?|-h|--help"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
# And... go!
|
||||
ci_init_build
|
||||
ci_trace_build
|
||||
[[ $# -eq 0 ]] || {
|
||||
echo >&2 "error: unexpected argument: '$1'"
|
||||
echo >&2 "note: this program accepts environment options only"
|
||||
usage 2
|
||||
}
|
||||
ci_cleanup_old_build
|
||||
ci_build
|
||||
}
|
||||
|
||||
main "$@"
|
||||
197
ci/ci_verify_makefiles.sh
Executable file
197
ci/ci_verify_makefiles.sh
Executable file
@@ -0,0 +1,197 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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_FORCE: '$CI_FORCE'"
|
||||
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 find_args=(-maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \))
|
||||
[[ ! $(find "$CI_SRC_DIR" "${find_args[@]}" | head -n1) ]] || {
|
||||
ci_warn "unexpected build found in '$CI_SRC_DIR'"
|
||||
if ci_expr $((CI_FORCE))
|
||||
then
|
||||
# Delete the old build.
|
||||
local my_file
|
||||
find "$CI_SRC_DIR" "${find_args[@]}" |
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
ci_spawn rm -fr "$my_file"
|
||||
done
|
||||
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||
else
|
||||
# Alert the user, but do not delete their existing files,
|
||||
# and do not mess up their existing build.
|
||||
ci_info "hint: consider using the option \$CI_FORCE=1"
|
||||
ci_err "unable to continue"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
function ci_build {
|
||||
ci_info "## START OF BUILD ##"
|
||||
# Initialize and populate the local arrays.
|
||||
local all_make_flags=()
|
||||
local all_make_vars=()
|
||||
[[ $CI_MAKE_FLAGS ]] && {
|
||||
all_make_flags+=($CI_MAKE_FLAGS)
|
||||
}
|
||||
[[ $CI_CC ]] && {
|
||||
all_make_vars+=("CC=$CI_CC")
|
||||
}
|
||||
[[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && {
|
||||
[[ $CI_SANITIZERS ]] && CI_CC_FLAGS="${CI_CC_FLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS"
|
||||
all_make_vars+=("CFLAGS=$CI_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")
|
||||
}
|
||||
[[ $CI_RANLIB ]] && {
|
||||
all_make_vars+=("RANLIB=$CI_RANLIB")
|
||||
}
|
||||
[[ $CI_LD ]] && {
|
||||
all_make_vars+=("LD=$CI_LD")
|
||||
}
|
||||
[[ $CI_LD_FLAGS || $CI_SANITIZERS ]] && {
|
||||
[[ $CI_SANITIZERS ]] && CI_LD_FLAGS+="${CI_LD_FLAGS:+" "}-fsanitize=$CI_SANITIZERS"
|
||||
all_make_vars+=("LDFLAGS=$CI_LD_FLAGS")
|
||||
}
|
||||
[[ $CI_LIBS ]] && {
|
||||
all_make_vars+=("LIBS=$CI_LIBS")
|
||||
}
|
||||
all_make_vars+=($CI_MAKE_VARS)
|
||||
# And... 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 [<options>]"
|
||||
echo "options: -?|-h|--help"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
# And... go!
|
||||
ci_init_build
|
||||
ci_trace_build
|
||||
[[ $# -eq 0 ]] || {
|
||||
echo >&2 "error: unexpected argument: '$1'"
|
||||
echo >&2 "note: this program accepts environment options only"
|
||||
usage 2
|
||||
}
|
||||
ci_cleanup_old_build
|
||||
ci_build
|
||||
}
|
||||
|
||||
main "$@"
|
||||
163
ci/ci_verify_version.sh
Executable file
163
ci/ci_verify_version.sh
Executable file
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# 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"
|
||||
|
||||
function ci_init_shellify {
|
||||
[[ -f $CI_SCRIPT_DIR/ci_shellify.sh ]] || {
|
||||
ci_err_internal "missing script: '$CI_SCRIPT_DIR/ci_shellify.sh'"
|
||||
}
|
||||
}
|
||||
|
||||
function ci_run_shellify {
|
||||
ci_info "shellifying:" "$@"
|
||||
local my_result
|
||||
"$BASH" "$CI_SCRIPT_DIR/ci_shellify.sh" "$@"
|
||||
echo "$my_result" | "$BASH" --posix || ci_err "bad shellify output"
|
||||
echo "$my_result"
|
||||
}
|
||||
|
||||
function ci_verify_version {
|
||||
ci_info "## START OF VERIFICATION ##"
|
||||
local my_env_libpng_ver my_env_autoconf_ver my_env_cmake_ver my_expect
|
||||
ci_init_shellify
|
||||
my_env_libpng_ver="$(ci_run_shellify png.h)"
|
||||
echo "$my_env_libpng_ver"
|
||||
my_env_autoconf_ver="$(ci_run_shellify configure.ac)"
|
||||
echo "$my_env_autoconf_ver"
|
||||
my_env_cmake_ver="$(ci_run_shellify CMakeLists.txt)"
|
||||
echo "$my_env_cmake_ver"
|
||||
ci_info "## VERIFYING: png.h version definitions ##"
|
||||
eval "$my_env_libpng_ver"
|
||||
local my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
|
||||
if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect"* ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_STRING == $my_expect*"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_STRING != $my_expect*"
|
||||
fi
|
||||
my_expect=$((PNG_LIBPNG_VER_MAJOR*10000 + PNG_LIBPNG_VER_MINOR*100 + PNG_LIBPNG_VER_RELEASE))
|
||||
if [[ "$PNG_LIBPNG_VER" == "$my_expect" ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER == $my_expect"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER != $my_expect"
|
||||
fi
|
||||
my_expect=$((PNG_LIBPNG_VER_MAJOR*10 + PNG_LIBPNG_VER_MINOR))
|
||||
if [[ "$PNG_LIBPNG_VER_SHAREDLIB" == "$my_expect" ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_SHAREDLIB == $my_expect"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_SHAREDLIB != $my_expect"
|
||||
fi
|
||||
if [[ "$PNG_LIBPNG_VER_SONUM" == "$my_expect" ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_SONUM == $my_expect"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_SONUM != $my_expect"
|
||||
fi
|
||||
if [[ "$PNG_LIBPNG_VER_DLLNUM" == "$my_expect" ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_DLLNUM == $my_expect"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_DLLNUM != $my_expect"
|
||||
fi
|
||||
if [[ "$PNG_LIBPNG_VER_BUILD" == [01] ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_BUILD == [01]"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD != [01]"
|
||||
fi
|
||||
ci_info "## VERIFYING: png.h build definitions ##"
|
||||
my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
|
||||
if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect" ]]
|
||||
then
|
||||
if [[ $PNG_LIBPNG_VER_BUILD -eq 0 ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_BUILD -eq 0"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -ne 0"
|
||||
fi
|
||||
if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_STABLE ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_BETA"
|
||||
fi
|
||||
elif [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect".git ]]
|
||||
then
|
||||
if [[ $PNG_LIBPNG_VER_BUILD -ne 0 ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_BUILD -ne 0"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -eq 0"
|
||||
fi
|
||||
if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_BETA ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_BETA"
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_BETA"
|
||||
fi
|
||||
else
|
||||
ci_err "unexpected: \$PNG_LIBPNG_VER_STRING == '$PNG_LIBPNG_VER_STRING'"
|
||||
fi
|
||||
ci_info "## VERIFYING: png.h type definitions ##"
|
||||
my_expect="$(echo "png_libpng_version_${PNG_LIBPNG_VER_STRING}" | tr . _)"
|
||||
ci_spawn grep -w -e "$my_expect" png.h
|
||||
ci_info "## VERIFYING: configure.ac version definitions ##"
|
||||
eval "$my_env_autoconf_ver"
|
||||
if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" ]]
|
||||
then
|
||||
ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
|
||||
else
|
||||
ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
|
||||
fi
|
||||
ci_info "## VERIFYING: CMakeLists.txt version definitions ##"
|
||||
eval "$my_env_cmake_ver"
|
||||
if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" && "$PNGLIB_SUBREVISION" == 0 ]]
|
||||
then
|
||||
ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
|
||||
ci_info "matched: \$PNGLIB_SUBREVISION == 0"
|
||||
elif [[ "$PNGLIB_VERSION.$PNGLIB_SUBREVISION" == "$PNG_LIBPNG_VER_STRING" ]]
|
||||
then
|
||||
ci_info "matched: \$PNGLIB_VERSION.\$PNGLIB_SUBREVISION == \$PNG_LIBPNG_VER_STRING"
|
||||
else
|
||||
ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
|
||||
fi
|
||||
ci_info "## END OF VERIFICATION ##"
|
||||
ci_info "success!"
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>]"
|
||||
echo "options: -?|-h|--help"
|
||||
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 || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] || {
|
||||
echo >&2 "error: unexpected argument: '$1'"
|
||||
usage 2
|
||||
}
|
||||
# And... go!
|
||||
ci_verify_version
|
||||
}
|
||||
|
||||
main "$@"
|
||||
102
ci/lib/ci.lib.sh
Normal file
102
ci/lib/ci.lib.sh
Normal file
@@ -0,0 +1,102 @@
|
||||
# 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_FORCE:-0} == [01] ]] || {
|
||||
ci_err "bad boolean option: \$CI_FORCE: '$CI_FORCE'"
|
||||
}
|
||||
[[ ${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
350
configure.ac
350
configure.ac
@@ -1,7 +1,7 @@
|
||||
# configure.ac
|
||||
|
||||
# Copyright (c) 2018-2024 Cosmin Truta
|
||||
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||
# Last changed in libpng 1.6.25 [September 1, 2016]
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -25,8 +25,8 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.32rc02],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
AC_INIT([libpng],[1.6.43],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts/autoconf])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
# color-tests requires automake 1.11 or later
|
||||
@@ -46,17 +46,17 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.32rc02
|
||||
PNGLIB_VERSION=1.6.43
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=32
|
||||
PNGLIB_RELEASE=43
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
AC_CONFIG_SRCDIR([pngget.c])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
# Checks for programs.
|
||||
# Check for basic programs.
|
||||
AC_LANG([C])
|
||||
AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
@@ -72,16 +72,19 @@ dnl compatible later version may be used
|
||||
LT_INIT([win32-dll])
|
||||
LT_PREREQ([2.4.2])
|
||||
|
||||
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
|
||||
# to make sure this doesn't happen
|
||||
AC_MSG_CHECKING([that AWK works])
|
||||
dnl Declare the AWK variable.
|
||||
AC_ARG_VAR(AWK, [AWK language processor])
|
||||
|
||||
# Some awk implementations crash when confronted with pnglibconf.dfa.
|
||||
# Run a test now, to make sure this doesn't happen.
|
||||
AC_MSG_CHECKING([if awk ($AWK) works])
|
||||
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
|
||||
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||
${srcdir}/pngusr.dfa 1>&2
|
||||
then
|
||||
AC_MSG_RESULT([ok])
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_FAILURE([failed], 1)
|
||||
AC_MSG_FAILURE([no], 1)
|
||||
fi
|
||||
|
||||
# This is a remnant of the old cc -E validation, where it may have been
|
||||
@@ -89,11 +92,29 @@ fi
|
||||
DFNCPP="$CPP"
|
||||
AC_SUBST(DFNCPP)
|
||||
|
||||
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||
# checks the compiler with a program that generates a warning), add the
|
||||
# following option to deal with this
|
||||
AC_ARG_ENABLE([tests],
|
||||
AS_HELP_STRING([--disable-tests],
|
||||
[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,
|
||||
[additional flags for the C compiler, use this for options that would]
|
||||
[additional flags for the C compiler, to be used for options that would]
|
||||
[cause configure itself to fail])
|
||||
AC_ARG_ENABLE(werror,
|
||||
AS_HELP_STRING([[[--enable-werror[=OPT]]]],
|
||||
@@ -114,10 +135,10 @@ AC_ARG_ENABLE(werror,
|
||||
CFLAGS="$sav_CFLAGS"
|
||||
fi],)
|
||||
|
||||
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
|
||||
# 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:
|
||||
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89.
|
||||
# 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([
|
||||
@@ -133,23 +154,17 @@ AC_COMPILE_IFELSE(
|
||||
CFLAGS="$CFLAGS -std=c89"
|
||||
])
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
# Checks for structures and compiler characteristics.
|
||||
AC_STRUCT_TM
|
||||
AC_C_RESTRICT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||
AC_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])])
|
||||
# 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,
|
||||
@@ -157,8 +172,9 @@ AC_ARG_WITH(zlib-prefix,
|
||||
[prefix that may have been used in installed zlib]),
|
||||
[ZPREFIX=${withval}],
|
||||
[ZPREFIX='z_'])
|
||||
AC_CHECK_LIB(z, zlibVersion, ,
|
||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
||||
AC_CHECK_LIB([z], [zlibVersion], ,
|
||||
[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
|
||||
# platforms that don't enable FP exceptions, the function appears in the math
|
||||
@@ -210,9 +226,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||
if test "$have_ld_version_script" = "yes"; then
|
||||
AC_MSG_CHECKING([for symbol prefix])
|
||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||
| ${EGREP-grep} "^PREFIX=" \
|
||||
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
| ${CPP:-${CC:-gcc} -E} - 2>&1 \
|
||||
| ${EGREP:-grep} "^PREFIX=" \
|
||||
| ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||
AC_SUBST(SYMBOL_PREFIX)
|
||||
AC_MSG_RESULT($SYMBOL_PREFIX)
|
||||
fi
|
||||
@@ -297,7 +313,7 @@ AC_ARG_ENABLE([unversioned-libpng-config],
|
||||
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||
[test "$enable_unversioned_libpng_config" != "no"])
|
||||
|
||||
# HOST SPECIFIC OPTIONS
|
||||
# HOST-SPECIFIC OPTIONS
|
||||
# =====================
|
||||
#
|
||||
# DEFAULT
|
||||
@@ -305,7 +321,7 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||
#
|
||||
AC_ARG_ENABLE([hardware-optimizations],
|
||||
AS_HELP_STRING([[[--enable-hardware-optimizations]]],
|
||||
[Enable hardware optimizations: =no/off, yes/on:]),
|
||||
[Enable hardware optimizations: =no/off, yes/on.]),
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
# disable hardware optimization on all systems:
|
||||
@@ -315,24 +331,33 @@ AC_ARG_ENABLE([hardware-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], [0],
|
||||
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_MSA_OPT], [0],
|
||||
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)
|
||||
@@ -345,21 +370,25 @@ AC_ARG_ENABLE([hardware-optimizations],
|
||||
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 NEON (SIMD) support.
|
||||
# ARM NEON
|
||||
# ========
|
||||
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]],
|
||||
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
|
||||
[no/off: disable the optimizations; check: use internal checking code]
|
||||
[(deprecated and poorly supported); api: disable by default, enable by]
|
||||
[a call to png_set_option; yes/on: turn on unconditionally.]
|
||||
[Enable ARM NEON optimizations: =no/off, check, api, yes/on.]
|
||||
[no/off: disable the optimizations;]
|
||||
[check: use internal checking code (deprecated and poorly supported);]
|
||||
[api: disable by default, enable by a call to png_set_option;]
|
||||
[yes/on: turn on unconditionally.]
|
||||
[If not specified: determined by the compiler.]),
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
@@ -367,7 +396,7 @@ AC_ARG_ENABLE([arm-neon],
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||
[Disable ARM Neon optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_arm_neon=no;;
|
||||
enable_arm_neon=no ;;
|
||||
check)
|
||||
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||
[Check for ARM Neon support at run-time]);;
|
||||
@@ -377,35 +406,35 @@ AC_ARG_ENABLE([arm-neon],
|
||||
yes|on)
|
||||
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||
[Enable ARM Neon optimizations])
|
||||
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
|
||||
[you want the optimizations unconditionally pass -mfpu=neon]
|
||||
[to the compiler.]);;
|
||||
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';]
|
||||
[if you want the optimizations unconditionally,]
|
||||
[pass '-mfpu=neon' to the compiler.]);;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
||||
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:]
|
||||
[invalid argument])
|
||||
esac])
|
||||
|
||||
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
|
||||
# where ARM optimizations were explicitly requested (this allows a fallback if a
|
||||
# future host CPU does not match 'arm*')
|
||||
# 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 future host CPU does not match 'arm*'.)
|
||||
|
||||
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||
[test "$enable_arm_neon" != 'no' &&
|
||||
case "$host_cpu" in
|
||||
arm*|aarch64*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
arm*|aarch64*) : ;;
|
||||
*) test "$enable_arm_neon" != '' ;;
|
||||
esac])
|
||||
|
||||
# MIPS
|
||||
# ===
|
||||
#
|
||||
# MIPS MSA (SIMD) support.
|
||||
# MIPS MSA
|
||||
# ========
|
||||
|
||||
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.]
|
||||
[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)
|
||||
@@ -413,7 +442,7 @@ AC_ARG_ENABLE([mips-msa],
|
||||
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||
[Disable MIPS MSA optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_mips_msa=no;;
|
||||
enable_mips_msa=no ;;
|
||||
check)
|
||||
AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
|
||||
[Check for MIPS MSA support at run-time]);;
|
||||
@@ -423,31 +452,75 @@ AC_ARG_ENABLE([mips-msa],
|
||||
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_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])
|
||||
AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:]
|
||||
[invalid argument])
|
||||
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*')
|
||||
# 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*) :;;
|
||||
mipsel*|mips64el*) : ;;
|
||||
esac])
|
||||
|
||||
# INTEL
|
||||
# =====
|
||||
#
|
||||
# INTEL SSE (SIMD) support.
|
||||
# MIPS MMI
|
||||
# ========
|
||||
|
||||
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 argument])
|
||||
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 SSE
|
||||
# =========
|
||||
|
||||
AC_ARG_ENABLE([intel-sse],
|
||||
AS_HELP_STRING([[[--enable-intel-sse]]],
|
||||
[Enable Intel SSE optimizations: =no/off, yes/on:]
|
||||
[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.]),
|
||||
@@ -457,34 +530,34 @@ AC_ARG_ENABLE([intel-sse],
|
||||
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||
[Disable Intel SSE optimizations])
|
||||
# Prevent inclusion of the assembler files below:
|
||||
enable_intel_sse=no;;
|
||||
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])
|
||||
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:]
|
||||
[invalid argument])
|
||||
esac])
|
||||
|
||||
# Add Intel specific files to all builds where the 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*')
|
||||
# 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" != '';;
|
||||
i?86|x86_64) : ;;
|
||||
*) test "$enable_intel_sse" != '' ;;
|
||||
esac])
|
||||
|
||||
# PowerPC
|
||||
# ===
|
||||
#
|
||||
# PowerPC VSX (SIMD) support.
|
||||
# POWERPC VSX
|
||||
# ===========
|
||||
|
||||
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]
|
||||
[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
|
||||
@@ -492,36 +565,101 @@ AS_HELP_STRING([[[--enable-powerpc-vsx]]],
|
||||
# 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;;
|
||||
# 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.]);;
|
||||
AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README]
|
||||
[for the list of supported systems.]);;
|
||||
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_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])
|
||||
AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:]
|
||||
[invalid argument])
|
||||
esac])
|
||||
|
||||
# Add PowerPC specific files to all builds where the 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*')
|
||||
# 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*) :;;
|
||||
powerpc*|ppc64*) : ;;
|
||||
esac])
|
||||
|
||||
# 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 argument])
|
||||
esac])
|
||||
|
||||
if test "$enable_loongarch_lsx" != "no" &&
|
||||
case "$host_cpu" in
|
||||
loongarch*) : ;;
|
||||
*) test "$enable_loongarch_lsx" != '' ;;
|
||||
esac
|
||||
then
|
||||
compiler_support_loongarch_lsx=no
|
||||
AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics)
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
|
||||
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)
|
||||
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])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
|
||||
7
contrib/.editorconfig
Normal file
7
contrib/.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = false
|
||||
|
||||
[*.[ch]]
|
||||
max_doc_length = unset
|
||||
max_line_length = unset
|
||||
@@ -2,7 +2,6 @@
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -24,6 +23,7 @@
|
||||
* has been compiled only, not linked: no version of the library has been found,
|
||||
* only the header files exist in the NDK.
|
||||
*/
|
||||
|
||||
#include <cpu-features.h>
|
||||
|
||||
static int
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -22,6 +21,7 @@
|
||||
* This generic __linux__ implementation requires reading /proc/self/auxv and
|
||||
* looking at each element for one that records NEON capabilities.
|
||||
*/
|
||||
|
||||
#include <unistd.h> /* for POSIX 1003.1 */
|
||||
#include <errno.h> /* for EINTR */
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* contrib/arm-neon/linux.c
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 2014, 2017 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014, 2017.
|
||||
*
|
||||
@@ -19,6 +18,7 @@
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static int
|
||||
|
||||
133
contrib/conftest/basic.dfa
Normal file
133
contrib/conftest/basic.dfa
Normal file
@@ -0,0 +1,133 @@
|
||||
# basic.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2024
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with basic read and write support. This enables the lowest
|
||||
# level libpng read and write APIs - the "row-by-row" ones.
|
||||
#
|
||||
# Support is enabled only for those transformations that are observed to be
|
||||
# required by widely used apps or are in the v3 specification.
|
||||
#
|
||||
|
||||
everything = off
|
||||
|
||||
# The sequential read code is enabled here; the progressive code can be used
|
||||
# instead but there is no point enabling both.
|
||||
|
||||
option READ on
|
||||
option SEQUENTIAL_READ on
|
||||
option EASY_ACCESS on
|
||||
option SET_USER_LIMITS on
|
||||
option INFO_IMAGE on
|
||||
option READ_16BIT on
|
||||
|
||||
# Errors: these can be disabled but then there won't be any error messages
|
||||
# just failures and the error messages are really needed for apps:
|
||||
option WARNINGS on
|
||||
option ERROR_TEXT on
|
||||
option BENIGN_READ_ERRORS on
|
||||
|
||||
# Required for many display programs such as web browsers:
|
||||
option PROGRESSIVE_READ on
|
||||
|
||||
# Switch on the write code - this makes a minimalist encoder but with
|
||||
# interlace support turned on; otherwise png_read_png..png_write_png will
|
||||
# fail on an interlaced image.
|
||||
option WRITE on
|
||||
option WRITE_INTERLACING on
|
||||
option WRITE_16BIT on
|
||||
|
||||
# Usages of the 'fixed' APIs are relatively rare but they do occur
|
||||
# one or the other for both the API and the internal math.
|
||||
|
||||
#Fixed point:
|
||||
option FIXED_POINT on
|
||||
|
||||
#Floating point:
|
||||
option FLOATING_POINT on
|
||||
option FLOATING_ARITHMETIC on
|
||||
|
||||
# Basic error handling, IO and user memory support. The latter allows the
|
||||
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||
option SETJMP on
|
||||
option STDIO on
|
||||
option USER_MEM on
|
||||
|
||||
# Gamma handling: this needs to be on for the gamma handling
|
||||
option READ_GAMMA on
|
||||
|
||||
# The supported chunks
|
||||
chunk bKGD on
|
||||
chunk cHRM on
|
||||
chunk eXIf on
|
||||
chunk gAMA on
|
||||
chunk iCCP on
|
||||
chunk iTXt on
|
||||
chunk pHYs on
|
||||
chunk sBIT on
|
||||
chunk sRGB on
|
||||
chunk tEXt on
|
||||
chunk tIME on
|
||||
chunk tRNS on
|
||||
chunk zTXt on
|
||||
|
||||
# These don't seem to be used anywhere:
|
||||
# chunk pCAL
|
||||
# chunk sCAL
|
||||
# chunk sPLT
|
||||
|
||||
# The rest of this is app dependent: none of these options are required for
|
||||
# read/write of the full range of PNG files and the normal chunk handling on
|
||||
# read.
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||
option WRITE_CUSTOMIZE_COMPRESSION on
|
||||
|
||||
option READ_EXPAND on
|
||||
option READ_FILLER on
|
||||
option READ_GRAY_TO_RGB on
|
||||
option READ_INVERT on
|
||||
option READ_PACK on
|
||||
option READ_RGB_TO_GRAY on
|
||||
option READ_SCALE_16_TO_8 on
|
||||
option READ_SHIFT on
|
||||
option READ_STRIP_16_TO_8 on
|
||||
option READ_STRIP_ALPHA on
|
||||
option READ_SWAP on
|
||||
|
||||
option CONVERT_tIME on
|
||||
|
||||
# optipng
|
||||
option IO_STATE on
|
||||
option STORE_UNKNOWN_CHUNKS on
|
||||
option HANDLE_AS_UNKNOWN on
|
||||
|
||||
# pngcrush
|
||||
option READ_USER_TRANSFORM on
|
||||
option WRITE_FLUSH on
|
||||
|
||||
# pnmtopng
|
||||
chunk hIST on
|
||||
|
||||
# cairo
|
||||
option WRITE_PACKSWAP on
|
||||
option WRITE_USER_TRANSFORM on
|
||||
|
||||
# graphicsmagick
|
||||
option READ_USER_CHUNKS on
|
||||
|
||||
# Qt5.15 qtgui (gentoo package split) Qt6.6 qtbase
|
||||
option READ_BGR on
|
||||
option WRITE_BGR on
|
||||
option READ_SWAP_ALPHA on
|
||||
option WRITE_SWAP_ALPHA on
|
||||
chunk oFFs on
|
||||
|
||||
# ghostscript-gpl
|
||||
option WRITE_INVERT_ALPHA on
|
||||
option WRITE_INVERT on
|
||||
@@ -33,7 +33,7 @@ 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 suppport
|
||||
# pngcp can work without explicit known chunk reading support
|
||||
option UNKNOWN_CHUNKS on
|
||||
option SET_UNKNOWN_CHUNKS on
|
||||
option HANDLE_AS_UNKNOWN on
|
||||
@@ -52,6 +52,6 @@ option TEXT on
|
||||
option USER_LIMITS on
|
||||
option SET_USER_LIMITS on
|
||||
|
||||
# these are are just required for specific customizations
|
||||
# these are just required for specific customizations
|
||||
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||
option WRITE_CUSTOMIZE_COMPRESSION on
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* without processing the image. Notice that some header information may occur
|
||||
* after the image data. Textual data and comments are an example; the approach
|
||||
* in this file won't work reliably for such data because it only looks for the
|
||||
* information in the section of the file that preceeds the image data.
|
||||
* 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
|
||||
* system you use.
|
||||
@@ -80,7 +80,7 @@ extract(FILE *fp, png_uint_32 *proflen)
|
||||
}
|
||||
|
||||
else
|
||||
result = no_profile;
|
||||
result = no_profile;
|
||||
}
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
@@ -155,7 +155,7 @@ extract_one_file(const char *filename)
|
||||
}
|
||||
|
||||
else if (verbose && profile == no_profile)
|
||||
printf("%s has no profile\n", filename);
|
||||
printf("%s has no profile\n", filename);
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
@@ -42,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_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;
|
||||
bit_offset_lo &= 0x07;
|
||||
|
||||
@@ -73,7 +73,7 @@ static void
|
||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
png_uint_32 x)
|
||||
{
|
||||
PNG_CONST unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
switch (png_get_color_type(png_ptr, info_ptr))
|
||||
{
|
||||
@@ -87,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
*/
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
{
|
||||
PNG_CONST int index = component(row, x, 0, bit_depth, 1);
|
||||
int index = component(row, x, 0, bit_depth, 1);
|
||||
png_colorp palette = NULL;
|
||||
int num_palette = 0;
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* related or neighboring rights to this work. This work is published from:
|
||||
* United States.
|
||||
*
|
||||
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||
*
|
||||
* Read a PNG and write it out in a fixed format, using the 'simplified API'
|
||||
* that was introduced in libpng-1.6.0.
|
||||
*
|
||||
|
||||
@@ -146,7 +146,7 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||
/* These byte strings were copied from png.h. If a future version
|
||||
* 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 */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
- 1.10: added support for non-default visuals; fixed X pixel-conversion
|
||||
- 1.11: added extra set of parentheses to png_jmpbuf() macro; fixed
|
||||
command-line parsing bug
|
||||
- 1.12: fixed some small X memory leaks (thanks to Fran<EFBFBD>ois Petitjean)
|
||||
- 1.12: fixed some small X memory leaks (thanks to François Petitjean)
|
||||
- 1.13: fixed XFreeGC() crash bug (thanks to Patrick Welche)
|
||||
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
|
||||
- 2.00: dual-licensed (added GNU GPL)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
- 1.11: added -usleep option for demos; fixed command-line parsing bug
|
||||
- 1.12: added -pause option for demos and testing
|
||||
- 1.20: added runtime MMX-enabling/disabling and new -mmx* options
|
||||
- 1.21: fixed some small X memory leaks (thanks to Fran<EFBFBD>ois Petitjean)
|
||||
- 1.21: fixed some small X memory leaks (thanks to François Petitjean)
|
||||
- 1.22: fixed XFreeGC() crash bug (thanks to Patrick Welche)
|
||||
- 1.23: added -bgpat 0 mode (std white/gray checkerboard, 8x8 squares)
|
||||
- 1.30: added -loop option for -bgpat (ifdef FEATURE_LOOP); fixed bpp =
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#
|
||||
# Copyright (c) 2013 John Cunningham Bowler
|
||||
#
|
||||
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
/* Copyright: */
|
||||
#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler"
|
||||
/*
|
||||
* Last changed in libpng 1.6.20 [November 24, 2015]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -299,25 +297,28 @@ generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
|
||||
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
|
||||
*/
|
||||
# define interp(pos, c1, c2) ((pos * c1) + ((size-pos) * c2))
|
||||
# define xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
||||
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
||||
(size*size))
|
||||
/* 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 xyinterp(x, y, c1, c2, c3, c4) (((size * size / 2) +\
|
||||
(interp(x, c1, c2) * y + (size-y) * interp(x, c3, c4))) /\
|
||||
(size*size))
|
||||
|
||||
set_color(palette+ip, trans+ip,
|
||||
/* color: green, red,blue,white */
|
||||
xyinterp(x, y, 0, 255, 0, 255),
|
||||
xyinterp(x, y, 255, 0, 0, 255),
|
||||
xyinterp(x, y, 0, 0, 255, 255),
|
||||
/* alpha: 0, 102, 204, 255) */
|
||||
xyinterp(x, y, 0, 102, 204, 255),
|
||||
gamma_table);
|
||||
set_color(palette+ip, trans+ip,
|
||||
/* color: green, red,blue,white */
|
||||
xyinterp(x, y, 0, 255, 0, 255),
|
||||
xyinterp(x, y, 255, 0, 0, 255),
|
||||
xyinterp(x, y, 0, 0, 255, 255),
|
||||
/* alpha: 0, 102, 204, 255) */
|
||||
xyinterp(x, y, 0, 102, 204, 255),
|
||||
gamma_table);
|
||||
}
|
||||
}
|
||||
|
||||
return ip+1;
|
||||
@@ -396,7 +397,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
image_size_of_type(color_type, bit_depth, colors, small)-1;
|
||||
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
|
||||
|
||||
if (colors[0] == 0) if (small)
|
||||
if (colors[0] == 0 && small)
|
||||
{
|
||||
unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
@@ -495,7 +496,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
case 32:
|
||||
case 48:
|
||||
case 64:
|
||||
/* The rows are filled by an alogorithm similar to the above, in the
|
||||
/* 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
|
||||
@@ -661,7 +662,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@@ -672,8 +673,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 2:
|
||||
{
|
||||
const png_uint_32 luma = colors[1];
|
||||
const png_uint_32 alpha = colors[2];
|
||||
png_uint_32 luma = colors[1];
|
||||
png_uint_32 alpha = colors[2];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<size_max; ++x)
|
||||
@@ -688,9 +689,9 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 3:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@@ -707,10 +708,10 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
|
||||
case 4:
|
||||
{
|
||||
const png_uint_32 red = colors[1];
|
||||
const png_uint_32 green = colors[2];
|
||||
const png_uint_32 blue = colors[3];
|
||||
const png_uint_32 alpha = colors[4];
|
||||
png_uint_32 red = colors[1];
|
||||
png_uint_32 green = colors[2];
|
||||
png_uint_32 blue = colors[3];
|
||||
png_uint_32 alpha = colors[4];
|
||||
png_uint_32 x;
|
||||
|
||||
for (x=0; x<=size_max; ++x)
|
||||
@@ -812,7 +813,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
{
|
||||
const unsigned int size =
|
||||
unsigned int size =
|
||||
image_size_of_type(color_type, bit_depth, colors, small);
|
||||
unsigned int ysize;
|
||||
png_fixed_point real_gamma = 45455; /* For sRGB */
|
||||
@@ -824,7 +825,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
*/
|
||||
if (small)
|
||||
{
|
||||
const unsigned int pixel_depth =
|
||||
unsigned int pixel_depth =
|
||||
pixel_depth_of_type(color_type, bit_depth);
|
||||
|
||||
if (pixel_depth <= 8U)
|
||||
@@ -858,10 +859,13 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (real_gamma == 45455) for (i=0; i<256; ++i)
|
||||
if (real_gamma == 45455)
|
||||
{
|
||||
gamma_table[i] = (png_byte)i;
|
||||
conv = 1.;
|
||||
for (i=0; i<256; ++i)
|
||||
{
|
||||
gamma_table[i] = (png_byte)i;
|
||||
conv = 1.;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
@@ -950,7 +954,7 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
int passes = 1;
|
||||
# endif /* !WRITE_INTERLACING */
|
||||
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);
|
||||
|
||||
@@ -1094,7 +1098,7 @@ load_file(png_const_charp name, png_bytepp result)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static png_size_t
|
||||
static size_t
|
||||
load_fake(png_charp param, png_bytepp profile)
|
||||
{
|
||||
char *endptr = NULL;
|
||||
@@ -1164,7 +1168,7 @@ insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
{
|
||||
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 */
|
||||
{
|
||||
fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n",
|
||||
@@ -1179,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 '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 */
|
||||
{
|
||||
@@ -1274,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':
|
||||
{
|
||||
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 */
|
||||
{
|
||||
@@ -1378,10 +1382,10 @@ static void
|
||||
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
|
||||
png_charpp params)
|
||||
{
|
||||
const int ct = png_get_color_type(png_ptr, info_ptr);
|
||||
const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
|
||||
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);
|
||||
const unsigned int maxval =
|
||||
unsigned int maxval =
|
||||
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
|
||||
png_color_8 sBIT;
|
||||
|
||||
@@ -1430,10 +1434,13 @@ find_parameters(png_const_charp what, png_charp param, png_charp *list,
|
||||
for (i=0; *param && i<nparams; ++i)
|
||||
{
|
||||
list[i] = param;
|
||||
while (*++param) if (*param == '\n' || *param == ':')
|
||||
while (*++param)
|
||||
{
|
||||
*param++ = 0; /* Terminate last parameter */
|
||||
break; /* And start a new one. */
|
||||
if (*param == '\n' || *param == ':')
|
||||
{
|
||||
*param++ = 0; /* Terminate last parameter */
|
||||
break; /* And start a new one. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1856,7 +1863,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* 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);
|
||||
unsigned int i;
|
||||
|
||||
@@ -1869,7 +1876,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* small and colors are incomparible (will probably crash if both are used at
|
||||
/* small and colors are incompatible (will probably crash if both are used at
|
||||
* the same time!)
|
||||
*/
|
||||
if (small && colors[0] != 0)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngimage.c
|
||||
*
|
||||
* Copyright (c) 2021 Cosmin Truta
|
||||
* Copyright (c) 2015,2016 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -12,6 +12,7 @@
|
||||
* using png_read_png and then write with png_write_png. Test all possible
|
||||
* transforms.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -317,11 +318,10 @@ transform_name(int t)
|
||||
|
||||
t &= -t; /* first set bit */
|
||||
|
||||
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
|
||||
{
|
||||
if ((transform_info[i].transform & t) != 0)
|
||||
return transform_info[i].name;
|
||||
}
|
||||
for (i=0; i<TTABLE_SIZE; ++i)
|
||||
if (transform_info[i].name != NULL)
|
||||
if ((transform_info[i].transform & t) != 0)
|
||||
return transform_info[i].name;
|
||||
|
||||
return "invalid transform";
|
||||
}
|
||||
@@ -338,13 +338,16 @@ validate_T(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
|
||||
for (i=0; i<TTABLE_SIZE; ++i)
|
||||
{
|
||||
if (transform_info[i].when & TRANSFORM_R)
|
||||
read_transforms |= transform_info[i].transform;
|
||||
if (transform_info[i].name != NULL)
|
||||
{
|
||||
if (transform_info[i].when & TRANSFORM_R)
|
||||
read_transforms |= transform_info[i].transform;
|
||||
|
||||
if (transform_info[i].when & TRANSFORM_W)
|
||||
write_transforms |= transform_info[i].transform;
|
||||
if (transform_info[i].when & TRANSFORM_W)
|
||||
write_transforms |= transform_info[i].transform;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reversible transforms are those which are supported on both read and
|
||||
@@ -551,7 +554,7 @@ struct display
|
||||
png_structp original_pp; /* used on 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 */
|
||||
|
||||
/* Original chunks valid */
|
||||
@@ -807,7 +810,7 @@ display_cache_file(struct display *dp, const char *filename)
|
||||
|
||||
static void
|
||||
buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
||||
png_size_t size)
|
||||
size_t size)
|
||||
{
|
||||
struct buffer_list *last = bp->current;
|
||||
size_t read_count = bp->read_count;
|
||||
@@ -855,7 +858,7 @@ buffer_read(struct display *dp, struct buffer *bp, png_bytep data,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -927,7 +930,7 @@ update_display(struct display *dp)
|
||||
png_structp pp;
|
||||
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*/);
|
||||
|
||||
/* Move the result to the 'original' fields */
|
||||
@@ -962,21 +965,24 @@ update_display(struct display *dp)
|
||||
int bd = dp->bit_depth;
|
||||
unsigned int i;
|
||||
|
||||
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
|
||||
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 ||
|
||||
(transform_info[i].valid_chunks & chunks) != 0) &&
|
||||
(transform_info[i].color_mask_required & ct) ==
|
||||
transform_info[i].color_mask_required &&
|
||||
(transform_info[i].color_mask_absent & ct) == 0 &&
|
||||
(transform_info[i].bit_depths & bd) != 0 &&
|
||||
(transform_info[i].when & TRANSFORM_R) != 0)
|
||||
active |= transform;
|
||||
if ((transform_info[i].valid_chunks == 0 ||
|
||||
(transform_info[i].valid_chunks & chunks) != 0) &&
|
||||
(transform_info[i].color_mask_required & ct) ==
|
||||
transform_info[i].color_mask_required &&
|
||||
(transform_info[i].color_mask_absent & ct) == 0 &&
|
||||
(transform_info[i].bit_depths & bd) != 0 &&
|
||||
(transform_info[i].when & TRANSFORM_R) != 0)
|
||||
active |= transform;
|
||||
|
||||
else if ((transform_info[i].when & TRANSFORM_R) != 0)
|
||||
inactive |= transform;
|
||||
else if ((transform_info[i].when & TRANSFORM_R) != 0)
|
||||
inactive |= transform;
|
||||
}
|
||||
}
|
||||
|
||||
/* Some transforms appear multiple times in the table; the 'active' status
|
||||
@@ -1000,8 +1006,9 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
int interlace_method, compression_method, filter_method;
|
||||
const char *e = NULL;
|
||||
|
||||
png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth,
|
||||
&color_type, &interlace_method, &compression_method, &filter_method);
|
||||
if (!png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth,
|
||||
&color_type, &interlace_method, &compression_method, &filter_method))
|
||||
display_log(dp, LIBPNG_BUG, "png_get_IHDR failed");
|
||||
|
||||
# define C(item) if (item != dp->item) \
|
||||
display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\
|
||||
@@ -1081,8 +1088,9 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
size_t x;
|
||||
|
||||
/* Find the first error */
|
||||
for (x=0; x<rowbytes-1; ++x) if (row[x] != orig[x])
|
||||
break;
|
||||
for (x=0; x<rowbytes-1; ++x)
|
||||
if (row[x] != orig[x])
|
||||
break;
|
||||
|
||||
display_log(dp, APP_FAIL,
|
||||
"byte(%lu,%lu) changed 0x%.2x -> 0x%.2x",
|
||||
@@ -1137,6 +1145,7 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
display_log(dp, LIBPNG_ERROR, "invalid colour type %d",
|
||||
color_type);
|
||||
/*NOTREACHED*/
|
||||
memset(sig_bits, 0, sizeof(sig_bits));
|
||||
bpp = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1198,7 +1207,7 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
sig_bits[0] = (png_byte)b;
|
||||
break;
|
||||
|
||||
case 4: /* Relicate twice */
|
||||
case 4: /* Replicate twice */
|
||||
/* Value is 1, 2, 3 or 4 */
|
||||
b = 0xf & ((0xf << 4) >> sig_bits[0]);
|
||||
b |= b << 4;
|
||||
@@ -1267,7 +1276,7 @@ compare_read(struct display *dp, int applied_transforms)
|
||||
#ifdef PNG_WRITE_PNG_SUPPORTED
|
||||
static void
|
||||
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
|
||||
* libpng and from the generic read code.
|
||||
*/
|
||||
@@ -1311,7 +1320,7 @@ buffer_write(struct display *dp, struct buffer *buffer, png_bytep data,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1446,7 +1455,7 @@ test_one_file(struct display *dp, const char *filename)
|
||||
* unsigned, because some transforms are negative on a 16-bit system.
|
||||
*/
|
||||
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 bad_transforms = 0;
|
||||
unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */
|
||||
@@ -1572,7 +1581,7 @@ do_test(struct display *dp, const char *file)
|
||||
}
|
||||
|
||||
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 */
|
||||
int option_end, ilog = 0;
|
||||
@@ -1674,7 +1683,7 @@ main(const int argc, const char * const * const argv)
|
||||
/* 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);
|
||||
|
||||
if (!pass)
|
||||
@@ -1686,8 +1695,9 @@ main(const int argc, const char * const * const argv)
|
||||
|
||||
printf("%s: pngimage ", pass ? "PASS" : "FAIL");
|
||||
|
||||
for (j=1; j<option_end; ++j) if (j != ilog)
|
||||
printf("%s ", argv[j]);
|
||||
for (j=1; j<option_end; ++j)
|
||||
if (j != ilog)
|
||||
printf("%s ", argv[j]);
|
||||
|
||||
printf("%s\n", d.filename);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*-
|
||||
* pngstest.c
|
||||
|
||||
/* pngstest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||
* Copyright (c) 2021 Cosmin Truta
|
||||
* Copyright (c) 2013-2017 John Cunningham Bowler
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
@@ -10,8 +10,9 @@
|
||||
*
|
||||
* Test for the PNG 'simplified' APIs.
|
||||
*/
|
||||
|
||||
#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 <stdlib.h>
|
||||
@@ -372,7 +373,7 @@ print_opts(png_uint_32 opts)
|
||||
*/
|
||||
#define FORMAT_COUNT 64
|
||||
#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+alpha",
|
||||
@@ -578,11 +579,11 @@ typedef struct
|
||||
int stride_extra;
|
||||
FILE *input_file;
|
||||
png_voidp input_memory;
|
||||
png_size_t input_memory_size;
|
||||
size_t input_memory_size;
|
||||
png_bytep buffer;
|
||||
ptrdiff_t stride;
|
||||
png_size_t bufsize;
|
||||
png_size_t allocsize;
|
||||
size_t bufsize;
|
||||
size_t allocsize;
|
||||
char tmpfile_name[32];
|
||||
png_uint_16 colormap[256*4];
|
||||
}
|
||||
@@ -665,7 +666,7 @@ static void initimage(Image *image, png_uint_32 opts, const char *file_name,
|
||||
static void
|
||||
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)
|
||||
{
|
||||
@@ -1142,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:
|
||||
*
|
||||
* 1) Remove an alpha channel by pre-multiplication or compositing on a
|
||||
@@ -1150,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.)
|
||||
*
|
||||
* 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.)
|
||||
*
|
||||
* This gives the following base format conversion matrix:
|
||||
@@ -2036,7 +2037,7 @@ typedef struct
|
||||
/* Precalculated values: */
|
||||
int in_opaque; /* Value of input alpha that is opaque */
|
||||
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) */
|
||||
|
||||
void (*in_gp)(Pixel*, png_const_voidp);
|
||||
@@ -2346,8 +2347,8 @@ static int
|
||||
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 png_uint_32 in_format = transform->in_image->image.format;
|
||||
const png_uint_32 out_format = transform->out_image->image.format;
|
||||
png_uint_32 in_format = transform->in_image->image.format;
|
||||
png_uint_32 out_format = transform->out_image->image.format;
|
||||
|
||||
png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA;
|
||||
const char *via_linear = "";
|
||||
@@ -2602,12 +2603,12 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
ptrdiff_t strideb = b->stride;
|
||||
png_const_bytep rowa = a->buffer+16;
|
||||
png_const_bytep rowb = b->buffer+16;
|
||||
const png_uint_32 width = a->image.width;
|
||||
const png_uint_32 height = a->image.height;
|
||||
const png_uint_32 formata = a->image.format;
|
||||
const png_uint_32 formatb = b->image.format;
|
||||
const unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
const unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
png_uint_32 width = a->image.width;
|
||||
png_uint_32 height = a->image.height;
|
||||
png_uint_32 formata = a->image.format;
|
||||
png_uint_32 formatb = b->image.format;
|
||||
unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata);
|
||||
unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb);
|
||||
int alpha_added, alpha_removed;
|
||||
int bchannels;
|
||||
png_uint_32 y;
|
||||
@@ -2701,7 +2702,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
{
|
||||
if ((a->opts & ACCUMULATE) == 0)
|
||||
{
|
||||
char pindex[9];
|
||||
char pindex[16];
|
||||
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
||||
(unsigned long)a->image.colormap_entries);
|
||||
logerror(a, a->file_name, ": bad pixel index: ", pindex);
|
||||
@@ -2712,12 +2713,12 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
else if (y >= b->image.colormap_entries)
|
||||
{
|
||||
if ((b->opts & ACCUMULATE) == 0)
|
||||
{
|
||||
char pindex[9];
|
||||
{
|
||||
char pindex[16];
|
||||
sprintf(pindex, "%lu[%lu]", (unsigned long)y,
|
||||
(unsigned long)b->image.colormap_entries);
|
||||
logerror(b, b->file_name, ": bad pixel index: ", pindex);
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
|
||||
@@ -2726,7 +2727,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
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)
|
||||
{
|
||||
tr.error_ptr[0] = tr.error[0];
|
||||
@@ -2790,8 +2791,7 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
(formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR)))
|
||||
{
|
||||
/* Was an alpha channel changed? */
|
||||
const png_uint_32 alpha_changed = (formata ^ formatb) &
|
||||
PNG_FORMAT_FLAG_ALPHA;
|
||||
png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA;
|
||||
|
||||
/* Was an alpha channel removed? (The third test.) If so the direct
|
||||
* comparison is only possible if the input alpha is opaque.
|
||||
@@ -2821,8 +2821,11 @@ compare_two_images(Image *a, Image *b, int via_linear,
|
||||
bchannels = component_loc(bloc, formatb);
|
||||
|
||||
/* Hence the btoa array. */
|
||||
for (i=0; i<4; ++i) if (bloc[i] < 4)
|
||||
btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */
|
||||
for (i=0; i<4; ++i)
|
||||
{
|
||||
if (bloc[i] < 4)
|
||||
btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */
|
||||
}
|
||||
|
||||
if (alpha_added)
|
||||
alpha_added = bloc[0]; /* location of alpha channel in image b */
|
||||
@@ -2932,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)
|
||||
{
|
||||
tr.error_ptr[0] = tr.error[0];
|
||||
@@ -3210,10 +3213,10 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
||||
else if (image->opts & USE_FILE)
|
||||
{
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||
static int counter = 0;
|
||||
static unsigned int counter = 0;
|
||||
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,
|
||||
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
||||
@@ -3627,7 +3630,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (arg[0] == '-')
|
||||
{
|
||||
const int term = (arg[1] == '0' ? 0 : '\n');
|
||||
int term = (arg[1] == '0' ? 0 : '\n');
|
||||
unsigned int ich = 0;
|
||||
|
||||
/* Loop reading files, use a static buffer to simplify this and just
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* Last changed in libpng 1.6.32 [(PENDING RELEASE)]
|
||||
* Copyright (c) 2021 Cosmin Truta
|
||||
* Copyright (c) 2015,2017 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
@@ -56,7 +56,7 @@
|
||||
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
|
||||
#if PNG_LIBPNG_VER < 10500
|
||||
/* This deliberately lacks the PNG_CONST. */
|
||||
/* This deliberately lacks the const. */
|
||||
typedef png_byte *png_const_bytep;
|
||||
|
||||
/* This is copied from 1.5.1 png.h: */
|
||||
@@ -85,7 +85,7 @@ typedef png_byte *png_const_bytep;
|
||||
#define PNG_WRITE_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_GAMMA_THRESHOLD_FIXED\
|
||||
((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1))
|
||||
@@ -370,7 +370,9 @@ find_by_flag(png_uint_32 flag)
|
||||
{
|
||||
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");
|
||||
exit(4);
|
||||
@@ -547,27 +549,30 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
|
||||
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
discard = 1/*handled; discard*/;
|
||||
discard = 1; /*handled; discard*/
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
discard = 0/*not handled; keep*/;
|
||||
discard = 0; /*not handled; keep*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* Also store information about this chunk in the display, the relevant flag
|
||||
* is set if the chunk is to be kept ('not handled'.)
|
||||
*/
|
||||
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
|
||||
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)
|
||||
d->after_IDAT |= flag;
|
||||
if (pc->location & PNG_AFTER_IDAT)
|
||||
d->after_IDAT |= flag;
|
||||
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* However if there is no support to store unknown chunks don't ask libpng to
|
||||
@@ -841,8 +846,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
{
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
for (y=0; y<height; ++y)
|
||||
if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
} /* interlaced */
|
||||
@@ -1091,15 +1097,15 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
||||
|
||||
static const char *standard_tests[] =
|
||||
{
|
||||
"discard", "default=discard", 0,
|
||||
"save", "default=save", 0,
|
||||
"if-safe", "default=if-safe", 0,
|
||||
"vpAg", "vpAg=if-safe", 0,
|
||||
"sTER", "sTER=if-safe", 0,
|
||||
"IDAT", "default=discard", "IDAT=save", 0,
|
||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||
"sBIT=save", "sRGB=save", "eXIf=save", 0,
|
||||
0/*end*/
|
||||
"discard", "default=discard", NULL,
|
||||
"save", "default=save", NULL,
|
||||
"if-safe", "default=if-safe", NULL,
|
||||
"vpAg", "vpAg=if-safe", NULL,
|
||||
"sTER", "sTER=if-safe", NULL,
|
||||
"IDAT", "default=discard", "IDAT=save", NULL,
|
||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||
"sBIT=save", "sRGB=save", "eXIf=save", NULL,
|
||||
NULL /*end*/
|
||||
};
|
||||
|
||||
static PNG_NORETURN void
|
||||
@@ -1115,7 +1121,7 @@ int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
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;
|
||||
const char *count_argv = "default=save";
|
||||
const char *touch_file = NULL;
|
||||
@@ -1153,8 +1159,9 @@ main(int argc, const char **argv)
|
||||
/* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc
|
||||
* optimization which causes warnings with -Wstrict-overflow!
|
||||
*/
|
||||
else if (default_tests) if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
else if (default_tests)
|
||||
if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
|
||||
/* The name of the test file is the last argument; remove it. */
|
||||
d.file = argv[--argc];
|
||||
@@ -1216,7 +1223,11 @@ main(int argc, const char **argv)
|
||||
const char *result;
|
||||
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,
|
||||
this_test);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,8 @@
|
||||
|
||||
/* readpng.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -60,7 +59,7 @@ read_png(FILE *fp)
|
||||
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);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
/* tarith.c
|
||||
*
|
||||
* Copyright (c) 2021 Cosmin Truta
|
||||
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -88,6 +87,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
int minorarith = 0;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
if (strcmp(*++argv, "-a") == 0)
|
||||
showall = 1;
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
png_size_t index;
|
||||
size_t index;
|
||||
int state, failed = 0;
|
||||
char buffer[64];
|
||||
|
||||
@@ -130,8 +131,8 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
*/
|
||||
if (buffer[precision+7] != 71)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||
precision, buffer, (unsigned long)strlen(buffer));
|
||||
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n",
|
||||
test, precision, buffer, (unsigned long)strlen(buffer));
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
@@ -146,16 +147,16 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||
test < 0 && strcmp(buffer, "-inf"))
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
||||
precision, buffer);
|
||||
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n",
|
||||
test, precision, buffer);
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||
buffer[index] != 0)
|
||||
{
|
||||
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
||||
precision, buffer, buffer[index]);
|
||||
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n",
|
||||
test, precision, buffer, buffer[index]);
|
||||
failed = 1;
|
||||
}
|
||||
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||
@@ -176,7 +177,7 @@ int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||
}
|
||||
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);
|
||||
failed = 1;
|
||||
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. */
|
||||
double out = atof(buffer);
|
||||
double change = fabs((out - test)/test);
|
||||
double allow = .5/pow(10,
|
||||
double allow = .5 / pow(10,
|
||||
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||
|
||||
/* NOTE: if you hit this error case are you compiling with gcc
|
||||
@@ -257,8 +258,9 @@ skip:
|
||||
}
|
||||
while (--count);
|
||||
|
||||
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
||||
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
||||
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) "
|
||||
"%d minor arithmetic errors\n",
|
||||
finite, nonfinite, ok, failcount, minorarith);
|
||||
printf(" Error with >=%d digit precision %.2f%%\n", DBL_DIG, max_abs);
|
||||
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
png_size_t index = 0;
|
||||
size_t index = 0;
|
||||
const char test = (char)ch;
|
||||
const int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
const int character_accepted = (index == 1);
|
||||
int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||
int character_accepted = (index == 1);
|
||||
|
||||
if (c.check_state != exponent && isdigit(ch) && ch != '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): */
|
||||
if (index != 0 && index != 1)
|
||||
{
|
||||
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
||||
(unsigned long)index);
|
||||
fprintf(stderr, "%s: read beyond end of string (%lu)\n",
|
||||
co->number, (unsigned long)index);
|
||||
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)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
||||
ch, ch);
|
||||
"%s: character '%c' [0x%.2x] changed number validity\n",
|
||||
co->number, ch, ch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -521,10 +523,13 @@ static int check_all_characters(checkfp_command *co, checkfp_control c)
|
||||
{
|
||||
int ch;
|
||||
|
||||
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
||||
if (c.cnumber+4 < sizeof co->number)
|
||||
{
|
||||
if (!check_one_character(co, c, ch))
|
||||
return 0;
|
||||
for (ch=0; ch<256; ++ch)
|
||||
{
|
||||
if (!check_one_character(co, c, ch))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
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.limit > 0) for (i=0; tests[i]; ++i)
|
||||
if (c.limit > 0)
|
||||
{
|
||||
if (!check_one_character(co, c, tests[i]))
|
||||
return 0;
|
||||
for (i=0; tests[i]; ++i)
|
||||
{
|
||||
if (!check_one_character(co, c, tests[i]))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find out about the random number generator. */
|
||||
randbuffer = RAND_MAX;
|
||||
@@ -687,25 +695,25 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
||||
fp, ok ? "ok" : "overflow");
|
||||
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n",
|
||||
a, times, div, fp, ok ? "ok" : "overflow");
|
||||
|
||||
++tested;
|
||||
if (png_muldiv(&result, a, times, div) != ok)
|
||||
{
|
||||
++error;
|
||||
if (ok)
|
||||
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
||||
times, div, fp);
|
||||
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n",
|
||||
a, times, div, fp);
|
||||
else
|
||||
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
||||
times, div, result, fp);
|
||||
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n",
|
||||
a, times, div, result, fp);
|
||||
}
|
||||
else if (ok && result != fpround)
|
||||
{
|
||||
++error;
|
||||
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
||||
fp);
|
||||
fprintf(stderr, "%d * %d / %d -> %d not %lld\n",
|
||||
a, times, div, result, fp);
|
||||
}
|
||||
else
|
||||
++passed;
|
||||
@@ -721,8 +729,8 @@ int validation_muldiv(int count, int argc, char **argv)
|
||||
}
|
||||
while (--count > 0);
|
||||
|
||||
printf("%d tests including %d overflows, %d passed, %d failed (%d 64-bit "
|
||||
"errors)\n", tested, overflow, passed, error, error64);
|
||||
printf("%d tests including %d overflows, %d passed, %d failed "
|
||||
"(%d 64-bit errors)\n", tested, overflow, passed, error, error64);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -821,8 +829,9 @@ int validation_gamma(int argc, char **argv)
|
||||
{
|
||||
if (error > .68) /* By experiment error is less than .68 */
|
||||
{
|
||||
fprintf(stderr, "16-bit log error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_log16bit(i), correct, error);
|
||||
fprintf(stderr,
|
||||
"16-bit log error: %d: got %u, expected %f error: %f\n",
|
||||
i, png_log16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -841,8 +850,9 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > 1883) /* By experiment. */
|
||||
{
|
||||
fprintf(stderr, "32-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp(i), correct, error);
|
||||
fprintf(stderr,
|
||||
"32-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||
i, png_exp(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,8 +869,9 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .50002) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "8-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp8bit(i), correct, error);
|
||||
fprintf(stderr,
|
||||
"8-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||
i, png_exp8bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,8 +888,9 @@ int validation_gamma(int argc, char **argv)
|
||||
maxerr = fabs(error);
|
||||
if (fabs(error) > .524) /* By experiment */
|
||||
{
|
||||
fprintf(stderr, "16-bit exp error: %d: got %u, expected %f"
|
||||
" error: %f\n", i, png_exp16bit(i), correct, error);
|
||||
fprintf(stderr,
|
||||
"16-bit exp error: %d: got %u, expected %f error: %f\n",
|
||||
i, png_exp16bit(i), correct, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +952,7 @@ int validation_gamma(int argc, char **argv)
|
||||
|
||||
/**************************** VALIDATION TESTS ********************************/
|
||||
/* 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
|
||||
* 2: validates png_muldiv
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2013,2016 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
@@ -65,7 +64,7 @@ typedef struct
|
||||
} io_data;
|
||||
|
||||
static PNG_CALLBACK(void, read_and_copy,
|
||||
(png_structp png_ptr, png_bytep buffer, png_size_t cb))
|
||||
(png_structp png_ptr, png_bytep buffer, size_t cb))
|
||||
{
|
||||
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||
|
||||
@@ -100,7 +99,7 @@ static void read_by_row(png_structp png_ptr, png_infop 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 = voidcast(png_bytep,malloc(rowbytes));
|
||||
display = voidcast(png_bytep,malloc(rowbytes));
|
||||
@@ -528,7 +527,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
else if (nfiles == 0) /* Read from stdin withoout --dissemble */
|
||||
else if (nfiles == 0) /* Read from stdin without --dissemble */
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1,64 +1,55 @@
|
||||
|
||||
/* contrib/mips-msa/linux.c
|
||||
*
|
||||
* Copyright (c) 2020-2023 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, 2016.
|
||||
* Last changed in libpng 1.6.25beta03 [August 29, 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
|
||||
*
|
||||
* SEE contrib/mips-msa/README before reporting bugs
|
||||
* 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
|
||||
*
|
||||
* png_have_msa implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <elf.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int
|
||||
png_have_msa(png_structp png_ptr)
|
||||
{
|
||||
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
Elf64_auxv_t aux;
|
||||
int fd;
|
||||
int has_msa = 0;
|
||||
|
||||
char *string = "msa";
|
||||
char word[10];
|
||||
|
||||
if (f != NULL)
|
||||
fd = open("/proc/self/auxv", O_RDONLY);
|
||||
if (fd >= 0)
|
||||
{
|
||||
while(!feof(f))
|
||||
while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
|
||||
{
|
||||
int ch = fgetc(f);
|
||||
static int i = 0;
|
||||
|
||||
while(!(ch <= 32))
|
||||
if (aux.a_type == AT_HWCAP)
|
||||
{
|
||||
word[i++] = ch;
|
||||
ch = fgetc(f);
|
||||
uint64_t hwcap = aux.a_un.a_val;
|
||||
|
||||
has_msa = (hwcap >> 1) & 1;
|
||||
break;
|
||||
}
|
||||
|
||||
int val = strcmp(string, word);
|
||||
|
||||
if (val == 0)
|
||||
return 1;
|
||||
|
||||
i = 0;
|
||||
memset(word, 0, 10);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
close(fd);
|
||||
}
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
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
|
||||
@@ -1,4 +1,3 @@
|
||||
Last changed in libpng 1.6.32 [(PENDING RELEASE)]
|
||||
Copyright (c) 2017 Glenn Randers-Pehrson
|
||||
|
||||
This code is released under the libpng license.
|
||||
@@ -13,7 +12,7 @@ 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-Pehson
|
||||
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
|
||||
@@ -23,11 +22,15 @@ 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
|
||||
project.yaml original 2015, Chrome Devs Chromium
|
||||
README.txt (this file) original 2017, GLenn R-P libpng
|
||||
README.txt (this file) original 2017, Glenn R-P libpng
|
||||
|
||||
To do: exercise the progressive reader.
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash -eu
|
||||
# Copyright 2017 Glenn Randers-Pehrson
|
||||
|
||||
# Copyright 2017-2018 Glenn Randers-Pehrson
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,12 +15,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# Last changed in libpng 1.6.32 [(PENDING RELEASE)]
|
||||
#
|
||||
# Revisions by Glenn Randers-Pehson, 2017:
|
||||
# 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.
|
||||
@@ -30,18 +30,21 @@ cat scripts/pnglibconf.dfa | \
|
||||
> scripts/pnglibconf.dfa.temp
|
||||
mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
|
||||
|
||||
# build the library.
|
||||
# build the libpng library.
|
||||
autoreconf -f -i
|
||||
./configure
|
||||
./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_read_fuzzer.cc -o $OUT/libpng_read_fuzzer \
|
||||
$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/contrib/pngsuite -name "*.png" | xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip
|
||||
find $SRC/libpng -name "*.png" | grep -v crashers | \
|
||||
xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip
|
||||
|
||||
cp $SRC/*.dict $SRC/*.options $OUT/
|
||||
cp $SRC/libpng/contrib/oss-fuzz/*.dict \
|
||||
$SRC/libpng/contrib/oss-fuzz/*.options $OUT/
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
|
||||
// libpng_read_fuzzer.cc
|
||||
// Copyright 2017 Glenn Randers-Pehrson
|
||||
// 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
|
||||
|
||||
// Last changed in libpng 1.6.32 [(PENDING RELEASE)]
|
||||
|
||||
// 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.
|
||||
// 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>
|
||||
@@ -22,14 +24,23 @@
|
||||
#include "png.h"
|
||||
|
||||
#define PNG_CLEANUP \
|
||||
if(png_handler.png_ptr) \
|
||||
{ \
|
||||
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); \
|
||||
}
|
||||
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;
|
||||
@@ -39,21 +50,24 @@ struct BufState {
|
||||
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_ptr) {
|
||||
if (row_ptr)
|
||||
png_free(png_ptr, row_ptr);
|
||||
}
|
||||
if (png_ptr && info_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, png_size_t length) {
|
||||
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");
|
||||
@@ -63,6 +77,22 @@ void user_read_data(png_structp png_ptr, png_bytep data, png_size_t 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.
|
||||
@@ -80,6 +110,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -92,6 +127,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
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);
|
||||
@@ -111,9 +155,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
|
||||
// Reading.
|
||||
png_read_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));
|
||||
|
||||
// reset error handler to put png_deleter into scope.
|
||||
if (setjmp(png_jmpbuf(png_handler.png_ptr))) {
|
||||
@@ -138,8 +179,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
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_start_read_image(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) {
|
||||
@@ -148,6 +201,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
|
||||
|
||||
PNG_CLEANUP
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
homepage: "http://www.libpng.org/pub/png/libpng.html"
|
||||
primary_contact: "glennrp@gmail.com"
|
||||
sanitizers:
|
||||
- address
|
||||
- memory:
|
||||
experimental: True
|
||||
- undefined
|
||||
11
contrib/pngexif/.editorconfig
Normal file
11
contrib/pngexif/.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
max_doc_length = 79
|
||||
max_line_length = 79
|
||||
trim_trailing_whitespace = true
|
||||
3
contrib/pngexif/.gitignore
vendored
Normal file
3
contrib/pngexif/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
__pycache__
|
||||
*.py[co]
|
||||
*$py.class
|
||||
8
contrib/pngexif/.pylintrc
Normal file
8
contrib/pngexif/.pylintrc
Normal file
@@ -0,0 +1,8 @@
|
||||
[COMPATIBILITY]
|
||||
disable=consider-using-f-string
|
||||
|
||||
[COMPLEXITY]
|
||||
disable=too-many-branches,too-many-instance-attributes
|
||||
|
||||
[STYLE]
|
||||
disable=consider-using-in
|
||||
19
contrib/pngexif/LICENSE_MIT.txt
Normal file
19
contrib/pngexif/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.
|
||||
20
contrib/pngexif/README.md
Normal file
20
contrib/pngexif/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
pngexifinfo
|
||||
===========
|
||||
|
||||
Show the EXIF information embedded in a PNG file.
|
||||
|
||||
|
||||
Sample usage
|
||||
------------
|
||||
|
||||
Show the EXIF info inside a PNG file:
|
||||
|
||||
pngexifinfo /path/to/file.png
|
||||
|
||||
Show the EXIF info inside a raw `.exif` file, using base 16 for the EXIF tags:
|
||||
|
||||
pngexifinfo --hex /path/to/file.exif
|
||||
|
||||
Show the help text:
|
||||
|
||||
pngexifinfo --help
|
||||
48
contrib/pngexif/bytepack.py
Executable file
48
contrib/pngexif/bytepack.py
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Byte packing and unpacking utilities.
|
||||
|
||||
Copyright (C) 2017-2020 Cosmin Truta.
|
||||
|
||||
Use, modification and distribution are subject to the MIT License.
|
||||
Please see the accompanying file LICENSE_MIT.txt
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import struct
|
||||
|
||||
|
||||
def unpack_uint32be(buffer, offset=0):
|
||||
"""Unpack an unsigned int from its 32-bit big-endian representation."""
|
||||
return struct.unpack(">I", buffer[offset:offset + 4])[0]
|
||||
|
||||
|
||||
def unpack_uint32le(buffer, offset=0):
|
||||
"""Unpack an unsigned int from its 32-bit little-endian representation."""
|
||||
return struct.unpack("<I", buffer[offset:offset + 4])[0]
|
||||
|
||||
|
||||
def unpack_uint16be(buffer, offset=0):
|
||||
"""Unpack an unsigned int from its 16-bit big-endian representation."""
|
||||
return struct.unpack(">H", buffer[offset:offset + 2])[0]
|
||||
|
||||
|
||||
def unpack_uint16le(buffer, offset=0):
|
||||
"""Unpack an unsigned int from its 16-bit little-endian representation."""
|
||||
return struct.unpack("<H", buffer[offset:offset + 2])[0]
|
||||
|
||||
|
||||
def unpack_uint8(buffer, offset=0):
|
||||
"""Unpack an unsigned int from its 8-bit representation."""
|
||||
return struct.unpack("B", buffer[offset:offset + 1])[0]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# For testing only.
|
||||
assert unpack_uint32be(b"ABCDEF", 1) == 0x42434445
|
||||
assert unpack_uint32le(b"ABCDEF", 1) == 0x45444342
|
||||
assert unpack_uint16be(b"ABCDEF", 1) == 0x4243
|
||||
assert unpack_uint16le(b"ABCDEF", 1) == 0x4342
|
||||
assert unpack_uint8(b"ABCDEF", 1) == 0x42
|
||||
306
contrib/pngexif/exifinfo.py
Executable file
306
contrib/pngexif/exifinfo.py
Executable file
@@ -0,0 +1,306 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Show the EXIF information.
|
||||
|
||||
Copyright (C) 2017-2020 Cosmin Truta.
|
||||
|
||||
Use, modification and distribution are subject to the MIT License.
|
||||
Please see the accompanying file LICENSE_MIT.txt
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import sys
|
||||
|
||||
from bytepack import (unpack_uint32be,
|
||||
unpack_uint32le,
|
||||
unpack_uint16be,
|
||||
unpack_uint16le,
|
||||
unpack_uint8)
|
||||
|
||||
|
||||
# Generously allow the TIFF file to occupy up to a quarter-gigabyte.
|
||||
# TODO: Reduce this limit to 64K and use file seeking for anything larger.
|
||||
_READ_DATA_SIZE_MAX = 256 * 1024 * 1024
|
||||
|
||||
_TIFF_TAG_TYPES = {
|
||||
1: "byte",
|
||||
2: "ascii",
|
||||
3: "short",
|
||||
4: "long",
|
||||
5: "rational",
|
||||
6: "sbyte",
|
||||
7: "undefined",
|
||||
8: "sshort",
|
||||
9: "slong",
|
||||
10: "srational",
|
||||
11: "float",
|
||||
12: "double",
|
||||
}
|
||||
|
||||
# See http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
|
||||
_TIFF_TAGS = {
|
||||
0x00fe: "Subfile Type",
|
||||
0x0100: "Width",
|
||||
0x0101: "Height",
|
||||
0x0102: "Bits per Sample",
|
||||
0x0103: "Compression",
|
||||
0x0106: "Photometric",
|
||||
0x010d: "Document Name",
|
||||
0x010e: "Image Description",
|
||||
0x010f: "Make",
|
||||
0x0110: "Model",
|
||||
0x0111: "Strip Offsets",
|
||||
0x0112: "Orientation",
|
||||
0x0115: "Samples per Pixel",
|
||||
0x0116: "Rows per Strip",
|
||||
0x0117: "Strip Byte Counts",
|
||||
0x0118: "Min Sample Value",
|
||||
0x0119: "Max Sample Value",
|
||||
0x011a: "X Resolution",
|
||||
0x011b: "Y Resolution",
|
||||
0x011c: "Planar Configuration",
|
||||
0x011d: "Page Name",
|
||||
0x011e: "X Position",
|
||||
0x011f: "Y Position",
|
||||
0x0128: "Resolution Unit",
|
||||
0x0129: "Page Number",
|
||||
0x0131: "Software",
|
||||
0x0132: "Date Time",
|
||||
0x013b: "Artist",
|
||||
0x013c: "Host Computer",
|
||||
0x013d: "Predictor",
|
||||
0x013e: "White Point",
|
||||
0x013f: "Primary Chromaticities",
|
||||
0x0140: "Color Map",
|
||||
0x0141: "Half-Tone Hints",
|
||||
0x0142: "Tile Width",
|
||||
0x0143: "Tile Length",
|
||||
0x0144: "Tile Offsets",
|
||||
0x0145: "Tile Byte Counts",
|
||||
0x0211: "YCbCr Coefficients",
|
||||
0x0212: "YCbCr Subsampling",
|
||||
0x0213: "YCbCr Positioning",
|
||||
0x0214: "Reference Black White",
|
||||
0x022f: "Strip Row Counts",
|
||||
0x02bc: "XMP",
|
||||
0x8298: "Copyright",
|
||||
0x83bb: "IPTC",
|
||||
0x8769: "EXIF IFD",
|
||||
0x8773: "ICC Profile",
|
||||
0x8825: "GPS IFD",
|
||||
0xa005: "Interoperability IFD",
|
||||
0xc4a5: "Print IM",
|
||||
|
||||
# EXIF IFD tags
|
||||
0x829a: "Exposure Time",
|
||||
0x829d: "F-Number",
|
||||
0x8822: "Exposure Program",
|
||||
0x8824: "Spectral Sensitivity",
|
||||
0x8827: "ISO Speed Ratings",
|
||||
0x8828: "OECF",
|
||||
0x9000: "EXIF Version",
|
||||
0x9003: "DateTime Original",
|
||||
0x9004: "DateTime Digitized",
|
||||
0x9101: "Components Configuration",
|
||||
0x9102: "Compressed Bits Per Pixel",
|
||||
0x9201: "Shutter Speed Value",
|
||||
0x9202: "Aperture Value",
|
||||
0x9203: "Brightness Value",
|
||||
0x9204: "Exposure Bias Value",
|
||||
0x9205: "Max Aperture Value",
|
||||
0x9206: "Subject Distance",
|
||||
0x9207: "Metering Mode",
|
||||
0x9208: "Light Source",
|
||||
0x9209: "Flash",
|
||||
0x920a: "Focal Length",
|
||||
0x9214: "Subject Area",
|
||||
0x927c: "Maker Note",
|
||||
0x9286: "User Comment",
|
||||
# ... TODO
|
||||
0xa000: "Flashpix Version",
|
||||
0xa001: "Color Space",
|
||||
0xa002: "Pixel X Dimension",
|
||||
0xa003: "Pixel Y Dimension",
|
||||
0xa004: "Related Sound File",
|
||||
# ... TODO
|
||||
|
||||
# GPS IFD tags
|
||||
# ... TODO
|
||||
}
|
||||
|
||||
_TIFF_EXIF_IFD = 0x8769
|
||||
_GPS_IFD = 0x8825
|
||||
_INTEROPERABILITY_IFD = 0xa005
|
||||
|
||||
|
||||
class ExifInfo:
|
||||
"""EXIF reader and information lister."""
|
||||
|
||||
_endian = None
|
||||
_buffer = None
|
||||
_offset = 0
|
||||
_global_ifd_offset = 0
|
||||
_exif_ifd_offset = 0
|
||||
_gps_ifd_offset = 0
|
||||
_interoperability_ifd_offset = 0
|
||||
_hex = False
|
||||
|
||||
def __init__(self, buffer, **kwargs):
|
||||
"""Initialize the EXIF data reader."""
|
||||
self._hex = kwargs.get("hex", False)
|
||||
self._verbose = kwargs.get("verbose", False)
|
||||
if not isinstance(buffer, bytes):
|
||||
raise RuntimeError("invalid EXIF data type")
|
||||
if buffer.startswith(b"MM\x00\x2a"):
|
||||
self._endian = "MM"
|
||||
elif buffer.startswith(b"II\x2a\x00"):
|
||||
self._endian = "II"
|
||||
else:
|
||||
raise RuntimeError("invalid EXIF header")
|
||||
self._buffer = buffer
|
||||
self._offset = 4
|
||||
self._global_ifd_offset = self._ui32()
|
||||
|
||||
def endian(self):
|
||||
"""Return the endianness of the EXIF data."""
|
||||
return self._endian
|
||||
|
||||
def _tags_for_ifd(self, ifd_offset):
|
||||
"""Yield the tags found at the given TIFF IFD offset."""
|
||||
if ifd_offset < 8:
|
||||
raise RuntimeError("invalid TIFF IFD offset")
|
||||
self._offset = ifd_offset
|
||||
ifd_size = self._ui16()
|
||||
for _ in range(0, ifd_size):
|
||||
tag_id = self._ui16()
|
||||
tag_type = self._ui16()
|
||||
count = self._ui32()
|
||||
value_or_offset = self._ui32()
|
||||
if self._endian == "MM":
|
||||
# FIXME:
|
||||
# value_or_offset requires a fixup under big-endian encoding.
|
||||
if tag_type == 2:
|
||||
# 2 --> "ascii"
|
||||
value_or_offset >>= 24
|
||||
elif tag_type == 3:
|
||||
# 3 --> "short"
|
||||
value_or_offset >>= 16
|
||||
else:
|
||||
# ... FIXME
|
||||
pass
|
||||
if count == 0:
|
||||
raise RuntimeError("unsupported count=0 in tag 0x%x" % tag_id)
|
||||
if tag_id == _TIFF_EXIF_IFD:
|
||||
if tag_type != 4:
|
||||
raise RuntimeError("incorrect tag type for EXIF IFD")
|
||||
self._exif_ifd_offset = value_or_offset
|
||||
elif tag_id == _GPS_IFD:
|
||||
if tag_type != 4:
|
||||
raise RuntimeError("incorrect tag type for GPS IFD")
|
||||
self._gps_ifd_offset = value_or_offset
|
||||
elif tag_id == _INTEROPERABILITY_IFD:
|
||||
if tag_type != 4:
|
||||
raise RuntimeError("incorrect tag type for Interop IFD")
|
||||
self._interoperability_ifd_offset = value_or_offset
|
||||
yield (tag_id, tag_type, count, value_or_offset)
|
||||
|
||||
def tags(self):
|
||||
"""Yield all TIFF/EXIF tags."""
|
||||
if self._verbose:
|
||||
print("TIFF IFD : 0x%08x" % self._global_ifd_offset)
|
||||
for tag in self._tags_for_ifd(self._global_ifd_offset):
|
||||
yield tag
|
||||
if self._exif_ifd_offset > 0:
|
||||
if self._verbose:
|
||||
print("EXIF IFD : 0x%08x" % self._exif_ifd_offset)
|
||||
for tag in self._tags_for_ifd(self._exif_ifd_offset):
|
||||
yield tag
|
||||
if self._gps_ifd_offset > 0:
|
||||
if self._verbose:
|
||||
print("GPS IFD : 0x%08x" % self._gps_ifd_offset)
|
||||
for tag in self._tags_for_ifd(self._gps_ifd_offset):
|
||||
yield tag
|
||||
if self._interoperability_ifd_offset > 0:
|
||||
if self._verbose:
|
||||
print("Interoperability IFD : 0x%08x" %
|
||||
self._interoperability_ifd_offset)
|
||||
for tag in self._tags_for_ifd(self._interoperability_ifd_offset):
|
||||
yield tag
|
||||
|
||||
def tagid2str(self, tag_id):
|
||||
"""Return an informative string representation of a TIFF tag id."""
|
||||
idstr = _TIFF_TAGS.get(tag_id, "[Unknown]")
|
||||
if self._hex:
|
||||
idnum = "0x%04x" % tag_id
|
||||
else:
|
||||
idnum = "%d" % tag_id
|
||||
return "%s (%s)" % (idstr, idnum)
|
||||
|
||||
@staticmethod
|
||||
def tagtype2str(tag_type):
|
||||
"""Return an informative string representation of a TIFF tag type."""
|
||||
typestr = _TIFF_TAG_TYPES.get(tag_type, "[unknown]")
|
||||
return "%d:%s" % (tag_type, typestr)
|
||||
|
||||
def tag2str(self, tag_id, tag_type, count, value_or_offset):
|
||||
"""Return an informative string representation of a TIFF tag tuple."""
|
||||
return "%s (type=%s) (count=%d) : 0x%08x" \
|
||||
% (self.tagid2str(tag_id), self.tagtype2str(tag_type), count,
|
||||
value_or_offset)
|
||||
|
||||
def _ui32(self):
|
||||
"""Decode a 32-bit unsigned int found at the current offset;
|
||||
advance the offset by 4.
|
||||
"""
|
||||
if self._offset + 4 > len(self._buffer):
|
||||
raise RuntimeError("out-of-bounds uint32 access in EXIF")
|
||||
if self._endian == "MM":
|
||||
result = unpack_uint32be(self._buffer, self._offset)
|
||||
else:
|
||||
result = unpack_uint32le(self._buffer, self._offset)
|
||||
self._offset += 4
|
||||
return result
|
||||
|
||||
def _ui16(self):
|
||||
"""Decode a 16-bit unsigned int found at the current offset;
|
||||
advance the offset by 2.
|
||||
"""
|
||||
if self._offset + 2 > len(self._buffer):
|
||||
raise RuntimeError("out-of-bounds uint16 access in EXIF")
|
||||
if self._endian == "MM":
|
||||
result = unpack_uint16be(self._buffer, self._offset)
|
||||
else:
|
||||
result = unpack_uint16le(self._buffer, self._offset)
|
||||
self._offset += 2
|
||||
return result
|
||||
|
||||
def _ui8(self):
|
||||
"""Decode an 8-bit unsigned int found at the current offset;
|
||||
advance the offset by 1.
|
||||
"""
|
||||
if self._offset + 1 > len(self._buffer):
|
||||
raise RuntimeError("out-of-bounds uint8 access in EXIF")
|
||||
result = unpack_uint8(self._buffer, self._offset)
|
||||
self._offset += 1
|
||||
return result
|
||||
|
||||
|
||||
def print_raw_exif_info(buffer, **kwargs):
|
||||
"""Print the EXIF information found in a raw byte stream."""
|
||||
lister = ExifInfo(buffer, **kwargs)
|
||||
print("EXIF (endian=%s)" % lister.endian())
|
||||
for (tag_id, tag_type, count, value_or_offset) in lister.tags():
|
||||
print(lister.tag2str(tag_id=tag_id,
|
||||
tag_type=tag_type,
|
||||
count=count,
|
||||
value_or_offset=value_or_offset))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# For testing only.
|
||||
for arg in sys.argv[1:]:
|
||||
with open(arg, "rb") as test_stream:
|
||||
test_buffer = test_stream.read(_READ_DATA_SIZE_MAX)
|
||||
print_raw_exif_info(test_buffer, hex=True, verbose=True)
|
||||
10
contrib/pngexif/pngexifinfo
Executable file
10
contrib/pngexif/pngexifinfo
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
my_python="$(command -v python3 || command -v python)" || {
|
||||
echo >&2 "error: program not found: Python interpreter"
|
||||
exit 127
|
||||
}
|
||||
my_python_flags="-BES"
|
||||
|
||||
exec "$my_python" "$my_python_flags" "$(dirname "$0")/pngexifinfo.py" "$@"
|
||||
4
contrib/pngexif/pngexifinfo.bat
Normal file
4
contrib/pngexif/pngexifinfo.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
@setlocal enableextensions
|
||||
|
||||
python.exe -BES %~dp0.\pngexifinfo.py %*
|
||||
178
contrib/pngexif/pngexifinfo.py
Executable file
178
contrib/pngexif/pngexifinfo.py
Executable file
@@ -0,0 +1,178 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Show the PNG EXIF information.
|
||||
|
||||
Copyright (C) 2017-2020 Cosmin Truta.
|
||||
|
||||
Use, modification and distribution are subject to the MIT License.
|
||||
Please see the accompanying file LICENSE_MIT.txt
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import re
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
from bytepack import unpack_uint32be, unpack_uint8
|
||||
from exifinfo import print_raw_exif_info
|
||||
|
||||
_PNG_SIGNATURE = b"\x89PNG\x0d\x0a\x1a\x0a"
|
||||
_PNG_CHUNK_SIZE_MAX = 0x7fffffff
|
||||
_READ_DATA_SIZE_MAX = 0x3ffff
|
||||
|
||||
|
||||
def print_error(msg):
|
||||
"""Print an error message to stderr."""
|
||||
sys.stderr.write("%s: error: %s\n" % (sys.argv[0], msg))
|
||||
|
||||
|
||||
def print_debug(msg):
|
||||
"""Print a debug message to stderr."""
|
||||
sys.stderr.write("%s: debug: %s\n" % (sys.argv[0], msg))
|
||||
|
||||
|
||||
def _check_png(condition, chunk_sig=None):
|
||||
"""Check a PNG-specific assertion."""
|
||||
if condition:
|
||||
return
|
||||
if chunk_sig is None:
|
||||
raise RuntimeError("bad PNG data")
|
||||
raise RuntimeError("bad PNG data in '%s'" % chunk_sig)
|
||||
|
||||
|
||||
def _check_png_crc(data, checksum, chunk_sig):
|
||||
"""Check a CRC32 value inside a PNG stream."""
|
||||
if unpack_uint32be(data) == (checksum & 0xffffffff):
|
||||
return
|
||||
raise RuntimeError("bad PNG checksum in '%s'" % chunk_sig)
|
||||
|
||||
|
||||
def _extract_png_exif(data, **kwargs):
|
||||
"""Extract the EXIF header and data from a PNG chunk."""
|
||||
debug = kwargs.get("debug", False)
|
||||
if unpack_uint8(data, 0) == 0:
|
||||
if debug:
|
||||
print_debug("found compressed EXIF, compression method 0")
|
||||
if (unpack_uint8(data, 1) & 0x0f) == 0x08:
|
||||
data = zlib.decompress(data[1:])
|
||||
elif unpack_uint8(data, 1) == 0 \
|
||||
and (unpack_uint8(data, 5) & 0x0f) == 0x08:
|
||||
if debug:
|
||||
print_debug("found uncompressed-length EXIF field")
|
||||
data_len = unpack_uint32be(data, 1)
|
||||
data = zlib.decompress(data[5:])
|
||||
if data_len != len(data):
|
||||
raise RuntimeError(
|
||||
"incorrect uncompressed-length field in PNG EXIF")
|
||||
else:
|
||||
raise RuntimeError("invalid compression method in PNG EXIF")
|
||||
if data.startswith(b"MM\x00\x2a") or data.startswith(b"II\x2a\x00"):
|
||||
return data
|
||||
raise RuntimeError("invalid TIFF/EXIF header in PNG EXIF")
|
||||
|
||||
|
||||
def print_png_exif_info(instream, **kwargs):
|
||||
"""Print the EXIF information found in the given PNG datastream."""
|
||||
debug = kwargs.get("debug", False)
|
||||
has_exif = False
|
||||
while True:
|
||||
chunk_hdr = instream.read(8)
|
||||
_check_png(len(chunk_hdr) == 8)
|
||||
chunk_len = unpack_uint32be(chunk_hdr, offset=0)
|
||||
chunk_sig = chunk_hdr[4:8].decode("latin_1", errors="ignore")
|
||||
_check_png(re.search(r"^[A-Za-z]{4}$", chunk_sig), chunk_sig=chunk_sig)
|
||||
_check_png(chunk_len < _PNG_CHUNK_SIZE_MAX, chunk_sig=chunk_sig)
|
||||
if debug:
|
||||
print_debug("processing chunk: %s" % chunk_sig)
|
||||
if chunk_len <= _READ_DATA_SIZE_MAX:
|
||||
# The chunk size does not exceed an arbitrary, reasonable limit.
|
||||
chunk_data = instream.read(chunk_len)
|
||||
chunk_crc = instream.read(4)
|
||||
_check_png(len(chunk_data) == chunk_len and len(chunk_crc) == 4,
|
||||
chunk_sig=chunk_sig)
|
||||
checksum = zlib.crc32(chunk_hdr[4:8])
|
||||
checksum = zlib.crc32(chunk_data, checksum)
|
||||
_check_png_crc(chunk_crc, checksum, chunk_sig=chunk_sig)
|
||||
else:
|
||||
# The chunk is too big. Skip it.
|
||||
instream.seek(chunk_len + 4, io.SEEK_CUR)
|
||||
continue
|
||||
if chunk_sig == "IEND":
|
||||
_check_png(chunk_len == 0, chunk_sig=chunk_sig)
|
||||
break
|
||||
if chunk_sig.lower() in ["exif", "zxif"] and chunk_len > 8:
|
||||
has_exif = True
|
||||
exif_data = _extract_png_exif(chunk_data, **kwargs)
|
||||
print_raw_exif_info(exif_data, **kwargs)
|
||||
if not has_exif:
|
||||
raise RuntimeError("no EXIF data in PNG stream")
|
||||
|
||||
|
||||
def print_exif_info(file, **kwargs):
|
||||
"""Print the EXIF information found in the given file."""
|
||||
with open(file, "rb") as stream:
|
||||
header = stream.read(4)
|
||||
if header == _PNG_SIGNATURE[0:4]:
|
||||
if stream.read(4) != _PNG_SIGNATURE[4:8]:
|
||||
raise RuntimeError("corrupted PNG file")
|
||||
print_png_exif_info(instream=stream, **kwargs)
|
||||
elif header == b"II\x2a\x00" or header == b"MM\x00\x2a":
|
||||
data = header + stream.read(_READ_DATA_SIZE_MAX)
|
||||
print_raw_exif_info(data, **kwargs)
|
||||
else:
|
||||
raise RuntimeError("not a PNG file")
|
||||
|
||||
|
||||
def main():
|
||||
"""The main function."""
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="pngexifinfo",
|
||||
usage="%(prog)s [options] [--] files...",
|
||||
description="Show the PNG EXIF information.")
|
||||
parser.add_argument("files",
|
||||
metavar="file",
|
||||
nargs="*",
|
||||
help="a PNG file or a raw EXIF blob")
|
||||
parser.add_argument("-x",
|
||||
"--hex",
|
||||
dest="hex",
|
||||
action="store_true",
|
||||
help="show EXIF tags in base 16")
|
||||
parser.add_argument("-v",
|
||||
"--verbose",
|
||||
dest="verbose",
|
||||
action="store_true",
|
||||
help="run in verbose mode")
|
||||
parser.add_argument("--debug",
|
||||
dest="debug",
|
||||
action="store_true",
|
||||
help="run in debug mode")
|
||||
args = parser.parse_args()
|
||||
if not args.files:
|
||||
parser.error("missing file operand")
|
||||
result = 0
|
||||
for file in args.files:
|
||||
try:
|
||||
print_exif_info(file,
|
||||
hex=args.hex,
|
||||
debug=args.debug,
|
||||
verbose=args.verbose)
|
||||
except (IOError, OSError) as err:
|
||||
print_error(str(err))
|
||||
result = 66 # os.EX_NOINPUT
|
||||
except RuntimeError as err:
|
||||
print_error("%s: %s" % (file, str(err)))
|
||||
result = 69 # os.EX_UNAVAILABLE
|
||||
parser.exit(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
sys.stderr.write("INTERRUPTED\n")
|
||||
sys.exit(130) # SIGINT
|
||||
@@ -54,7 +54,7 @@ ZOBJS = adler32$(O) crc32$(O) \
|
||||
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||
pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
|
||||
pngset$(C) pngtrans$(C)
|
||||
|
||||
|
||||
# Standard headers
|
||||
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||
|
||||
|
||||
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
|
||||
--------
|
||||
(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
|
||||
------------
|
||||
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
|
||||
and merged the two together into pnmtopng.tar.gz, which is available
|
||||
from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
|
||||
and merged the two, which later became part of NetPBM, available from
|
||||
SourceForge.
|
||||
|
||||
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
|
||||
@@ -35,8 +25,8 @@ makes the whole setup a bit bulky. But that's unavoidable given the many
|
||||
features of pnmtopng.
|
||||
|
||||
|
||||
What now
|
||||
--------
|
||||
What now (1999)
|
||||
---------------
|
||||
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
|
||||
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
|
||||
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
|
||||
software developments. (By now there are of course a couple of programs,
|
||||
like Greg Roelofs' rpng/wpng, that can be used just as good.)
|
||||
software developments. By now there are of course a couple of programs,
|
||||
like Greg Roelofs' rpng/wpng, that can be used just as good.
|
||||
|
||||
|
||||
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,
|
||||
another reason to call it PngMinus (minus netpbm :-). So, part of the
|
||||
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
|
||||
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
|
||||
--------------------------------
|
||||
You have to put it together yourself. I did test the software under
|
||||
MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
|
||||
cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
|
||||
however some older libpng versions have a bug in pngmem.c when using
|
||||
Turbo-C 3.0 (see below).
|
||||
You have to put it together yourself. I developed the software on MS-DOS
|
||||
with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
|
||||
libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
|
||||
more current versions are OK.
|
||||
|
||||
You can build it using one of the two makefiles (make -f makefile.###)
|
||||
or use the batch/script files pngminus.bat / pngminus.sh. This assumes
|
||||
that you have built the libraries in ../libpng and ../zlib. Using Linux,
|
||||
make sure that you have built libpng with makefile.std and not
|
||||
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.
|
||||
The makefile assumes that the libpng libraries can be found in ../.. and
|
||||
libz in ../../../zlib. But you can change this to for example ../libpng
|
||||
and ../zlib. The makefile creates two versions of each program, one with
|
||||
static library support and the other using shared libraries.
|
||||
|
||||
If you create a ../pngsuite directory and then store the basn####.png
|
||||
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
|
||||
pnm2png.bat (or the .sh versions).
|
||||
test the proper functioning of PngMinus by running pngminus.sh.
|
||||
|
||||
|
||||
Warranty
|
||||
-------
|
||||
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
|
||||
it when you are in need for something simple or when you want to start
|
||||
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;
|
||||
**
|
||||
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 a starting
|
||||
point for developing your own stuff.
|
||||
|
||||
|
||||
The end
|
||||
-------
|
||||
Willem van Schaik
|
||||
mailto:willem at schaik.com
|
||||
mailto:willem at schaik dot com
|
||||
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,75 +1,52 @@
|
||||
/*
|
||||
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file
|
||||
* copyright (C) 1999,2017 by Willem van Schaik <willem at schaik.com>
|
||||
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
|
||||
* 1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||
(Glenn Randers-Pehrson)
|
||||
*
|
||||
* 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.
|
||||
* This software is released under the MIT license. For conditions of
|
||||
* distribution and use, see the LICENSE file part of this package.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (BOOL) 1
|
||||
#define TRUE ((BOOL) 1)
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#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
|
||||
#define FALSE ((BOOL) 0)
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
int main (int argc, char *argv[]);
|
||||
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
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_wr = stdout;
|
||||
FILE *fp_al = NULL;
|
||||
const char *fname_wr = NULL;
|
||||
const char *fname_al = NULL;
|
||||
BOOL raw = TRUE;
|
||||
BOOL alpha = FALSE;
|
||||
int argi;
|
||||
int ret;
|
||||
|
||||
for (argi = 1; argi < argc; argi++)
|
||||
{
|
||||
@@ -88,22 +65,23 @@ int main(int argc, char *argv[])
|
||||
argi++;
|
||||
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
fname_al = argv[argi];
|
||||
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);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
usage ();
|
||||
exit (0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
@@ -111,17 +89,18 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
else if (fp_wr == stdout)
|
||||
{
|
||||
fname_wr = argv[argi];
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -129,30 +108,21 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||
/* set stdin/stdout if required to binary */
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdin), O_BINARY);
|
||||
if ((raw) && (fp_wr == stdout))
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdout), O_BINARY);
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
|
||||
exit(1);
|
||||
}
|
||||
ret = png2pnm (fp_rd, fp_wr, fp_al, raw, alpha);
|
||||
|
||||
/* close input file */
|
||||
fclose (fp_rd);
|
||||
@@ -162,6 +132,17 @@ int main(int argc, char *argv[])
|
||||
if (alpha)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -169,23 +150,18 @@ int main(int argc, char *argv[])
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
void usage ()
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\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, " or: ... | png2pnm [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
fprintf (stderr,
|
||||
" -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
|
||||
" -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,
|
||||
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||
" -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
|
||||
fprintf (stderr, " -h | -? print this help-information\n");
|
||||
}
|
||||
|
||||
@@ -194,79 +170,70 @@ void usage()
|
||||
*/
|
||||
|
||||
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
volatile BOOL raw, BOOL alpha)
|
||||
BOOL raw, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte buf[8];
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
png_uint_32 row_bytes;
|
||||
png_struct *png_ptr;
|
||||
png_info *info_ptr;
|
||||
BOOL ret;
|
||||
|
||||
/* 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 height;
|
||||
int bit_depth;
|
||||
int channels;
|
||||
int color_type;
|
||||
int alpha_present;
|
||||
int row, col;
|
||||
int ret;
|
||||
int i;
|
||||
png_uint_32 row, col, i;
|
||||
long dep_16;
|
||||
|
||||
/* read and check signature in PNG file */
|
||||
ret = fread (buf, 1, 8, png_file);
|
||||
if (ret != 8)
|
||||
return FALSE;
|
||||
/* set up the image transformations that are necessary for the PNM format */
|
||||
|
||||
ret = png_sig_cmp (buf, 0, 8);
|
||||
if (ret)
|
||||
return FALSE;
|
||||
/* set up (if applicable) the expansion of paletted images to full-color rgb,
|
||||
* and the expansion of transparency maps to full alpha-channel */
|
||||
png_set_expand (png_ptr);
|
||||
|
||||
/* create png and info structures */
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
/* set up (if applicable) the expansion of grayscale images to bit-depth 8 */
|
||||
png_set_expand_gray_1_2_4_to_8 (png_ptr);
|
||||
|
||||
#ifdef NJET
|
||||
/* downgrade 16-bit images to 8-bit */
|
||||
@@ -274,32 +241,24 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
png_set_strip_16 (png_ptr);
|
||||
/* transform grayscale images into full-color */
|
||||
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);
|
||||
/* only if file has a file gamma, we do a correction */
|
||||
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)
|
||||
/* if the PNG image has a gAMA chunk then gamma-correct the output image */
|
||||
{
|
||||
raw = FALSE;
|
||||
#ifdef __TURBOC__
|
||||
pnm_file->flags &= ~((unsigned) _F_BIN);
|
||||
#endif
|
||||
double file_gamma;
|
||||
if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
|
||||
png_set_gamma (png_ptr, (double) 2.2, file_gamma);
|
||||
}
|
||||
#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)
|
||||
channels = 1;
|
||||
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
@@ -316,47 +275,12 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
if (alpha && !alpha_present)
|
||||
{
|
||||
fprintf (stderr, "PNG2PNM\n");
|
||||
fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\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 ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
|
||||
{
|
||||
/* too big */
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
if ((png_pixels = (png_byte *)
|
||||
malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
|
||||
{
|
||||
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
|
||||
fprintf (stderr, "Warning: no alpha channel in PNG file\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((row_pointers = (png_byte **)
|
||||
malloc ((size_t)height * sizeof (png_bytep))) == NULL)
|
||||
{
|
||||
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 < ((int) 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);
|
||||
/* get address of internally-allocated image data */
|
||||
row_pointers = png_get_rows (png_ptr, info_ptr);
|
||||
|
||||
/* write header of PNM file */
|
||||
|
||||
@@ -387,46 +311,67 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
}
|
||||
|
||||
/* write data to PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
|
||||
for (row = 0; row < (int) height; row++)
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (col = 0; col < (int) width; col++)
|
||||
pix_ptr = row_pointers[row];
|
||||
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)
|
||||
fputc ((int) *pix_ptr++ , pnm_file);
|
||||
{
|
||||
fputc ((int) *pix_ptr++, pnm_file);
|
||||
if (bit_depth == 16)
|
||||
fputc ((int) *pix_ptr++, pnm_file);
|
||||
}
|
||||
else
|
||||
if (bit_depth == 16){
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
|
||||
{
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
dep_16 = ((long) *pix_ptr++) << 8;
|
||||
dep_16 += ((long) *pix_ptr++);
|
||||
fprintf (pnm_file, "%ld ", dep_16);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (alpha_present)
|
||||
{
|
||||
if (!alpha)
|
||||
{
|
||||
pix_ptr++; /* alpha */
|
||||
/* skip the alpha-channel */
|
||||
pix_ptr++;
|
||||
if (bit_depth == 16)
|
||||
pix_ptr++;
|
||||
}
|
||||
else /* output alpha-channel as pgm file */
|
||||
else
|
||||
{
|
||||
/* output the alpha-channel as pgm file */
|
||||
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
|
||||
{
|
||||
if (bit_depth == 16)
|
||||
{
|
||||
dep_16 = (long) *pix_ptr++;
|
||||
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
|
||||
{
|
||||
fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* if alpha_present */
|
||||
} /* end if alpha_present */
|
||||
|
||||
if (!raw)
|
||||
if (col % 4 == 3)
|
||||
@@ -438,13 +383,5 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
|
||||
fprintf (pnm_file, "\n");
|
||||
} /* end for row */
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
free (png_pixels);
|
||||
|
||||
PNG_UNUSED(raw) /* to quiet a Coverity defect */
|
||||
return TRUE;
|
||||
|
||||
} /* end of source */
|
||||
|
||||
|
||||
@@ -1,77 +1,57 @@
|
||||
/*
|
||||
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||
* copyright (C) 1999,2015,2017 by Willem van Schaik <willem at schaik.com>
|
||||
* copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||
*
|
||||
* version 1.0 - 1999.10.15 - First version.
|
||||
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||
* version 1.2 - 2017.04.22 - Add buffer-size check
|
||||
* 1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||
* (Glenn Randers-Pehrson)
|
||||
*
|
||||
* 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.
|
||||
* This software is released under the MIT license. For conditions of
|
||||
* distribution and use, see the LICENSE file part of this package.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL unsigned char
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (BOOL) 1
|
||||
#define TRUE ((BOOL) 1)
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#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
|
||||
#define FALSE ((BOOL) 0)
|
||||
#endif
|
||||
|
||||
#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 */
|
||||
|
||||
int main (int argc, char *argv[]);
|
||||
int main (int argc, char *argv[]);
|
||||
void usage ();
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha);
|
||||
void get_token(FILE *pnm_file, char *token);
|
||||
png_uint_32 get_data (FILE *pnm_file, int depth);
|
||||
png_uint_32 get_value (FILE *pnm_file, int depth);
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
|
||||
BOOL interlace, BOOL alpha);
|
||||
BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
|
||||
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
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *fp_rd = stdin;
|
||||
FILE *fp_al = NULL;
|
||||
FILE *fp_wr = stdout;
|
||||
const char *fname_wr = NULL;
|
||||
BOOL interlace = FALSE;
|
||||
BOOL alpha = FALSE;
|
||||
int argi;
|
||||
int ret;
|
||||
|
||||
for (argi = 1; argi < argc; argi++)
|
||||
{
|
||||
@@ -89,20 +69,20 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: alpha-channel file %s does not exist\n",
|
||||
argv[argi]);
|
||||
argv[argi]);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
usage ();
|
||||
exit (0);
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
|
||||
usage();
|
||||
exit(1);
|
||||
usage ();
|
||||
exit (1);
|
||||
break;
|
||||
} /* end switch */
|
||||
}
|
||||
@@ -117,10 +97,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (fp_wr == stdout)
|
||||
{
|
||||
fname_wr = argv[argi];
|
||||
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -128,30 +109,23 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: too many parameters\n");
|
||||
usage();
|
||||
usage ();
|
||||
exit (1);
|
||||
}
|
||||
} /* end for */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
/* set stdin/stdout to binary, we're reading the PNM always! in binary format */
|
||||
#if defined(O_BINARY) && (O_BINARY != 0)
|
||||
/* set stdin/stdout to binary,
|
||||
* we're reading the PNM always! in binary format
|
||||
*/
|
||||
if (fp_rd == stdin)
|
||||
{
|
||||
setmode (STDIN, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdin), O_BINARY);
|
||||
if (fp_wr == stdout)
|
||||
{
|
||||
setmode (STDOUT, O_BINARY);
|
||||
}
|
||||
setmode (fileno (stdout), O_BINARY);
|
||||
#endif
|
||||
|
||||
/* call the conversion program itself */
|
||||
if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE)
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\n");
|
||||
fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
|
||||
exit (1);
|
||||
}
|
||||
ret = pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha);
|
||||
|
||||
/* close input file */
|
||||
fclose (fp_rd);
|
||||
@@ -161,6 +135,15 @@ int main(int argc, char *argv[])
|
||||
if (alpha)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -168,15 +151,10 @@ int main(int argc, char *argv[])
|
||||
* usage
|
||||
*/
|
||||
|
||||
void usage()
|
||||
void usage ()
|
||||
{
|
||||
fprintf (stderr, "PNM2PNG\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, " or: ... | pnm2png [options]\n");
|
||||
fprintf (stderr, "Options:\n");
|
||||
@@ -190,103 +168,101 @@ void usage()
|
||||
* pnm2png
|
||||
*/
|
||||
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
BOOL alpha)
|
||||
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
|
||||
BOOL interlace, BOOL alpha)
|
||||
{
|
||||
png_struct *png_ptr = NULL;
|
||||
png_info *info_ptr = NULL;
|
||||
png_byte *png_pixels = NULL;
|
||||
png_byte **row_pointers = NULL;
|
||||
png_byte *pix_ptr = NULL;
|
||||
volatile png_uint_32 row_bytes;
|
||||
png_struct *png_ptr;
|
||||
png_info *info_ptr;
|
||||
BOOL ret;
|
||||
|
||||
char type_token[16];
|
||||
char width_token[16];
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
volatile int color_type=1;
|
||||
unsigned long ul_width=0, ul_alpha_width=0;
|
||||
unsigned long ul_height=0, ul_alpha_height=0;
|
||||
unsigned long ul_maxval=0;
|
||||
volatile png_uint_32 width=0, height=0;
|
||||
volatile png_uint_32 alpha_width=0, alpha_height=0;
|
||||
png_uint_32 maxval;
|
||||
volatile int bit_depth = 0;
|
||||
int channels=0;
|
||||
int alpha_depth = 0;
|
||||
int alpha_present=0;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* initialize the libpng context for writing to png_file */
|
||||
|
||||
png_ptr = png_create_write_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_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 channels;
|
||||
char magic_token[4];
|
||||
BOOL raw;
|
||||
png_uint_32 width, height, maxval;
|
||||
png_uint_32 row_bytes;
|
||||
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;
|
||||
#endif
|
||||
png_uint_32 tmp16;
|
||||
int i;
|
||||
|
||||
/* read header of PNM file */
|
||||
|
||||
get_token(pnm_file, type_token);
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
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 (fscan_pnm_magic (pnm_file, magic_token, sizeof (magic_token)) != 1)
|
||||
return FALSE; /* not a PNM file */
|
||||
|
||||
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 <= 65535) */
|
||||
bit_depth = 16;
|
||||
}
|
||||
else if ((type_token[1] == '3') || (type_token[1] == '6'))
|
||||
if ((magic_token[1] == '1') || (magic_token[1] == '4'))
|
||||
{
|
||||
raw = (type_token[1] == '6');
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
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 ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
|
||||
(fscan_pnm_uint_32 (pnm_file, &height) != 1))
|
||||
return FALSE; /* bad PBM file header */
|
||||
} else if ((magic_token[1] == '2') || (magic_token[1] == '5') ||
|
||||
(magic_token[1] == '3') || (magic_token[1] == '6'))
|
||||
{
|
||||
if ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
|
||||
(fscan_pnm_uint_32 (pnm_file, &height) != 1) ||
|
||||
(fscan_pnm_uint_32 (pnm_file, &maxval) != 1))
|
||||
return FALSE; /* bad PGM/PPM file header */
|
||||
}
|
||||
|
||||
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;
|
||||
else if (maxval <= 3)
|
||||
bit_depth = 2;
|
||||
@@ -294,8 +270,34 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
bit_depth = 4;
|
||||
else if (maxval <= 255)
|
||||
bit_depth = 8;
|
||||
else /* if (maxval <= 65535) */
|
||||
else if (maxval <= 65535U)
|
||||
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
|
||||
{
|
||||
@@ -306,49 +308,36 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY)
|
||||
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
if (color_type == PNG_COLOR_TYPE_RGB)
|
||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
if ((fscan_pnm_magic (alpha_file, magic_token, sizeof (magic_token)) != 1)
|
||||
|| ((magic_token[1] != '2') && (magic_token[1] != '5')))
|
||||
return FALSE; /* not a PGM file */
|
||||
|
||||
get_token(alpha_file, type_token);
|
||||
if (type_token[0] != 'P')
|
||||
{
|
||||
if ((fscan_pnm_uint_32 (alpha_file, &alpha_width) != 1) ||
|
||||
(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;
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
alpha_raw = (type_token[1] == '5');
|
||||
get_token(alpha_file, width_token);
|
||||
sscanf (width_token, "%lu", &ul_alpha_width);
|
||||
alpha_width=(png_uint_32) ul_alpha_width;
|
||||
if (alpha_width != width)
|
||||
return FALSE;
|
||||
get_token(alpha_file, height_token);
|
||||
sscanf (height_token, "%lu", &ul_alpha_height);
|
||||
alpha_height = (png_uint_32) ul_alpha_height;
|
||||
if (alpha_height != height)
|
||||
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
|
||||
{
|
||||
else 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 <= 65535U)
|
||||
alpha_depth = 16;
|
||||
else /* maxval > 65535U */
|
||||
return FALSE;
|
||||
if (alpha_depth != bit_depth)
|
||||
return FALSE;
|
||||
}
|
||||
} /* end if alpha */
|
||||
|
||||
/* calculate the number of channels and store alpha-presence */
|
||||
@@ -360,219 +349,259 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
channels = 3;
|
||||
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
channels = 4;
|
||||
#if 0
|
||||
else
|
||||
channels = 0; /* cannot happen */
|
||||
#endif
|
||||
return FALSE; /* NOTREACHED */
|
||||
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap)
|
||||
{
|
||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes)
|
||||
{
|
||||
/* too big */
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
}
|
||||
|
||||
if ((row_bytes == 0) ||
|
||||
((size_t) height > (size_t) (-1) / (size_t) row_bytes))
|
||||
{
|
||||
/* too big */
|
||||
return FALSE;
|
||||
}
|
||||
if ((png_pixels = (png_byte *)
|
||||
malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* read data from PNM file */
|
||||
pix_ptr = png_pixels;
|
||||
|
||||
for (row = 0; row < (int) height; row++)
|
||||
/* allocate the rows using the same memory layout as libpng, and transfer
|
||||
* 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++)
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
/* 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++)
|
||||
{
|
||||
pix_ptr = row_pointers[row];
|
||||
if (packed_bitmap)
|
||||
{
|
||||
for (i = 0; i < (int) row_bytes; i++)
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_data (pnm_file, 8);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (col = 0; col < (int) width; col++)
|
||||
for (i = 0; i < row_bytes; i++)
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_pnm_data (pnm_file, 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
for (i = 0; i < (png_uint_32) (channels - alpha_present); i++)
|
||||
{
|
||||
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
|
||||
{
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
{
|
||||
*pix_ptr++ = get_pnm_value (pnm_file, bit_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
val16 = get_pnm_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((val16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
*pix_ptr = (png_byte) (val16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
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
|
||||
{
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
{
|
||||
*pix_ptr++ = get_pnm_value (alpha_file, bit_depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
val16 = get_pnm_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((val16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (val16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
} /* if packed_bitmap */
|
||||
}
|
||||
} /* end if alpha */
|
||||
} /* end if packed_bitmap */
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
/* prepare the standard PNG structures */
|
||||
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
|
||||
NULL);
|
||||
if (!png_ptr)
|
||||
{
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
info_ptr = png_create_info_struct (png_ptr);
|
||||
if (!info_ptr)
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
/* 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);
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap == TRUE)
|
||||
{
|
||||
png_set_packing (png_ptr);
|
||||
png_set_invert_mono (png_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = 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 */
|
||||
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, &info_ptr);
|
||||
free (png_pixels);
|
||||
png_pixels = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the individual row_pointers to point at the correct offsets */
|
||||
for (i = 0; i < (int) height; i++)
|
||||
row_pointers[i] = png_pixels + i * row_bytes;
|
||||
|
||||
/* write out the entire image data in one call */
|
||||
png_write_image (png_ptr, row_pointers);
|
||||
|
||||
/* write the additional chunks to the PNG file (not really needed) */
|
||||
png_write_end (png_ptr, info_ptr);
|
||||
|
||||
/* clean up after the write, and free any memory allocated */
|
||||
png_destroy_write_struct (&png_ptr, &info_ptr);
|
||||
|
||||
if (row_pointers != (unsigned char**) NULL)
|
||||
free (row_pointers);
|
||||
if (png_pixels != (unsigned char*) NULL)
|
||||
free (png_pixels);
|
||||
|
||||
PNG_UNUSED(raw) /* Quiet a Coverity defect */
|
||||
|
||||
return TRUE;
|
||||
} /* 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;
|
||||
|
||||
/* remove white-space and comment lines */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
if (ret == '#')
|
||||
{
|
||||
/* the rest of this line is a comment */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
}
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||
}
|
||||
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 */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
ret = fgetc (pnm_file);
|
||||
if (ret == EOF) break;
|
||||
i++;
|
||||
token[i] = (unsigned char) ret;
|
||||
if (ret == '0')
|
||||
{
|
||||
/* 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';
|
||||
|
||||
return;
|
||||
token_buf[i] = '\0';
|
||||
return (i > 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_data() - takes first byte and converts into next pixel value,
|
||||
* taking as much bits as defined by bit-depth and
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
* fscan_pnm_uint_32 - like fscan_token above, but expects the extracted token
|
||||
* to be numeric, and converts it to an unsigned 32-bit int
|
||||
*/
|
||||
|
||||
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 old_value = 0;
|
||||
static int mask = 0;
|
||||
int i;
|
||||
png_uint_32 ret_value;
|
||||
int i;
|
||||
|
||||
if (mask == 0)
|
||||
for (i = 0; i < depth; i++)
|
||||
@@ -580,7 +609,11 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
|
||||
|
||||
if (bits_left <= 0)
|
||||
{
|
||||
/* FIXME:
|
||||
* signal the premature end of file, instead of pretending to read zeroes
|
||||
*/
|
||||
old_value = fgetc (pnm_file);
|
||||
if (old_value == EOF) return 0;
|
||||
bits_left = 8;
|
||||
}
|
||||
|
||||
@@ -595,25 +628,28 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
|
||||
}
|
||||
|
||||
/*
|
||||
* get_value() - takes first (numeric) string and converts into number,
|
||||
* using the bit-depth to fill up a byte (0Ah -> AAh)
|
||||
* get_pnm_value - takes first (numeric) string and converts into number,
|
||||
* 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;
|
||||
png_byte token[16];
|
||||
unsigned long ul_ret_value;
|
||||
png_uint_32 ret_value;
|
||||
int i = 0;
|
||||
int i;
|
||||
|
||||
if (mask == 0)
|
||||
for (i = 0; i < depth; i++)
|
||||
mask = (mask << 1) | 0x01;
|
||||
|
||||
get_token (pnm_file, (char *) token);
|
||||
sscanf ((const char *) token, "%lu", &ul_ret_value);
|
||||
ret_value = (png_uint_32) ul_ret_value;
|
||||
if (fscan_pnm_uint_32 (pnm_file, &ret_value) != 1)
|
||||
{
|
||||
/* FIXME:
|
||||
* signal the invalid numeric tokens or the premature end of file,
|
||||
* instead of pretending to read zeroes
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret_value &= mask;
|
||||
|
||||
@@ -625,4 +661,3 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
|
||||
}
|
||||
|
||||
/* end of source */
|
||||
|
||||
|
||||
4
contrib/pngminus/png2pnm.bat → contrib/pngminus/test_png2pnm.bat
Executable file → Normal file
4
contrib/pngminus/png2pnm.bat → contrib/pngminus/test_png2pnm.bat
Executable file → Normal file
@@ -7,7 +7,7 @@ png2pnm.exe -noraw ..\pngsuite\basn0g16.png basn0g16.pgm
|
||||
REM -- full-color
|
||||
png2pnm.exe -noraw ..\pngsuite\basn2c08.png basn2c08.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\basn3p02.png basn3p02.ppm
|
||||
png2pnm.exe -noraw ..\pngsuite\basn3p04.png basn3p04.ppm
|
||||
@@ -27,7 +27,7 @@ png2pnm.exe -raw ..\pngsuite\basn0g16.png rawn0g16.pgm
|
||||
REM -- full-color
|
||||
png2pnm.exe -raw ..\pngsuite\basn2c08.png rawn2c08.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\basn3p02.png rawn3p02.ppm
|
||||
png2pnm.exe -raw ..\pngsuite\basn3p04.png rawn3p04.ppm
|
||||
@@ -8,7 +8,7 @@
|
||||
# -- full-color
|
||||
./png2pnm -noraw ../pngsuite/basn2c08.png basn2c08.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn2c16.png basn2c16.ppm
|
||||
# -- palletted
|
||||
# -- paletted
|
||||
./png2pnm -noraw ../pngsuite/basn3p01.png basn3p01.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn3p02.png basn3p02.ppm
|
||||
./png2pnm -noraw ../pngsuite/basn3p04.png basn3p04.ppm
|
||||
@@ -28,7 +28,7 @@
|
||||
# -- full-color
|
||||
./png2pnm -raw ../pngsuite/basn2c08.png rawn2c08.ppm
|
||||
./png2pnm -raw ../pngsuite/basn2c16.png rawn2c16.ppm
|
||||
# -- palletted
|
||||
# -- paletted
|
||||
./png2pnm -raw ../pngsuite/basn3p01.png rawn3p01.ppm
|
||||
./png2pnm -raw ../pngsuite/basn3p02.png rawn3p02.ppm
|
||||
./png2pnm -raw ../pngsuite/basn3p04.png rawn3p04.ppm
|
||||
@@ -1,4 +1,4 @@
|
||||
make -f makefile.tc3
|
||||
make
|
||||
call png2pnm.bat
|
||||
call pnm2png.bat
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
make -f makefile.std
|
||||
make
|
||||
sh png2pnm.sh
|
||||
sh pnm2png.sh
|
||||
|
||||
4
contrib/pngminus/pnm2png.bat → contrib/pngminus/test_pnm2png.bat
Executable file → Normal file
4
contrib/pngminus/pnm2png.bat → contrib/pngminus/test_pnm2png.bat
Executable file → Normal file
@@ -7,7 +7,7 @@ pnm2png.exe basn0g16.pgm basn0g16.png
|
||||
REM -- full-color
|
||||
pnm2png.exe basn2c08.ppm basn2c08.png
|
||||
pnm2png.exe basn2c16.ppm basn2c16.png
|
||||
REM -- palletted
|
||||
REM -- paletted
|
||||
pnm2png.exe basn3p01.ppm basn3p01.png
|
||||
pnm2png.exe basn3p02.ppm basn3p02.png
|
||||
pnm2png.exe basn3p04.ppm basn3p04.png
|
||||
@@ -27,7 +27,7 @@ pnm2png.exe rawn0g16.pgm rawn0g16.png
|
||||
REM -- full-color
|
||||
pnm2png.exe rawn2c08.ppm rawn2c08.png
|
||||
pnm2png.exe rawn2c16.ppm rawn2c16.png
|
||||
REM -- palletted
|
||||
REM -- paletted
|
||||
pnm2png.exe rawn3p01.ppm rawn3p01.png
|
||||
pnm2png.exe rawn3p02.ppm rawn3p02.png
|
||||
pnm2png.exe rawn3p04.ppm rawn3p04.png
|
||||
@@ -8,7 +8,7 @@
|
||||
# -- full-color
|
||||
./pnm2png basn2c08.ppm basn2c08.png
|
||||
./pnm2png basn2c16.ppm basn2c16.png
|
||||
# -- palletted
|
||||
# -- paletted
|
||||
./pnm2png basn3p01.ppm basn3p01.png
|
||||
./pnm2png basn3p02.ppm basn3p02.png
|
||||
./pnm2png basn3p04.ppm basn3p04.png
|
||||
@@ -28,7 +28,7 @@
|
||||
# -- full-color
|
||||
./pnm2png rawn2c08.ppm rawn2c08.png
|
||||
./pnm2png rawn2c16.ppm rawn2c16.png
|
||||
# -- palletted
|
||||
# -- paletted
|
||||
./pnm2png rawn3p01.ppm rawn3p01.png
|
||||
./pnm2png rawn3p02.ppm rawn3p02.png
|
||||
./pnm2png rawn3p04.ppm rawn3p04.png
|
||||
@@ -16,6 +16,8 @@ chunks, etc.
|
||||
The "ft*.png" images are "free/libre" replacements for the transparent
|
||||
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:
|
||||
grayscale (1-16 bit deep), full color (8 or 16 bit), paletted
|
||||
(1-8 bit) and grayscale or color images with alpha channel. You
|
||||
|
||||
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 |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user