Compare commits
2109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d23e3fc586 | ||
|
|
f1d512de2f | ||
|
|
751ce7d9f3 | ||
|
|
ffea183e55 | ||
|
|
3fed7e016b | ||
|
|
8fb32c0a39 | ||
|
|
b3e739028a | ||
|
|
ae87a95861 | ||
|
|
b443c541b9 | ||
|
|
cf483eee49 | ||
|
|
3de15e0c34 | ||
|
|
a2291b252d | ||
|
|
a36deef563 | ||
|
|
6d95c51adf | ||
|
|
5ea5482872 | ||
|
|
8cc1277b69 | ||
|
|
ecf5f9a96a | ||
|
|
035262a18d | ||
|
|
ed7cab47d9 | ||
|
|
42d679b9fc | ||
|
|
044c22e12f | ||
|
|
1d2320994d | ||
|
|
70327296e2 | ||
|
|
f81833aed6 | ||
|
|
00607ec260 | ||
|
|
fdf8903354 | ||
|
|
166e34213e | ||
|
|
6367924ac6 | ||
|
|
29f718ee63 | ||
|
|
fe50cd9978 | ||
|
|
b542e4c8e9 | ||
|
|
52291467e1 | ||
|
|
c76f4a0826 | ||
|
|
c0b16e3d2b | ||
|
|
6cedf37c83 | ||
|
|
bd20344b0a | ||
|
|
c30b1e72da | ||
|
|
622c462e48 | ||
|
|
410c028f33 | ||
|
|
cf54623b08 | ||
|
|
ac59b2c582 | ||
|
|
6902cdb177 | ||
|
|
55de97207d | ||
|
|
708f013f89 | ||
|
|
163f0b1965 | ||
|
|
3a32d199df | ||
|
|
9a51a87af3 | ||
|
|
74aeaddf8e | ||
|
|
ab6c4a5db1 | ||
|
|
ec4cacc16e | ||
|
|
5db6a6819d | ||
|
|
f448279b14 | ||
|
|
ded5a504b4 | ||
|
|
c0d0fe86d8 | ||
|
|
a81a8c137b | ||
|
|
02f7bcdbd1 | ||
|
|
bbb7550709 | ||
|
|
5ced1f590b | ||
|
|
b98ee19241 | ||
|
|
ad8330af72 | ||
|
|
b25adabcfa | ||
|
|
875e873f26 | ||
|
|
2a9e3bd743 | ||
|
|
f37b7c1f96 | ||
|
|
509c2680aa | ||
|
|
d48cfe591f | ||
|
|
68564c0f9e | ||
|
|
ec5adb83dd | ||
|
|
de4cbb5c21 | ||
|
|
c8e52741fd | ||
|
|
72473266b8 | ||
|
|
a5ad46b9f8 | ||
|
|
6399d0a699 | ||
|
|
aa9db61677 | ||
|
|
2b05d47bc2 | ||
|
|
7bc9fca430 | ||
|
|
bb16b94455 | ||
|
|
33011754e6 | ||
|
|
bce58f487e | ||
|
|
ce067a6cd1 | ||
|
|
d3a3a73f64 | ||
|
|
58a3975e93 | ||
|
|
351d5d08fa | ||
|
|
426de82d0c | ||
|
|
5857929f95 | ||
|
|
709477274e | ||
|
|
1af712c101 | ||
|
|
ec90cd0f90 | ||
|
|
ce76ffac4c | ||
|
|
500b5ecec3 | ||
|
|
87ab3360d0 | ||
|
|
b46af82cc1 | ||
|
|
a4aa30d9a0 | ||
|
|
0d7818d1b6 | ||
|
|
4b67db4d9b | ||
|
|
f70a7e1ee1 | ||
|
|
f27167f20c | ||
|
|
6a8421fb44 | ||
|
|
031e16ecff | ||
|
|
75be88cfbd | ||
|
|
e2442e0707 | ||
|
|
1c2d3cfaaf | ||
|
|
2d0b675adf | ||
|
|
a214094b37 | ||
|
|
83fcf7b9e9 | ||
|
|
8a885c5443 | ||
|
|
ae5c15eb59 | ||
|
|
90e2d7f3fd | ||
|
|
5308c1a03b | ||
|
|
ce90ab5d44 | ||
|
|
1ee87a9e2e | ||
|
|
479501b07c | ||
|
|
9bc8eb6449 | ||
|
|
0fa5ae6b54 | ||
|
|
1ff90822f1 | ||
|
|
f8cca819a4 | ||
|
|
beefb62a6f | ||
|
|
3d9c64e9f8 | ||
|
|
23e8e0ff83 | ||
|
|
c868e41b22 | ||
|
|
0696b0a451 | ||
|
|
254909fab5 | ||
|
|
aa829dcf50 | ||
|
|
fbef50bc8b | ||
|
|
43ce78e032 | ||
|
|
add6158e96 | ||
|
|
65aaecd2d5 | ||
|
|
cfb7138523 | ||
|
|
bb3d325624 | ||
|
|
c701014dce | ||
|
|
950580eb0c | ||
|
|
8217fd5478 | ||
|
|
103c6c3276 | ||
|
|
2b1c9c6887 | ||
|
|
07e304c3bf | ||
|
|
5ea77d8b77 | ||
|
|
9a1d32095b | ||
|
|
17ed160078 | ||
|
|
504a295cde | ||
|
|
d00d7d8c19 | ||
|
|
aaffc14f65 | ||
|
|
d5f281b734 | ||
|
|
f2729c983a | ||
|
|
c1f07a9fc4 | ||
|
|
4f943644e5 | ||
|
|
3bef88f6ec | ||
|
|
2260b66e16 | ||
|
|
a861cc2f31 | ||
|
|
5c064c6ba5 | ||
|
|
9454cd365a | ||
|
|
43c58ff983 | ||
|
|
86a9bd1b08 | ||
|
|
a4a721fce5 | ||
|
|
574f3a772c | ||
|
|
ad6c316146 | ||
|
|
8d95be3afb | ||
|
|
a62895265f | ||
|
|
9ab569e616 | ||
|
|
9c78a04df4 | ||
|
|
0fa7850aeb | ||
|
|
0c8eb5b4dd | ||
|
|
84893085cf | ||
|
|
f4b8a5cf03 | ||
|
|
6d8caa9f88 | ||
|
|
398c1e9acc | ||
|
|
26f109290d | ||
|
|
43e84cff1b | ||
|
|
696e754ecf | ||
|
|
909a8cfc7b | ||
|
|
7678cba140 | ||
|
|
3820eb1e2d | ||
|
|
d23bf13189 | ||
|
|
f7aeafaf00 | ||
|
|
fce0382181 | ||
|
|
3041cf67ff | ||
|
|
1a85fc497d | ||
|
|
eb8bba627f | ||
|
|
53bb941845 | ||
|
|
2401e4d10c | ||
|
|
34e9d7e340 | ||
|
|
dc9bdf143a | ||
|
|
b2d000e64b | ||
|
|
bfc3ce3157 | ||
|
|
269e84c971 | ||
|
|
b628d6934f | ||
|
|
450306a84b | ||
|
|
ed3c527386 | ||
|
|
4a275cf080 | ||
|
|
13e4803e6a | ||
|
|
a74655af45 | ||
|
|
58cb10ee5f | ||
|
|
7b3c0f0109 | ||
|
|
72964b8633 | ||
|
|
3270768736 | ||
|
|
51f94caba1 | ||
|
|
9a12cf7ab5 | ||
|
|
b85de60a9f | ||
|
|
e73ee60a8f | ||
|
|
f918646f9a | ||
|
|
365bc1ce11 | ||
|
|
836e711c38 | ||
|
|
f154ccc091 | ||
|
|
9be7a47841 | ||
|
|
4d77515bc9 | ||
|
|
fb27709ab1 | ||
|
|
a9bfef2a57 | ||
|
|
12909e6a0f | ||
|
|
60a61a34fc | ||
|
|
216ccd6702 | ||
|
|
88e99ac246 | ||
|
|
78e3171864 | ||
|
|
72d249b89c | ||
|
|
075a1e1afc | ||
|
|
2dd5ae7b83 | ||
|
|
e95be67503 | ||
|
|
ec4255bb74 | ||
|
|
cfff992fc6 | ||
|
|
31d957d25a | ||
|
|
41dd774c1f | ||
|
|
1374cdfabe | ||
|
|
3a86fa5b22 | ||
|
|
499bd1da89 | ||
|
|
527477ae43 | ||
|
|
3b1b5646d4 | ||
|
|
cd81708ba9 | ||
|
|
f5c596e8f2 | ||
|
|
6ee36adc4e | ||
|
|
24d2c9de3d | ||
|
|
4b8d1ee39e | ||
|
|
fb16334315 | ||
|
|
5ff20ca303 | ||
|
|
dbbf6185a9 | ||
|
|
e4e091a184 | ||
|
|
730f65fd4a | ||
|
|
5e01695e2d | ||
|
|
a53303b82e | ||
|
|
8f21330ed5 | ||
|
|
ec333d5bbd | ||
|
|
4d8f239872 | ||
|
|
667fb53e3f | ||
|
|
a22ab9f3df | ||
|
|
1a830d52a4 | ||
|
|
c5a46f7e9f | ||
|
|
d8d5f06dd9 | ||
|
|
93060bf32e | ||
|
|
d5e22710be | ||
|
|
2d06b326b6 | ||
|
|
fd825574d1 | ||
|
|
0f87064d26 | ||
|
|
0fb7725000 | ||
|
|
a8af72437e | ||
|
|
d0fc58eb15 | ||
|
|
b3954883af | ||
|
|
5198654f73 | ||
|
|
f24385c465 | ||
|
|
a19f3a9c7a | ||
|
|
c15c2d88ef | ||
|
|
63ba814364 | ||
|
|
83649cc19b | ||
|
|
ed600dbb53 | ||
|
|
0d2908a62b | ||
|
|
ee39375c85 | ||
|
|
50d4088439 | ||
|
|
7e8ed0d448 | ||
|
|
5698542e24 | ||
|
|
6c1538470f | ||
|
|
e080e5d90b | ||
|
|
6b05623682 | ||
|
|
c716918d0a | ||
|
|
619c20d5e8 | ||
|
|
f8a5b80cb0 | ||
|
|
cc11b90b22 | ||
|
|
48dde8baf1 | ||
|
|
0629d2a00d | ||
|
|
32ba839c57 | ||
|
|
1da5cf4251 | ||
|
|
54e17215e6 | ||
|
|
4e67edff34 | ||
|
|
cdd9ffb65b | ||
|
|
39c8b666f9 | ||
|
|
fbf0a5fbc5 | ||
|
|
da75d56d6c | ||
|
|
02939f53a0 | ||
|
|
39b950076a | ||
|
|
c0f5e0b702 | ||
|
|
f5f176dd5d | ||
|
|
2c814300b5 | ||
|
|
4966e1eec5 | ||
|
|
67753d1298 | ||
|
|
f446e5d5c7 | ||
|
|
0c8bf27a3c | ||
|
|
5fc2839d45 | ||
|
|
701768b9c2 | ||
|
|
7a2bb989f2 | ||
|
|
a614b4af9f | ||
|
|
00eb5cdeab | ||
|
|
dc42b5460e | ||
|
|
ec86e2a9ad | ||
|
|
999ba67714 | ||
|
|
4d1d6adfaa | ||
|
|
0aea1da9f0 | ||
|
|
dde3b9e4be | ||
|
|
85e2e0f9c2 | ||
|
|
f2ec34de52 | ||
|
|
5e8fd24131 | ||
|
|
daab3e4ec4 | ||
|
|
71441f322e | ||
|
|
aa20343efd | ||
|
|
7faa703ebf | ||
|
|
e4189accd3 | ||
|
|
5ba6c7effb | ||
|
|
bf506e11b7 | ||
|
|
cdb6c34e1c | ||
|
|
576eef0509 | ||
|
|
f654cf0e2c | ||
|
|
70d831dc0d | ||
|
|
510e67c542 | ||
|
|
243aba148e | ||
|
|
2a4e7f1bc3 | ||
|
|
6a244cb514 | ||
|
|
2ee9faef10 | ||
|
|
a07787f423 | ||
|
|
ace9d06b9e | ||
|
|
752ee33e86 | ||
|
|
d44ffd9db0 | ||
|
|
598cd994f3 | ||
|
|
fa628eff6a | ||
|
|
933289f509 | ||
|
|
888d4075ee | ||
|
|
4802ddd7f7 | ||
|
|
9d8efde83b | ||
|
|
ddd54ff8a8 | ||
|
|
8a178239bd | ||
|
|
6c08ceb2ef | ||
|
|
0d435698f4 | ||
|
|
63c1674ebc | ||
|
|
864600d707 | ||
|
|
4ac7101056 | ||
|
|
4efb529bb7 | ||
|
|
f8e8039204 | ||
|
|
aa805bc89f | ||
|
|
81a64020e3 | ||
|
|
1fd5232cb6 | ||
|
|
9af41ac451 | ||
|
|
ed363b90ec | ||
|
|
6b4fa1bba7 | ||
|
|
376fac2dc8 | ||
|
|
a05011ddbc | ||
|
|
a546be5141 | ||
|
|
b4ecf9c867 | ||
|
|
75ca8cf867 | ||
|
|
c7dadd2d0b | ||
|
|
7475e59637 | ||
|
|
25e40dc42c | ||
|
|
296c8bad7e | ||
|
|
8b7ffebe42 | ||
|
|
a6b1bda094 | ||
|
|
a06aeb25f2 | ||
|
|
fa01dcb519 | ||
|
|
166aa51f5f | ||
|
|
37d08441ab | ||
|
|
6b99f99b88 | ||
|
|
3bc0839d7f | ||
|
|
7432a53e2b | ||
|
|
f645002fb6 | ||
|
|
0123dd2472 | ||
|
|
668bb847d5 | ||
|
|
3e2cf6909c | ||
|
|
f8dd3830eb | ||
|
|
c51334f4d0 | ||
|
|
da6b7c2ede | ||
|
|
779f5622aa | ||
|
|
6d172465cc | ||
|
|
fa6d5a29da | ||
|
|
79929eae12 | ||
|
|
ef62d51374 | ||
|
|
2c19e8cb79 | ||
|
|
00ace7679a | ||
|
|
775862809b | ||
|
|
0cbef40560 | ||
|
|
aed7d4661e | ||
|
|
bbaa3afe23 | ||
|
|
727fbf0183 | ||
|
|
41d4acba88 | ||
|
|
413ac73d98 | ||
|
|
faa4c44453 | ||
|
|
5dae26de7c | ||
|
|
2a41c84487 | ||
|
|
675ad04262 | ||
|
|
30ef0977be | ||
|
|
de852420c0 | ||
|
|
f854e668e6 | ||
|
|
c1afc7921d | ||
|
|
86496e9b58 | ||
|
|
c5c47edfd2 | ||
|
|
9fb04f5945 | ||
|
|
a9cad80d19 | ||
|
|
1d3037ebe1 | ||
|
|
3d30031772 | ||
|
|
f03d5df238 | ||
|
|
f20cba1bb0 | ||
|
|
0e9c14e1bb | ||
|
|
b7178cee71 | ||
|
|
63645d9161 | ||
|
|
602f5bea74 | ||
|
|
10c3e5d44e | ||
|
|
ea3df2f662 | ||
|
|
f46c7875dd | ||
|
|
9cb270a216 | ||
|
|
d1e39740b2 | ||
|
|
24ad6a0179 | ||
|
|
e6dd72874e | ||
|
|
c77eb27cb1 | ||
|
|
60ba1963fe | ||
|
|
7139f6c961 | ||
|
|
f7067a9e73 | ||
|
|
445d9b4196 | ||
|
|
f3db724c2d | ||
|
|
a8e56d39e5 | ||
|
|
1c5a481dfa | ||
|
|
3554fdb9cf | ||
|
|
da5d474c11 | ||
|
|
e3ce6852a6 | ||
|
|
3c85fc4bb1 | ||
|
|
017339f715 | ||
|
|
63eb69de62 | ||
|
|
ebc7c3a760 | ||
|
|
5f1960f38c | ||
|
|
6b236241d2 | ||
|
|
4618c247df | ||
|
|
7e27264523 | ||
|
|
644fbcef01 | ||
|
|
90f94c9ec8 | ||
|
|
29165500c9 | ||
|
|
db2986c96f | ||
|
|
7b008bdf12 | ||
|
|
8a12b6a6a0 | ||
|
|
02fc068dc8 | ||
|
|
c42b9ca3ef | ||
|
|
338ac421d7 | ||
|
|
86d57c6787 | ||
|
|
1083a3bffb | ||
|
|
e581ede148 | ||
|
|
36b2fecd0c | ||
|
|
83d6a8e643 | ||
|
|
9de0e03f2f | ||
|
|
873b390172 | ||
|
|
6948e6c2bf | ||
|
|
d81d671d36 | ||
|
|
7434b5eb2f | ||
|
|
bf061b4a1c | ||
|
|
d0755fa501 | ||
|
|
c88ce1aa16 | ||
|
|
c629ccd7d9 | ||
|
|
41ebea736d | ||
|
|
2db4ee73ff | ||
|
|
bda865e181 | ||
|
|
a914cb2d9f | ||
|
|
9f785697e4 | ||
|
|
662bf6ba7b | ||
|
|
a7eb278df1 | ||
|
|
71539b3e13 | ||
|
|
564022ebda | ||
|
|
f9d1fcdf6f | ||
|
|
5d2d1d4c47 | ||
|
|
bdbb0138b9 | ||
|
|
78c2093bd4 | ||
|
|
a2cc95b827 | ||
|
|
7129fc6299 | ||
|
|
a97939ec77 | ||
|
|
16db1b3f76 | ||
|
|
fdbbf10e90 | ||
|
|
ecb17510f0 | ||
|
|
bc649a29c0 | ||
|
|
33a9675dd3 | ||
|
|
82d2050470 | ||
|
|
a4d5a6bb1c | ||
|
|
7cd94b7ef9 | ||
|
|
730ddfba3d | ||
|
|
3f97ede419 | ||
|
|
12513c1340 | ||
|
|
ba88b106d5 | ||
|
|
11ceef67d5 | ||
|
|
2ef1bec37f | ||
|
|
e9ea853284 | ||
|
|
a1cea09935 | ||
|
|
efeca65349 | ||
|
|
c0756e6119 | ||
|
|
8b9eb07a36 | ||
|
|
2a21ae7463 | ||
|
|
cd1bee49e1 | ||
|
|
df3ace7e9c | ||
|
|
33a4b3d400 | ||
|
|
c8b99a298e | ||
|
|
fe0750f0d2 | ||
|
|
82070439ab | ||
|
|
a92d31df00 | ||
|
|
1dbceb51c9 | ||
|
|
b052d67eb1 | ||
|
|
d166012ae3 | ||
|
|
578c3f67d7 | ||
|
|
7ff92d811b | ||
|
|
3eed295c43 | ||
|
|
d0d81e9c3a | ||
|
|
19a5f802bc | ||
|
|
7930a77eaa | ||
|
|
00696236df | ||
|
|
29875d2597 | ||
|
|
2d055dc7c7 | ||
|
|
810aa1f188 | ||
|
|
50a3df621e | ||
|
|
d0b65844c2 | ||
|
|
ea0f2c2811 | ||
|
|
5c5de61c13 | ||
|
|
04962caf3a | ||
|
|
004427c071 | ||
|
|
83052612d0 | ||
|
|
c079546d32 | ||
|
|
2bbe593b31 | ||
|
|
328e088030 | ||
|
|
c62f3f40be | ||
|
|
d37548299f | ||
|
|
cdeb7db034 | ||
|
|
d66dc1084c | ||
|
|
ebfee8203a | ||
|
|
0a8555ea59 | ||
|
|
4dec5210ef | ||
|
|
ae9446b98f | ||
|
|
bc4d369b49 | ||
|
|
334b1963f7 | ||
|
|
d4a32f71d4 | ||
|
|
f63d1609dc | ||
|
|
0e5f88dbe1 | ||
|
|
c4ac1e2b15 | ||
|
|
6bce2c22c7 | ||
|
|
4d117e06bc | ||
|
|
bbe6136281 | ||
|
|
9c318c0884 | ||
|
|
7c0efc8589 | ||
|
|
25651f6eb5 | ||
|
|
f4543c7379 | ||
|
|
dfe0538662 | ||
|
|
ce6f3d8cd2 | ||
|
|
3d037a5c72 | ||
|
|
5f27ff790b | ||
|
|
d3c8cde986 | ||
|
|
804440b2e1 | ||
|
|
ef5d1ea229 | ||
|
|
150b5c4a90 | ||
|
|
a86aee5113 | ||
|
|
f79cc2214e | ||
|
|
608dfddd22 | ||
|
|
948d9d0492 | ||
|
|
370aaa61fd | ||
|
|
f58a0d4174 | ||
|
|
870d4403eb | ||
|
|
e9897e4200 | ||
|
|
ba67ec6270 | ||
|
|
0c28bca095 | ||
|
|
b83bfa68a9 | ||
|
|
efd7674c11 | ||
|
|
7def1fcf5b | ||
|
|
c6262663b5 | ||
|
|
91c739f541 | ||
|
|
aac7f6575a | ||
|
|
fc76d48701 | ||
|
|
df9b78ab5c | ||
|
|
2e08021a9f | ||
|
|
ad67be3b36 | ||
|
|
b94560c4a8 | ||
|
|
873a32e8d0 | ||
|
|
e9ccb2ff22 | ||
|
|
4209d3496d | ||
|
|
6ab56c195e | ||
|
|
2e7c6109ff | ||
|
|
b2092f33c3 | ||
|
|
c87576eb09 | ||
|
|
fbff4b9500 | ||
|
|
d3a58a33cd | ||
|
|
05a5f4a9cc | ||
|
|
4db50792eb | ||
|
|
8c2c415847 | ||
|
|
1475ca8fe2 | ||
|
|
f7b5dd1e41 | ||
|
|
5b9d498fa0 | ||
|
|
ab62cf7ba5 | ||
|
|
257745ba05 | ||
|
|
22505838cb | ||
|
|
66f830135f | ||
|
|
11fe81d0df | ||
|
|
ed028a6575 | ||
|
|
63c66d2131 | ||
|
|
0b8d990cef | ||
|
|
0b58a07f5e | ||
|
|
108f603748 | ||
|
|
ceb4712807 | ||
|
|
6304683a66 | ||
|
|
3c50582e77 | ||
|
|
6ca1aab2f7 | ||
|
|
b7efc273a0 | ||
|
|
f493ae8ff3 | ||
|
|
39bd663c71 | ||
|
|
1dc81a3bae | ||
|
|
3a379eda44 | ||
|
|
5f434e6053 | ||
|
|
d11fc3c7c8 | ||
|
|
7464e5fe76 | ||
|
|
33f39a2818 | ||
|
|
049e5c80b9 | ||
|
|
594b7258cc | ||
|
|
0533b31891 | ||
|
|
cca53c920d | ||
|
|
5901802871 | ||
|
|
fbef31f76d | ||
|
|
1aa50b71d9 | ||
|
|
3adc64a4cb | ||
|
|
ccb1d12f53 | ||
|
|
82b8751482 | ||
|
|
838e00fd54 | ||
|
|
c73a82c6aa | ||
|
|
b9f25333f6 | ||
|
|
0f6b96c68e | ||
|
|
eeea9ed397 | ||
|
|
b95528727f | ||
|
|
d9605b0560 | ||
|
|
40e6e8b2a2 | ||
|
|
514307e9e6 | ||
|
|
7388a54647 | ||
|
|
e1abc9a7ac | ||
|
|
24aeccff3e | ||
|
|
0409942a02 | ||
|
|
e7a135b930 | ||
|
|
62300280b5 | ||
|
|
55e3e7e819 | ||
|
|
0c59a4daf6 | ||
|
|
d47fa82ae8 | ||
|
|
c3b7375ad8 | ||
|
|
e2f5c7cab3 | ||
|
|
001189cb7a | ||
|
|
24899de84c | ||
|
|
8d4544b7bc | ||
|
|
60fe8fe525 | ||
|
|
fc742e8e19 | ||
|
|
e3d3cc073d | ||
|
|
4272eec761 | ||
|
|
b8c8ef9851 | ||
|
|
a9356f18b4 | ||
|
|
5dc78b3681 | ||
|
|
66bf3abec7 | ||
|
|
b8f2b72acb | ||
|
|
0175589d46 | ||
|
|
12c8d0c891 | ||
|
|
7e6f1ee2d4 | ||
|
|
4bd97823d3 | ||
|
|
360ffd4441 | ||
|
|
9b1ca0816c | ||
|
|
76ef3c5dda | ||
|
|
0045d0072b | ||
|
|
6263c1fc1b | ||
|
|
7bd7012c98 | ||
|
|
ecfbabdbf3 | ||
|
|
3c9850814b | ||
|
|
46611eb0ee | ||
|
|
66245aa735 | ||
|
|
144e7b79e4 | ||
|
|
5ad13790c2 | ||
|
|
814fb56282 | ||
|
|
9f6bb55f67 | ||
|
|
44e609fa3a | ||
|
|
e383334c0a | ||
|
|
7ad4962b66 | ||
|
|
535b1ee3ef | ||
|
|
e170b61137 | ||
|
|
f8301c92dd | ||
|
|
1aa56251a9 | ||
|
|
2c0b793539 | ||
|
|
3854b5ef59 | ||
|
|
ef025d6c8c | ||
|
|
5d5b9a497b | ||
|
|
b284a473f7 | ||
|
|
99de998e2c | ||
|
|
51b63d0931 | ||
|
|
b70fe7221e | ||
|
|
f33b56330d | ||
|
|
a37736dd43 | ||
|
|
ccee85d6e2 | ||
|
|
c4c3ac6305 | ||
|
|
f069238be3 | ||
|
|
f66c307c2e | ||
|
|
e7a9390725 | ||
|
|
147ae6f24c | ||
|
|
4464a39363 | ||
|
|
38bfd451d5 | ||
|
|
b530bd1f33 | ||
|
|
0297e2a61d | ||
|
|
486d2a028a | ||
|
|
cfbb147aad | ||
|
|
295df8bdad | ||
|
|
e99d135774 | ||
|
|
461283574a | ||
|
|
646859004f | ||
|
|
f413bb5fb7 | ||
|
|
df3ff573cc | ||
|
|
a72597b837 | ||
|
|
1d434bfdc9 | ||
|
|
64c1c3b7ec | ||
|
|
c55d3622c8 | ||
|
|
8b11360a8b | ||
|
|
7f3a5c18e6 | ||
|
|
e7fe0653e5 | ||
|
|
eb590a6e25 | ||
|
|
6b48fbd229 | ||
|
|
311f16e848 | ||
|
|
ea4fad9aec | ||
|
|
4b1094cc3a | ||
|
|
84f9fbfe3e | ||
|
|
3b85b4e1bd | ||
|
|
1bd801a872 | ||
|
|
4528256c56 | ||
|
|
3f1e5d6842 | ||
|
|
93da07241d | ||
|
|
6af3f00efa | ||
|
|
eeace92a35 | ||
|
|
0d25e86574 | ||
|
|
b7a30f1186 | ||
|
|
e45363d7c2 | ||
|
|
16d7eeb944 | ||
|
|
87254c1c44 | ||
|
|
ef1c66701a | ||
|
|
9a4231edfe | ||
|
|
a5195816f6 | ||
|
|
13e2115054 | ||
|
|
8a99fcac80 | ||
|
|
061d42c272 | ||
|
|
d236890325 | ||
|
|
c8e03dbda5 | ||
|
|
f017a5de0f | ||
|
|
ffcbd29084 | ||
|
|
e77bd79dc2 | ||
|
|
b9e50a2b57 | ||
|
|
943adfb1fe | ||
|
|
8a13ae9f25 | ||
|
|
67972b4ea0 | ||
|
|
43e9cee4b2 | ||
|
|
3f4fb1a62d | ||
|
|
59326a1491 | ||
|
|
3b78447867 | ||
|
|
8a1f94b7b8 | ||
|
|
7824f70008 | ||
|
|
fbde10ef57 | ||
|
|
361192b972 | ||
|
|
4ed09b89cf | ||
|
|
1c6030799d | ||
|
|
c0e5229b23 | ||
|
|
6fc85ff960 | ||
|
|
063d3128a8 | ||
|
|
8b8d88c850 | ||
|
|
a5403fda93 | ||
|
|
c88aade31c | ||
|
|
101df25fde | ||
|
|
21b2f11a42 | ||
|
|
cd3c32f15d | ||
|
|
87d506416f | ||
|
|
b03b5797f4 | ||
|
|
e5f8575776 | ||
|
|
b36bec4d71 | ||
|
|
62003f9ae5 | ||
|
|
7d7e24c60a | ||
|
|
b4c7d90b3f | ||
|
|
e4fa772b58 | ||
|
|
2086f28340 | ||
|
|
f317d8fe84 | ||
|
|
a0908f87a5 | ||
|
|
fda32bfb93 | ||
|
|
4c778664d0 | ||
|
|
fc6c8738e3 | ||
|
|
2732926d8d | ||
|
|
fc42227f55 | ||
|
|
dec1abe515 | ||
|
|
8c1d7c702e | ||
|
|
6f7100360e | ||
|
|
18f4486b9a | ||
|
|
4326901a92 | ||
|
|
faac204f30 | ||
|
|
944cf32d5a | ||
|
|
473bc8edfc | ||
|
|
682c2b69f9 | ||
|
|
52076a7015 | ||
|
|
23a5f07202 | ||
|
|
2dc2bbde66 | ||
|
|
09d26479de | ||
|
|
548aeb977d | ||
|
|
b93b80b3aa | ||
|
|
706f2a8881 | ||
|
|
abffeb8390 | ||
|
|
bd845c8691 | ||
|
|
4e5e4787e4 | ||
|
|
100ed0a5f9 | ||
|
|
af64ac105f | ||
|
|
d895eac10e | ||
|
|
31bdb9940e | ||
|
|
2d27a01e6d | ||
|
|
378f4528ad | ||
|
|
abf87ed578 | ||
|
|
7c0f91e4e6 | ||
|
|
e223a7ee9e | ||
|
|
161abb182e | ||
|
|
8f4115dc8c | ||
|
|
2e3f284fa5 | ||
|
|
8c4107ca00 | ||
|
|
45c800e2d6 | ||
|
|
3fd6eec30b | ||
|
|
d273dc190c | ||
|
|
94d0aa2e4c | ||
|
|
2dac0fbd04 | ||
|
|
16cc1be7a6 | ||
|
|
9e74f518bd | ||
|
|
f8ee35809f | ||
|
|
222279a4f0 | ||
|
|
2f59b4eac1 | ||
|
|
5d4e113b06 | ||
|
|
8db334cde2 | ||
|
|
1733487e17 | ||
|
|
2012e32f19 | ||
|
|
f4c556031c | ||
|
|
553e2cb89e | ||
|
|
038cf66ab2 | ||
|
|
8acdd385cb | ||
|
|
a60728cb34 | ||
|
|
80ececa081 | ||
|
|
4d0329b235 | ||
|
|
199fffb759 | ||
|
|
1d50153e84 | ||
|
|
69c5bea97a | ||
|
|
0c7449c461 | ||
|
|
2906cbf6ed | ||
|
|
18edf4db70 | ||
|
|
5610bb1fec | ||
|
|
b190357c98 | ||
|
|
2de8e97989 | ||
|
|
6f168e4f80 | ||
|
|
86612bf441 | ||
|
|
66b9aeb4f3 | ||
|
|
3e8afe7f94 | ||
|
|
7b66e2fa25 | ||
|
|
758ed27a05 | ||
|
|
d200b2c144 | ||
|
|
af19664571 | ||
|
|
b30b918b0f | ||
|
|
aa411b107f | ||
|
|
0195c26b3b | ||
|
|
fdc2954e79 | ||
|
|
3b8d4263fc | ||
|
|
87768cc42c | ||
|
|
a3b8f11de4 | ||
|
|
166227c3c7 | ||
|
|
305e0f1541 | ||
|
|
1cf34093b9 | ||
|
|
30a62f472f | ||
|
|
f33798a34d | ||
|
|
d10edbc1ee | ||
|
|
6a9cbe75ed | ||
|
|
af49fce8d3 | ||
|
|
67599a5dc6 | ||
|
|
4862b64557 | ||
|
|
396e070825 | ||
|
|
ea070355f5 | ||
|
|
dd12a235c5 | ||
|
|
5dc419c6bc | ||
|
|
97ba4bac6d | ||
|
|
f5b95b3201 | ||
|
|
92c7ae8911 | ||
|
|
6e21536da0 | ||
|
|
fcb749d773 | ||
|
|
7bb4dbb81b | ||
|
|
2f79703e04 | ||
|
|
7b499d682e | ||
|
|
5d332e6447 | ||
|
|
c4f4d18352 | ||
|
|
74437c2c0d | ||
|
|
5e75573709 | ||
|
|
60b35b8714 | ||
|
|
5bfddde8fd | ||
|
|
3c2910bc94 | ||
|
|
57a9436cec | ||
|
|
b7d9250185 | ||
|
|
eee4d881c1 | ||
|
|
2d3974f117 | ||
|
|
821a20d0e8 | ||
|
|
9c37b59d48 | ||
|
|
a35cc3acf8 | ||
|
|
96f55a9797 | ||
|
|
9e9df11625 | ||
|
|
2b910d60be | ||
|
|
5c04be8c3d | ||
|
|
3f40a7b13d | ||
|
|
e1ed715c47 | ||
|
|
29c00b45fa | ||
|
|
985f8d3bf9 | ||
|
|
960ea8fb66 | ||
|
|
7db7c4b433 | ||
|
|
d56079bc7e | ||
|
|
336154ad7e | ||
|
|
80d2fe24c8 | ||
|
|
d657ebcc92 | ||
|
|
b0073a2851 | ||
|
|
9537c80920 | ||
|
|
68a89e0170 | ||
|
|
03d7b0bd81 | ||
|
|
5d4f2feeed | ||
|
|
c4264cd007 | ||
|
|
3aa498b9e1 | ||
|
|
f568823115 | ||
|
|
022952d37d | ||
|
|
1c510cf11a | ||
|
|
593bb84e41 | ||
|
|
ae6746cab2 | ||
|
|
8d2a67c7dd | ||
|
|
a4871a16c6 | ||
|
|
e59db4fad5 | ||
|
|
d12ca848a2 | ||
|
|
dbebf635b0 | ||
|
|
28383e8001 | ||
|
|
0a1775882f | ||
|
|
2ed7138390 | ||
|
|
eead7fe19b | ||
|
|
88ae091ca1 | ||
|
|
1728190717 | ||
|
|
009b6a50b5 | ||
|
|
f35c0b83c0 | ||
|
|
885da7cef9 | ||
|
|
efb347cf12 | ||
|
|
311e4b7cd1 | ||
|
|
030a805b5b | ||
|
|
395de92bd7 | ||
|
|
4bd85091a9 | ||
|
|
6832bc2615 | ||
|
|
7f0bceb586 | ||
|
|
7dc5d31417 | ||
|
|
05142f3fa8 | ||
|
|
e4552b8143 | ||
|
|
0c0d0bc5b1 | ||
|
|
624acb5168 | ||
|
|
42af7fbde1 | ||
|
|
581c75f44c | ||
|
|
1cdf41108b | ||
|
|
0d141f4844 | ||
|
|
adb33bb1a4 | ||
|
|
4a9b7184e6 | ||
|
|
8419f05afa | ||
|
|
c33bc1dab0 | ||
|
|
435f18d902 | ||
|
|
bb70930aa8 | ||
|
|
bac0f31e7c | ||
|
|
89e1e74994 | ||
|
|
b9b6a143b1 | ||
|
|
0c48e5367b | ||
|
|
897a525e3f | ||
|
|
61a2e1ed20 | ||
|
|
2409fb9d03 | ||
|
|
6bf156552e | ||
|
|
63c56225ff | ||
|
|
08b114849f | ||
|
|
89c9791c8e | ||
|
|
0a92189a38 | ||
|
|
7448ab4e82 | ||
|
|
febf3466d4 | ||
|
|
5523494348 | ||
|
|
3287e09390 | ||
|
|
c31dea2118 | ||
|
|
b861ef600c | ||
|
|
fa6e45a67f | ||
|
|
5c2f2cccb7 | ||
|
|
fc300f03f9 | ||
|
|
9961cd6aed | ||
|
|
9649c114e6 | ||
|
|
6500625c07 | ||
|
|
0eb9ce28ad | ||
|
|
4f40a52c8e | ||
|
|
16ecf16f90 | ||
|
|
0fe79b8083 | ||
|
|
c0aa2c01b7 | ||
|
|
b7e14cbaca | ||
|
|
b3106a1ec5 | ||
|
|
e8376f242d | ||
|
|
724d558ae3 | ||
|
|
005d7c52a7 | ||
|
|
4d98fc5d95 | ||
|
|
e9bbf66627 | ||
|
|
c3e2b3c933 | ||
|
|
60e6c633fa | ||
|
|
b6ddbefdd7 | ||
|
|
b346a5cc31 | ||
|
|
c92da453f3 | ||
|
|
8d0816e808 | ||
|
|
3d26a0a343 | ||
|
|
579d16b032 | ||
|
|
5ca1602f2f | ||
|
|
e64d7453e9 | ||
|
|
b9e72234e1 | ||
|
|
6762c622b3 | ||
|
|
618fb42ff1 | ||
|
|
3c4b32337a | ||
|
|
dff12f6b87 | ||
|
|
a4137a6c14 | ||
|
|
fa9569fcec | ||
|
|
09fde9eaf6 | ||
|
|
71f953d0be | ||
|
|
16c3cdb956 | ||
|
|
1d3533fea1 | ||
|
|
8e876747c8 | ||
|
|
52925cfff2 | ||
|
|
2a10cbaa27 | ||
|
|
9ba6976321 | ||
|
|
6ee8b5ce48 | ||
|
|
040c688263 | ||
|
|
c05b10176d | ||
|
|
d3d06f42c1 | ||
|
|
78dd697afb | ||
|
|
994b9819ac | ||
|
|
7d8ed9833e | ||
|
|
039b6c8041 | ||
|
|
72bad638c1 | ||
|
|
3d9105bb76 | ||
|
|
3317c65fb9 | ||
|
|
1f3d15a32d | ||
|
|
7544a924e3 | ||
|
|
bf417e56e0 | ||
|
|
f6903faab4 | ||
|
|
890f35098a | ||
|
|
08b4ed7490 | ||
|
|
1bb1e69186 | ||
|
|
786bb7f8c9 | ||
|
|
2935005850 | ||
|
|
abb6a513fa | ||
|
|
974aa1692a | ||
|
|
671fea53d1 | ||
|
|
1aeba2fe5f | ||
|
|
857564d019 | ||
|
|
07c0d68d9b | ||
|
|
cbe20c302e | ||
|
|
4f4d870822 | ||
|
|
55e240198d | ||
|
|
72b66f9c77 | ||
|
|
540789427c | ||
|
|
48706bff01 | ||
|
|
ac79e9b1ee | ||
|
|
023ebb66c4 | ||
|
|
3c8a31c9b5 | ||
|
|
c5aefc3659 | ||
|
|
d1e8d536c8 | ||
|
|
c85058008f | ||
|
|
12d34929ba | ||
|
|
dca89b0e4a | ||
|
|
97fbe04323 | ||
|
|
db6e007c44 | ||
|
|
ac10ce0c8c | ||
|
|
bff45dffc1 | ||
|
|
2d4ca5d710 | ||
|
|
69e08193f3 | ||
|
|
3b80b515fe | ||
|
|
cb2b0d6670 | ||
|
|
61298968fa | ||
|
|
04508b8c4c | ||
|
|
bd029eb0f7 | ||
|
|
fabf58ed48 | ||
|
|
b767b5e6bb | ||
|
|
7a0bc500e2 | ||
|
|
a7fa97cda5 | ||
|
|
a2c32ce513 | ||
|
|
98e6ffb50c | ||
|
|
cda9ea1e3b | ||
|
|
fca3a77590 | ||
|
|
ee1111ae8a | ||
|
|
2bdc88ba48 | ||
|
|
c18c6f9fd6 | ||
|
|
b3633e930b | ||
|
|
ad6e9649d5 | ||
|
|
8e4a07e20f | ||
|
|
db5b90b145 | ||
|
|
07eadec225 | ||
|
|
fbff05b11c | ||
|
|
a601602d61 | ||
|
|
7d49d6c6b0 | ||
|
|
811d68b21b | ||
|
|
20a53a6419 | ||
|
|
f3fb703909 | ||
|
|
2bf81e8eb7 | ||
|
|
d40310f531 | ||
|
|
c6c8c7911f | ||
|
|
3ea68ac65e | ||
|
|
3c6b1ba545 | ||
|
|
7b0d18f239 | ||
|
|
b4832c620f | ||
|
|
e6a43d1aa5 | ||
|
|
10138c9d35 | ||
|
|
838af42eaf | ||
|
|
6addfed58b | ||
|
|
d4d76b46c8 | ||
|
|
01f46504ee | ||
|
|
d820c88ab2 | ||
|
|
472ecea71e | ||
|
|
e2563adb2e | ||
|
|
c7e306f883 | ||
|
|
fa4e9b5926 | ||
|
|
33721ced53 | ||
|
|
3b0a4b86ac | ||
|
|
dc0f3c179e | ||
|
|
0ccc581b8c | ||
|
|
fbc4f5fdd4 | ||
|
|
198cc7c161 | ||
|
|
95257c488f | ||
|
|
f934fc621e | ||
|
|
e2da0467a6 | ||
|
|
154c2dc749 | ||
|
|
101197d2a2 | ||
|
|
afb8fce223 | ||
|
|
1c51826a70 | ||
|
|
ac5b9e8b78 | ||
|
|
8abacdbd4b | ||
|
|
159f02b3a9 | ||
|
|
7452d682ef | ||
|
|
0a90c5d778 | ||
|
|
20b1b0c547 | ||
|
|
4b7c15f709 | ||
|
|
1719c57186 | ||
|
|
73dae02512 | ||
|
|
792daa8548 | ||
|
|
4aa11c8bb4 | ||
|
|
aef8973ec7 | ||
|
|
36b5ca24d3 | ||
|
|
59aa40fa79 | ||
|
|
9f0b4a4bd3 | ||
|
|
54fffed01a | ||
|
|
11b9c8802c | ||
|
|
475ae72b0b | ||
|
|
87d6e984ff | ||
|
|
fa408f82d8 | ||
|
|
0213d619bf | ||
|
|
446d58f4de | ||
|
|
04a34ea5bf | ||
|
|
d60317df82 | ||
|
|
ae0631474a | ||
|
|
f368bcab26 | ||
|
|
ff3d754f29 | ||
|
|
81d02327c8 | ||
|
|
0fb3247f9a | ||
|
|
c0e571289a | ||
|
|
24668df1df | ||
|
|
ee1972febe | ||
|
|
9ad7a4c6ca | ||
|
|
f625bf7117 | ||
|
|
45b2cca4c0 | ||
|
|
7bd1cf2566 | ||
|
|
423b7d78f0 | ||
|
|
2296d513c1 | ||
|
|
af914fe8f6 | ||
|
|
5ca8bf8738 | ||
|
|
6f58a183fa | ||
|
|
6bcd8f8345 | ||
|
|
d5641a02e8 | ||
|
|
81082f5929 | ||
|
|
f4cdf5e8a2 | ||
|
|
633934f421 | ||
|
|
c25257c4ea | ||
|
|
b34b2ad711 | ||
|
|
e338413d35 | ||
|
|
ec61f52d87 | ||
|
|
39b9801063 | ||
|
|
3fab7e7a13 | ||
|
|
458a2dd64e | ||
|
|
ed8ca2cc6c | ||
|
|
73aed2c20a | ||
|
|
e99b408fe6 | ||
|
|
f5a6d63edc | ||
|
|
0442d164dc | ||
|
|
0437a8f335 | ||
|
|
75cbacff26 | ||
|
|
b05f1f177e | ||
|
|
aa5a1808fe | ||
|
|
c10837d8a8 | ||
|
|
3f2e3b11f0 | ||
|
|
b481543bc7 | ||
|
|
41e3657631 | ||
|
|
31087f88c7 | ||
|
|
64da9d6ba8 | ||
|
|
5c4338be32 | ||
|
|
9172810d28 | ||
|
|
6accd550fd | ||
|
|
4432f84185 | ||
|
|
fb7587dad3 | ||
|
|
7421f92041 | ||
|
|
df6799e3b8 | ||
|
|
9905afa24b | ||
|
|
22be928d5a | ||
|
|
a3dd57c615 | ||
|
|
6586b254ee | ||
|
|
d4b8d9c33b | ||
|
|
4986652604 | ||
|
|
cd5c8559d6 | ||
|
|
af57f6f5f9 | ||
|
|
48f620c4f0 | ||
|
|
ca4751d1df | ||
|
|
3e21a7a9b2 | ||
|
|
4fcdeb795d | ||
|
|
084c4c039a | ||
|
|
771fbdeb99 | ||
|
|
2d25f449a5 | ||
|
|
7858477652 | ||
|
|
52559c88b4 | ||
|
|
04b5b27bc8 | ||
|
|
7440604f2b | ||
|
|
bfa613b9a6 | ||
|
|
30822f98f7 | ||
|
|
aaa5ae742a | ||
|
|
207b31b1c5 | ||
|
|
08fcac01e6 | ||
|
|
2f83944e9b | ||
|
|
89f8671eb0 | ||
|
|
aba6c404c3 | ||
|
|
5bede571dd | ||
|
|
37915a690c | ||
|
|
bd096ba10d | ||
|
|
e280cc2afd | ||
|
|
da64629c62 | ||
|
|
cce0ccc931 | ||
|
|
02cb7b444e | ||
|
|
afa79bd62f | ||
|
|
6e84abb54e | ||
|
|
f0fe7e9603 | ||
|
|
c8a3df184e | ||
|
|
dcc68c41aa | ||
|
|
c39f2aa88f | ||
|
|
45b9c02bd7 | ||
|
|
94d6c1054f | ||
|
|
f64f027bae | ||
|
|
9431d5c677 | ||
|
|
99f9678f02 | ||
|
|
8e4bc5dfb0 | ||
|
|
048f264cb1 | ||
|
|
0803520704 | ||
|
|
3fc75a5734 | ||
|
|
61130e332a | ||
|
|
c436a02bb1 | ||
|
|
3d625746d4 | ||
|
|
4c0c6ffee0 | ||
|
|
b8614f5d9f | ||
|
|
9e646118bc | ||
|
|
931a4929bb | ||
|
|
2bf41d5534 | ||
|
|
2de2cf9e54 | ||
|
|
fb0ef0019b | ||
|
|
f42e2be51a | ||
|
|
073c49ed39 | ||
|
|
9f804a5590 | ||
|
|
fe52f5efa5 | ||
|
|
0af70afcea | ||
|
|
26ddbf432d | ||
|
|
22c11c2e20 | ||
|
|
52e26f6330 | ||
|
|
9d0c277115 | ||
|
|
4d9d01c146 | ||
|
|
c543f1b6f9 | ||
|
|
3a034760e0 | ||
|
|
5f55e384a9 | ||
|
|
9ec9d98b4b | ||
|
|
70d2cc0e04 | ||
|
|
8d0f7753c6 | ||
|
|
7f90cedc40 | ||
|
|
39ac1cfc79 | ||
|
|
be2b542bba | ||
|
|
adfac40859 | ||
|
|
22c2e01d7a | ||
|
|
82512e05b0 | ||
|
|
8b3e32bf48 | ||
|
|
3297fc34a0 | ||
|
|
1f63b8d9d1 | ||
|
|
2dd1c6ca8d | ||
|
|
0b818b4134 | ||
|
|
cd72e32e8c | ||
|
|
e160ae113f | ||
|
|
84aee73599 | ||
|
|
a0d29e0364 | ||
|
|
8e43940920 | ||
|
|
cc4145ce2f | ||
|
|
e94b3a80f2 | ||
|
|
9f8a003137 | ||
|
|
34be67477f | ||
|
|
fc9fec465f | ||
|
|
515fece330 | ||
|
|
3252455c3f | ||
|
|
4965fd0a7c | ||
|
|
a1c870d302 | ||
|
|
d67d122db0 | ||
|
|
81de93c8a5 | ||
|
|
a30a027128 | ||
|
|
f46db556e3 | ||
|
|
afb0dcf565 | ||
|
|
ba4a6c32f8 | ||
|
|
dc3556a0a1 | ||
|
|
6a9229ae96 | ||
|
|
0d605d57f4 | ||
|
|
8adaa68d4b | ||
|
|
6ae33e0848 | ||
|
|
670d50d910 | ||
|
|
096a63bc8e | ||
|
|
00113423f9 | ||
|
|
f59e5301a5 | ||
|
|
647786ee51 | ||
|
|
4b3e749f0f | ||
|
|
c4c137f5e9 | ||
|
|
d7201e7dbe | ||
|
|
eebb09941b | ||
|
|
a1d135912d | ||
|
|
fdaa047891 | ||
|
|
55a0e9175c | ||
|
|
ba01bcbbc5 | ||
|
|
71fb9568b9 | ||
|
|
1e7853c0cc | ||
|
|
ffdedb5963 | ||
|
|
af67ada048 | ||
|
|
9c3d4cec36 | ||
|
|
58c992a2ae | ||
|
|
c2328db52d | ||
|
|
cf55125611 | ||
|
|
2f54a1f3cb | ||
|
|
c27f55d6f9 | ||
|
|
59925ba3af | ||
|
|
b684672502 | ||
|
|
0428dc2cdc | ||
|
|
33fb70b328 | ||
|
|
9fe128871e | ||
|
|
ecc22a1007 | ||
|
|
b69f25841b | ||
|
|
5ae35d8a86 | ||
|
|
8ddd1ff301 | ||
|
|
6b041a9221 | ||
|
|
2b6cc565d2 | ||
|
|
13ac9e8554 | ||
|
|
2fbf7acccc | ||
|
|
5b620429e5 | ||
|
|
0f1f5f822b | ||
|
|
628b982497 | ||
|
|
b5beb92a92 | ||
|
|
41f0b53f18 | ||
|
|
16ff890de7 | ||
|
|
e14730f6cc | ||
|
|
383cd7265d | ||
|
|
674a037ec7 | ||
|
|
8e4f6724cb | ||
|
|
f914eb1111 | ||
|
|
b04e41592c | ||
|
|
7d12636291 | ||
|
|
19e408d256 | ||
|
|
f0f1ce1b7f | ||
|
|
83925d0427 | ||
|
|
ee4c7d28ab | ||
|
|
6e5eac3ea7 | ||
|
|
9c1aac4639 | ||
|
|
70796552c4 | ||
|
|
936ae5a813 | ||
|
|
ee67b71238 | ||
|
|
de30fe9460 | ||
|
|
2cb8ab383d | ||
|
|
6683a2411a | ||
|
|
8c5aa647d1 | ||
|
|
e456841c1c | ||
|
|
8be6348add | ||
|
|
1b9184db5b | ||
|
|
2610cd4d4a | ||
|
|
8f94c2b084 | ||
|
|
92dd17f4c7 | ||
|
|
70d3c1aeec | ||
|
|
e0c15701d4 | ||
|
|
a6c9eaf155 | ||
|
|
3f0ffbc4b7 | ||
|
|
f506e2cbb5 | ||
|
|
5553c54e26 | ||
|
|
05cd6e6ea0 | ||
|
|
d669ea731f | ||
|
|
0a9250c2c0 | ||
|
|
7b1c86c3bd | ||
|
|
019d51d4f1 | ||
|
|
3cde27c244 | ||
|
|
7b8366223a | ||
|
|
ce6c0e7ebd | ||
|
|
52ce04b193 | ||
|
|
b4e2548e6b | ||
|
|
b368b2f300 | ||
|
|
97e5be2e2e | ||
|
|
0651ee366b | ||
|
|
a8a481e690 | ||
|
|
791e9b4316 | ||
|
|
c394d503ae | ||
|
|
7702469e15 | ||
|
|
1379c92f87 | ||
|
|
c19ea22c80 | ||
|
|
94e873fe9e | ||
|
|
b03457663d | ||
|
|
8c5d7e518d | ||
|
|
448d12d298 | ||
|
|
bd4c4babbd | ||
|
|
8aab7a1dad | ||
|
|
1385e05209 | ||
|
|
ca423d39a3 | ||
|
|
835da9597c | ||
|
|
1086af6541 | ||
|
|
66f6b9b036 | ||
|
|
7e768e9849 | ||
|
|
e9081e7385 | ||
|
|
9d7101c8f6 | ||
|
|
7f52711afa | ||
|
|
c2dab98ea0 | ||
|
|
7cfbea858c | ||
|
|
c17aa549ab | ||
|
|
cfbf6426e7 | ||
|
|
c650f3c220 | ||
|
|
b217c71121 | ||
|
|
25fc4cc39f | ||
|
|
5e46549148 | ||
|
|
fee19c375b | ||
|
|
6423e4993c | ||
|
|
65586bf2be | ||
|
|
b9e9ca093a | ||
|
|
f3e8b02df5 | ||
|
|
e8dac6d863 | ||
|
|
6de1345133 | ||
|
|
2c607d528d | ||
|
|
2a74bcdce4 | ||
|
|
cbe9d3a371 | ||
|
|
c06e5f2928 | ||
|
|
cc90e31263 | ||
|
|
2c6f3ed984 | ||
|
|
6841bdbcdb | ||
|
|
b7af9a7762 | ||
|
|
93443d06a9 | ||
|
|
f52a5670da | ||
|
|
2b1d58c39f | ||
|
|
33e613d948 | ||
|
|
e666645535 | ||
|
|
a856d7bf70 | ||
|
|
050ba6c841 | ||
|
|
5d0234739e | ||
|
|
cdf8deb55a | ||
|
|
aad846c416 | ||
|
|
d09fd835a3 | ||
|
|
ba12191cc8 | ||
|
|
6f9fad72a2 | ||
|
|
4a2fe27cb6 | ||
|
|
1c833ad8a5 | ||
|
|
2aedbe637d | ||
|
|
272a395514 | ||
|
|
05c7b00f1d | ||
|
|
57a402e02e | ||
|
|
0441bdfd88 | ||
|
|
cd90164f77 | ||
|
|
efbdb72ac3 | ||
|
|
f7737c3f76 | ||
|
|
92eb806f1d | ||
|
|
a12d14eb90 | ||
|
|
dbfa2648d8 | ||
|
|
3ee09f164f | ||
|
|
50b6c75d9d | ||
|
|
53df93d14a | ||
|
|
e74d1c77ea | ||
|
|
5e2215842c | ||
|
|
016f5cdbcf | ||
|
|
7ef20bf0a6 | ||
|
|
40feae60f4 | ||
|
|
e840aab1fa | ||
|
|
df1fccf695 | ||
|
|
f58669bc0d | ||
|
|
2f7d48a87e | ||
|
|
ce2fed003b | ||
|
|
da2b560b34 | ||
|
|
9542ab205c | ||
|
|
faff5f4891 | ||
|
|
580cdcd9bb | ||
|
|
a112f12efd | ||
|
|
44ee340ab5 | ||
|
|
5e805d2f4b | ||
|
|
688a25c4cc | ||
|
|
030b6fc1c1 | ||
|
|
84d37a09b6 | ||
|
|
88d2e0d792 | ||
|
|
ea1ca03b75 | ||
|
|
8644ed2a04 | ||
|
|
67403cc55f | ||
|
|
a6b5eab50f | ||
|
|
b7478432f5 | ||
|
|
9d14254225 | ||
|
|
311728cd98 | ||
|
|
44e6c174ee | ||
|
|
d2e0417960 | ||
|
|
aa31d1d14b | ||
|
|
4cf0357c0f | ||
|
|
0f654d4674 | ||
|
|
14faccfa93 | ||
|
|
e420e3a19c | ||
|
|
5bd7a89f6a | ||
|
|
230440c8e7 | ||
|
|
c1e4151607 | ||
|
|
67420f1fa1 | ||
|
|
51b8cd674a | ||
|
|
90d7c850fa | ||
|
|
8ec31e2fb2 | ||
|
|
e0eea893be | ||
|
|
f2e5e59720 | ||
|
|
1df063383d | ||
|
|
1b0a8cdd79 | ||
|
|
6fa79e5dbf | ||
|
|
ed6a876521 | ||
|
|
16b1fdf84d | ||
|
|
d8b3658cdf | ||
|
|
d475ea928b | ||
|
|
c2e128f8c5 | ||
|
|
9b0741512e | ||
|
|
211ab00fc4 | ||
|
|
de5d1ec4e4 | ||
|
|
91ad5467ab | ||
|
|
5d1cec9a79 | ||
|
|
bc1e5525b0 | ||
|
|
f343d7332a | ||
|
|
1109f68db6 | ||
|
|
50b3728013 | ||
|
|
42df487a35 | ||
|
|
85a878bf07 | ||
|
|
4a87a4a6bd | ||
|
|
066c44b341 | ||
|
|
ba8383452c | ||
|
|
d345306ecc | ||
|
|
edf4d637e1 | ||
|
|
c02c1fa775 | ||
|
|
a20f5d026a | ||
|
|
d3aa5c9f94 | ||
|
|
e808882c95 | ||
|
|
a02a9af565 | ||
|
|
061f96dc7d | ||
|
|
00e258dedd | ||
|
|
7672bd3ac5 | ||
|
|
00a69f142a | ||
|
|
adce3b2eeb | ||
|
|
6070e60924 | ||
|
|
dbb92f2eee | ||
|
|
33ddbcc5b3 | ||
|
|
9227c0d77b | ||
|
|
29b738d9b6 | ||
|
|
22b4359e42 | ||
|
|
35c1909f0b | ||
|
|
8de30b8c28 | ||
|
|
14dfb6b81d | ||
|
|
ce02d1d62a | ||
|
|
157c7635db | ||
|
|
b10d6c827d | ||
|
|
cf446479aa | ||
|
|
4658c17c9e | ||
|
|
869095444e | ||
|
|
489864aefa | ||
|
|
2bfd5d8c7d | ||
|
|
71be635a89 | ||
|
|
e3f7e75525 | ||
|
|
b6fb92eeff | ||
|
|
04dc101077 | ||
|
|
d02c734a19 | ||
|
|
9d5f6b9e33 | ||
|
|
de8be2e9f0 | ||
|
|
64d644bcc3 | ||
|
|
395bf7e218 | ||
|
|
67810edcf7 | ||
|
|
cd39e3abc1 | ||
|
|
14ae3e4959 | ||
|
|
ac31113152 | ||
|
|
42c015d5a2 | ||
|
|
49e17cd6a7 | ||
|
|
5e3346ba58 | ||
|
|
2bc15f6bac | ||
|
|
1d4c5744a8 | ||
|
|
24b83b5b0c | ||
|
|
8e732e32be | ||
|
|
e3086351f9 | ||
|
|
3ee533eb7c | ||
|
|
626f00e5c8 | ||
|
|
994f49d8c2 | ||
|
|
411c62396d | ||
|
|
4703b773af | ||
|
|
2ff9d2a26d | ||
|
|
d25fe3fd18 | ||
|
|
9682a6e036 | ||
|
|
a501250666 | ||
|
|
9bfb9ee536 | ||
|
|
8338344cf8 | ||
|
|
abeb01d5f1 | ||
|
|
16d4cc3b34 | ||
|
|
7f352fc982 | ||
|
|
34e538a8ca | ||
|
|
3fbb13e0cd | ||
|
|
3bdddc666b | ||
|
|
c2ddde57c4 | ||
|
|
7a8cefdb71 | ||
|
|
4fa973b836 | ||
|
|
3ec2702bfc | ||
|
|
aa92628cd4 | ||
|
|
6be4598bec | ||
|
|
14a2cd0317 | ||
|
|
fcdffa2265 | ||
|
|
d6e51e6cde | ||
|
|
ef534974a8 | ||
|
|
99799a6c29 | ||
|
|
a399b5bbea | ||
|
|
6f78dc30c5 | ||
|
|
f84a4eb00d | ||
|
|
c3f61d6f57 | ||
|
|
65b1230f18 | ||
|
|
ed7ec8322c | ||
|
|
2540beb951 | ||
|
|
431e5937b5 | ||
|
|
2fea4ae8bf | ||
|
|
5d3d11ee66 | ||
|
|
bdc88147bb | ||
|
|
47ce37c6b0 | ||
|
|
93598f71bb | ||
|
|
82c0d4c9e9 | ||
|
|
a9300ce862 | ||
|
|
4611077eab | ||
|
|
667766d07f | ||
|
|
31a13fcbb2 | ||
|
|
10979fb0fe | ||
|
|
5bc9a1076e | ||
|
|
cc2cf7db19 | ||
|
|
d5a3955024 | ||
|
|
8b351a8fa6 | ||
|
|
9a77f7f3ce | ||
|
|
9237ae5f3e | ||
|
|
0e72ee1ccc | ||
|
|
7e60806f34 | ||
|
|
115955e36e | ||
|
|
90a42bb4d2 | ||
|
|
d6d704d30d | ||
|
|
3f8b9470a9 | ||
|
|
a391158b34 | ||
|
|
187e286f44 | ||
|
|
1c610ebfa3 | ||
|
|
5c4e594064 | ||
|
|
d56b1c71cd | ||
|
|
2139a653b0 | ||
|
|
f634833a16 | ||
|
|
892ed7e6b4 | ||
|
|
977458e00d | ||
|
|
76e7801a58 | ||
|
|
7ed5fe39c9 | ||
|
|
35acffcf0c | ||
|
|
1fbaddde3b | ||
|
|
51a4282abc | ||
|
|
bcfb6ed138 | ||
|
|
59fd32e903 | ||
|
|
efc012f0b5 | ||
|
|
d8cc0513ee | ||
|
|
f90d1d84c7 | ||
|
|
22faf366c3 | ||
|
|
552dd27bde | ||
|
|
4c5eae3bd0 | ||
|
|
4a0cf492f4 | ||
|
|
ac0eff91f6 | ||
|
|
d04c64b75a | ||
|
|
d594af38e1 | ||
|
|
fed7b30436 | ||
|
|
32fa016937 | ||
|
|
5526cf13d0 | ||
|
|
58a0845738 | ||
|
|
0260fd6196 | ||
|
|
d5bc5379a4 | ||
|
|
c5efebc394 | ||
|
|
15ff5c1feb | ||
|
|
696f25e052 | ||
|
|
074a6f24bb | ||
|
|
89d167655e | ||
|
|
91332307b5 | ||
|
|
a43dd1aeb7 | ||
|
|
e3c79837d1 | ||
|
|
77f2cf4e75 | ||
|
|
19f178b9f3 | ||
|
|
5e9da424a4 | ||
|
|
7e1d9c4e42 | ||
|
|
3bcf42b4ac | ||
|
|
5e9c5f9ff7 | ||
|
|
086cc1e5cc | ||
|
|
1873d021c7 | ||
|
|
4be061b162 | ||
|
|
66b6d80ed6 | ||
|
|
92df122286 | ||
|
|
0c7b322efe | ||
|
|
43f33a4d19 | ||
|
|
b02715c1b1 | ||
|
|
ef842c142c | ||
|
|
b58789cb91 | ||
|
|
95dfd2ab45 | ||
|
|
581609cebd | ||
|
|
e701ed74c0 | ||
|
|
ce03e93dfd | ||
|
|
be085e08b3 | ||
|
|
da6a1f6c76 | ||
|
|
407cd22df3 | ||
|
|
43577eacf9 | ||
|
|
045e8f7f07 | ||
|
|
c17c5c8188 | ||
|
|
f2cb47a275 | ||
|
|
a8bb67e5a9 | ||
|
|
3c620745a7 | ||
|
|
3f2ef301c4 | ||
|
|
28db388687 | ||
|
|
a3845bd44b | ||
|
|
c8ddbca289 | ||
|
|
b8530db29f | ||
|
|
cc9133fadf | ||
|
|
02156d7c53 | ||
|
|
8b3f7c6ff0 | ||
|
|
cc8df443e6 | ||
|
|
8755a6805a | ||
|
|
7ce8dfe258 | ||
|
|
3405865cd2 | ||
|
|
18f4b35de5 | ||
|
|
1630b15a0e | ||
|
|
4dc725069a | ||
|
|
2a07591e9b | ||
|
|
6ce4882e2a | ||
|
|
4e08a1d3bc | ||
|
|
a311c1cd21 | ||
|
|
4802041125 | ||
|
|
8bde192230 | ||
|
|
e005c1f751 | ||
|
|
e7c15f3e41 | ||
|
|
1a9a4d13c7 | ||
|
|
892b81cb44 | ||
|
|
38218222cd | ||
|
|
05c1af2f57 | ||
|
|
9eecea2a8e | ||
|
|
2c31f2b499 | ||
|
|
86eefe66a6 | ||
|
|
964a22d663 | ||
|
|
b457b5d42e | ||
|
|
400d484c41 | ||
|
|
47ae9a3e0f | ||
|
|
22f9ca067c | ||
|
|
85712cb267 | ||
|
|
055ddf28b4 | ||
|
|
ad02bb6032 | ||
|
|
6262130033 | ||
|
|
756095aaf0 | ||
|
|
25299d0d2f | ||
|
|
439527e0b9 | ||
|
|
a683760d1c | ||
|
|
f46386f87d | ||
|
|
10e445c341 | ||
|
|
e4f9ae630d | ||
|
|
8252677857 | ||
|
|
452d7857cc | ||
|
|
b9e093c1a8 | ||
|
|
aa8b75afa8 | ||
|
|
50103b80ca | ||
|
|
d850ff7386 | ||
|
|
d70d48ea3e | ||
|
|
7404770855 | ||
|
|
b56211da74 | ||
|
|
4c2c2e7467 | ||
|
|
1913d03c89 | ||
|
|
023d8b367d | ||
|
|
f0512c5686 | ||
|
|
62bb97b9ac | ||
|
|
2719c40abc | ||
|
|
3bc6dc4305 | ||
|
|
be2de6bc98 | ||
|
|
a117c67704 | ||
|
|
74ff1aac8e | ||
|
|
345c3eed92 | ||
|
|
3bfca02ca0 | ||
|
|
a4b6e4cd66 | ||
|
|
763f26b29a | ||
|
|
4ac54c3cd6 | ||
|
|
c20ba350ad | ||
|
|
5cc45fd6df | ||
|
|
eaad60012a | ||
|
|
36adfee700 | ||
|
|
b10fb30664 | ||
|
|
d83e1f8900 | ||
|
|
26a69b1a29 | ||
|
|
5a5af28b7c | ||
|
|
1dd9985842 | ||
|
|
6ca296de5d | ||
|
|
21b5c4bc4d | ||
|
|
9ca11b80fc | ||
|
|
2e1b59c09d | ||
|
|
3c7c57b3ad | ||
|
|
fd7105e1d6 | ||
|
|
38b8c2f0ef | ||
|
|
6ac57da9cd | ||
|
|
4d53f88ea5 | ||
|
|
4add559463 | ||
|
|
f0d2577482 | ||
|
|
55a9cbffe7 | ||
|
|
f54cc16225 | ||
|
|
f80fb63847 | ||
|
|
33c17e84f2 | ||
|
|
979a590374 | ||
|
|
c0cfde855c | ||
|
|
1f981a0210 | ||
|
|
2e25b45529 | ||
|
|
bdb1602e25 | ||
|
|
fe418b6240 | ||
|
|
19e6975e90 | ||
|
|
a97cc7c538 | ||
|
|
d06a3aec90 | ||
|
|
2f1473783f | ||
|
|
a6ae163f09 | ||
|
|
76f402f51b | ||
|
|
b6d2ffa0c3 | ||
|
|
b6563b2d50 | ||
|
|
024e30659f | ||
|
|
cd9000a034 | ||
|
|
24fd779ccf | ||
|
|
366f303099 | ||
|
|
409b94e337 | ||
|
|
b4aae95e78 | ||
|
|
8705f11462 | ||
|
|
627856c2cf | ||
|
|
257a3bcf05 | ||
|
|
117bacff3a | ||
|
|
d910129db9 | ||
|
|
e300354827 | ||
|
|
abd867408b | ||
|
|
7a4d1f0fdb | ||
|
|
89c9085fcd | ||
|
|
71cbfe8860 | ||
|
|
76a6ac5c44 | ||
|
|
1040f1ac81 | ||
|
|
4b8c2743fb | ||
|
|
2413fda880 | ||
|
|
d91d48ed83 | ||
|
|
364c050c1a | ||
|
|
f228b139fa | ||
|
|
6a6ac8951c | ||
|
|
deab46b949 | ||
|
|
5b8f6495d1 | ||
|
|
edc8253164 | ||
|
|
8f91c754c8 | ||
|
|
e0b2920fdd | ||
|
|
03c5cacaec | ||
|
|
d8d4b03bc5 | ||
|
|
ce23b96141 | ||
|
|
75905554de | ||
|
|
ea84d5dd61 | ||
|
|
bb8322f4c8 | ||
|
|
a478af780a | ||
|
|
21e8297c16 | ||
|
|
0879ed8eaf | ||
|
|
53c7d3bc82 | ||
|
|
7e08d60891 | ||
|
|
1dc925aa11 | ||
|
|
fd644379ed | ||
|
|
a119e8f8d0 | ||
|
|
153f54b94f | ||
|
|
ddf1f74cc3 | ||
|
|
674ea621df | ||
|
|
3576a86dfb | ||
|
|
7a3ae15f7d | ||
|
|
be1aa6e080 | ||
|
|
8dc66668e6 | ||
|
|
65ee62c698 | ||
|
|
ba825db7ad | ||
|
|
c49c2e80e8 | ||
|
|
74e983609c | ||
|
|
aa25adaaa0 | ||
|
|
d0d0f09d40 | ||
|
|
0b1530e1e3 | ||
|
|
b9d65553d7 | ||
|
|
1b6f7d3992 | ||
|
|
30ce53edf9 | ||
|
|
c37c0d1195 | ||
|
|
031227571f | ||
|
|
5e8d78ff40 | ||
|
|
134d29791f | ||
|
|
d982f7d040 | ||
|
|
8737bd492f | ||
|
|
ddef5f56d3 | ||
|
|
09345b6eb4 | ||
|
|
7dcc736177 | ||
|
|
2f85b88bdf | ||
|
|
84aba108d6 | ||
|
|
843e7306a1 | ||
|
|
1c7414ba64 | ||
|
|
6e6910e89b | ||
|
|
3b5b551723 | ||
|
|
7a4df47c41 | ||
|
|
faab86eecc | ||
|
|
80a67be49b | ||
|
|
3f60381c7a | ||
|
|
6993ea56e9 | ||
|
|
7aa7b6dbec | ||
|
|
3d9b2409ce | ||
|
|
82b3873e31 | ||
|
|
1edebfd17b | ||
|
|
aaa3706132 | ||
|
|
c840af9323 | ||
|
|
bf617c729e | ||
|
|
7387b7409a | ||
|
|
36a5d9d238 | ||
|
|
83d312b3f5 | ||
|
|
66ecd42c6e | ||
|
|
bb631abf79 | ||
|
|
b0a89debf1 | ||
|
|
e4451444a3 | ||
|
|
e086462c22 | ||
|
|
f77287acae | ||
|
|
85f7af7f92 | ||
|
|
fe51f97001 | ||
|
|
e480777a66 | ||
|
|
daddf82191 | ||
|
|
6be102a7a4 | ||
|
|
d40bcf1723 | ||
|
|
8b4725152d | ||
|
|
9582b1cdee | ||
|
|
7cdba23378 | ||
|
|
68f4bb1ad4 | ||
|
|
5b6447311e | ||
|
|
0cc699da2a | ||
|
|
2a16fd79cc | ||
|
|
0f7601bf85 | ||
|
|
1d7eaef724 | ||
|
|
ac87162327 | ||
|
|
7321ba352c | ||
|
|
c3a5da1def | ||
|
|
ec65eee13b | ||
|
|
d8f6cdb23b | ||
|
|
199c556b18 | ||
|
|
719a2b62ad | ||
|
|
fcbd92d31e | ||
|
|
20e5edecac | ||
|
|
c2bfb82eb7 | ||
|
|
f3a31100ec | ||
|
|
fe706f6e28 | ||
|
|
0d30199d2b | ||
|
|
30d3cc5854 | ||
|
|
c6838b243e | ||
|
|
56e1973681 | ||
|
|
efe0be8eeb | ||
|
|
a0609a5e50 | ||
|
|
0298a12bd8 | ||
|
|
689114d5ef | ||
|
|
bb4cee56c8 | ||
|
|
5c8514046b | ||
|
|
ea3b2ebdc8 | ||
|
|
5926e27a45 | ||
|
|
c139c254e6 | ||
|
|
aebd271f92 | ||
|
|
14b2ea965a | ||
|
|
bab8a11dd8 | ||
|
|
dafd6e3e76 | ||
|
|
e8b4d69f1a | ||
|
|
659295da13 | ||
|
|
b8c4739843 | ||
|
|
9f90f4835e | ||
|
|
a443f36e44 | ||
|
|
90965c3d7e | ||
|
|
3ee7a1103f | ||
|
|
f72fb65759 | ||
|
|
852575c603 | ||
|
|
3a2d3ad1c5 | ||
|
|
7e2aebae6b | ||
|
|
04a22b9409 | ||
|
|
f626e49ae2 | ||
|
|
bd8a138197 | ||
|
|
5fe77ba686 | ||
|
|
b079982e2c | ||
|
|
34e8ec1eef | ||
|
|
8dcefc5dbd | ||
|
|
40b41cfd6a | ||
|
|
22659e40da | ||
|
|
69ec314fb5 | ||
|
|
b50c3ca33f | ||
|
|
b96fd4daa4 | ||
|
|
c3574b2b38 | ||
|
|
e25f0c337c | ||
|
|
feca7e5b6f | ||
|
|
ede97ef4b4 | ||
|
|
f37c1f3363 | ||
|
|
4c24ec5383 | ||
|
|
def5d225f9 | ||
|
|
3b9219b882 | ||
|
|
00c5bcbd7b | ||
|
|
9c5f5a5314 | ||
|
|
0d88231511 | ||
|
|
668d21fe80 | ||
|
|
af894dd7be | ||
|
|
27c9e4290d | ||
|
|
70d9c0bd55 | ||
|
|
f40efc062f | ||
|
|
16299d15a8 | ||
|
|
68e57edef5 | ||
|
|
ff6f4bcf88 | ||
|
|
e35e2360e5 | ||
|
|
cb2dd6c427 | ||
|
|
1798b82a86 | ||
|
|
6b0f9283dd | ||
|
|
79fc8d851e | ||
|
|
eda68dbd6a | ||
|
|
b754ae7260 | ||
|
|
f7f66301b2 | ||
|
|
bfa7c1f2ee | ||
|
|
615df6941d | ||
|
|
4b24e9833c | ||
|
|
1a275c641e | ||
|
|
41f55c093a | ||
|
|
16c97143f3 | ||
|
|
0baf670330 | ||
|
|
357eba2331 | ||
|
|
54656d1d59 | ||
|
|
c5414ae082 | ||
|
|
24b8211e9f | ||
|
|
f14f1a0dc3 | ||
|
|
9821061877 | ||
|
|
98f16a9b4d | ||
|
|
7a9a82bf06 | ||
|
|
db1a243631 | ||
|
|
55e8d83a10 | ||
|
|
5838d99dfe | ||
|
|
825d07f5d5 | ||
|
|
64462a3578 | ||
|
|
36db4985d5 | ||
|
|
4240858f53 | ||
|
|
ea1c8a3360 | ||
|
|
c65c17f5ea | ||
|
|
392b89a5a5 | ||
|
|
3b1c09417f | ||
|
|
f222c7547c | ||
|
|
444950fec8 | ||
|
|
3ca410784c | ||
|
|
4c1c7f5a52 | ||
|
|
2e069ba879 | ||
|
|
c61c02e031 | ||
|
|
05e874048b | ||
|
|
4f2536e187 | ||
|
|
7d3a698e52 | ||
|
|
49933cde47 | ||
|
|
63c18bbe6c | ||
|
|
1fee9f05fb | ||
|
|
b2c532f62d | ||
|
|
9a6243c913 | ||
|
|
4d289a4912 | ||
|
|
5b3da6d4e3 | ||
|
|
95de778c46 | ||
|
|
f585c78fe6 | ||
|
|
164cb4004b | ||
|
|
cb9c102ddb | ||
|
|
0cae220381 | ||
|
|
389975d9ee | ||
|
|
a1a5989d85 | ||
|
|
8311c51c07 | ||
|
|
2691a24539 | ||
|
|
1bd552079d | ||
|
|
daa07a8ac3 | ||
|
|
7a9b1adb5f | ||
|
|
769c80420b | ||
|
|
6212076d91 | ||
|
|
c8eee1dffe | ||
|
|
88617301e9 | ||
|
|
33d5bcb4f3 | ||
|
|
9b74d3f224 | ||
|
|
5cac289deb | ||
|
|
cf75c6f1be | ||
|
|
b0716b6875 | ||
|
|
adce982c72 | ||
|
|
d8d563f60a | ||
|
|
9cc9035c67 | ||
|
|
af9ce6951a | ||
|
|
c689a22bb0 | ||
|
|
65b7cbecf3 | ||
|
|
f7e0f6d5f5 | ||
|
|
6b7eeb745c | ||
|
|
3901fbb143 | ||
|
|
bf9f8d041b | ||
|
|
a63544a357 | ||
|
|
98d1d692b5 | ||
|
|
de4b417a81 | ||
|
|
de0008d00e | ||
|
|
89e518a098 | ||
|
|
59641bb95f | ||
|
|
a06a8bc928 | ||
|
|
0a22f153ea | ||
|
|
4a7a6cc081 | ||
|
|
093fe3bb51 | ||
|
|
205cdc87d4 | ||
|
|
a5cccc9dbf | ||
|
|
c7de3b4d83 | ||
|
|
9a4a8bb721 | ||
|
|
649fe159ce | ||
|
|
e1594812ac | ||
|
|
863946aebd | ||
|
|
c5cf41164a | ||
|
|
a4f55b50c9 | ||
|
|
d7bacc0721 | ||
|
|
f1962bc0ce | ||
|
|
8622727c09 | ||
|
|
ebd6166488 | ||
|
|
f83b43b7c9 | ||
|
|
e2796477e6 | ||
|
|
c653640b0d | ||
|
|
2d830a0e0c | ||
|
|
6687665312 | ||
|
|
d88cc24540 | ||
|
|
3347727ebb |
48
.gitignore
vendored
Normal file
48
.gitignore
vendored
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
.DS_Store
|
||||||
|
Makefile.in
|
||||||
|
Makefile
|
||||||
|
/CMakeFiles
|
||||||
|
/autom4te.cache
|
||||||
|
/aclocal.m4
|
||||||
|
/compile
|
||||||
|
/configure
|
||||||
|
/depcomp
|
||||||
|
/install-sh
|
||||||
|
/libtool
|
||||||
|
/missing
|
||||||
|
/stamp-h*
|
||||||
|
/java/classnoinst.stamp
|
||||||
|
/pkgscripts/
|
||||||
|
/jconfig.h
|
||||||
|
/jconfigint.h
|
||||||
|
/config.guess
|
||||||
|
/config.h
|
||||||
|
/config.h.in
|
||||||
|
/config.log
|
||||||
|
/config.status
|
||||||
|
/config.sub
|
||||||
|
/ltmain.sh
|
||||||
|
/ar-lib
|
||||||
|
/libjpeg.map
|
||||||
|
/.libs/
|
||||||
|
/simd/.libs/
|
||||||
|
/simd/jsimdcfg.inc
|
||||||
|
*.o
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
/cjpeg
|
||||||
|
/djpeg
|
||||||
|
/jcstest
|
||||||
|
/jpegtran
|
||||||
|
/jpegyuv
|
||||||
|
/md5/md5cmp
|
||||||
|
/rdjpgcom
|
||||||
|
/test_enc_*
|
||||||
|
/tjbench
|
||||||
|
/tjbenchtest
|
||||||
|
/tjunittest
|
||||||
|
/wrjpgcom
|
||||||
|
/yuvjpeg
|
||||||
|
test_yuv*.jpg
|
||||||
|
CMakeCache.txt
|
||||||
|
CTestTestfile.cmake
|
||||||
137
.travis.yml
137
.travis.yml
@@ -1,137 +0,0 @@
|
|||||||
language: c
|
|
||||||
|
|
||||||
branches:
|
|
||||||
except:
|
|
||||||
- /^[0-9]+\.[0-9]+\.[0-9]+/
|
|
||||||
- /^jpeg-.*/
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: linux
|
|
||||||
env: BUILD_OFFICIAL=1
|
|
||||||
sudo: required
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
- os: osx
|
|
||||||
env: BUILD_OFFICIAL=1
|
|
||||||
osx_image: xcode7.3
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: clang
|
|
||||||
env:
|
|
||||||
CMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
CFLAGS_RELWITHDEBINFO="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
|
|
||||||
CMAKE_FLAGS="-DENABLE_SHARED=0"
|
|
||||||
ASAN_OPTIONS="detect_leaks=1 symbolize=1"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- nasm
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: gcc
|
|
||||||
env: CMAKE_FLAGS="-DWITH_12BIT=1"
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: gcc
|
|
||||||
env: CMAKE_FLAGS="-DWITH_JPEG7=1"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- nasm
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: gcc
|
|
||||||
env: CMAKE_FLAGS="-DWITH_JPEG8=1"
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- nasm
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
compiler: gcc
|
|
||||||
env: CMAKE_FLAGS="-DWITH_SIMD=0"
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
|
||||||
brew update &&
|
|
||||||
brew bundle &&
|
|
||||||
ln -fs /usr/local/bin/gpg1 /usr/local/bin/gpg &&
|
|
||||||
git clone --depth=1 https://github.com/libjpeg-turbo/gas-preprocessor.git ~/src/gas-preprocessor &&
|
|
||||||
ln -fs /Applications/Xcode.app /Applications/Xcode72.app;
|
|
||||||
fi
|
|
||||||
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
|
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
|
||||||
docker pull dcommander/buildljt;
|
|
||||||
fi &&
|
|
||||||
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b $TRAVIS_BRANCH ~/src/buildscripts &&
|
|
||||||
if [ -n "$encrypted_f92e8533f6f1_iv" ]; then
|
|
||||||
openssl aes-256-cbc -K $encrypted_f92e8533f6f1_key -iv $encrypted_f92e8533f6f1_iv -in ci/keys.enc -out ci/keys -d &&
|
|
||||||
tar xf ci/keys &&
|
|
||||||
rm ci/keys &&
|
|
||||||
mv ci/gpgsign ~/src/buildscripts &&
|
|
||||||
gpg --import ci/sign_ljt &&
|
|
||||||
rm ci/sign_ljt;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
script:
|
|
||||||
- if [ "${BUILD_OFFICIAL:-}" != "" ]; then
|
|
||||||
mkdir -p ~/src/ljt.nightly &&
|
|
||||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
|
||||||
docker run -v $HOME/src/ljt.nightly:/root/src/ljt.nightly -v $HOME/src/buildscripts:/root/src/buildscripts -v $TRAVIS_BUILD_DIR:/root/src/libjpeg-turbo -v $HOME/.gnupg:/root/.gnupg -t dcommander/buildljt:latest bash -c "rpm --import http://pgp.mit.edu/pks/lookup?op=get\&search=0x0575F26BD5B3FDB1 && ~/src/buildscripts/buildljt -d /root/src/libjpeg-turbo -v" &&
|
|
||||||
sudo chown -R travis:travis ~/src/ljt.nightly &&
|
|
||||||
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
|
|
||||||
else
|
|
||||||
PATH=$PATH:~/src/gas-preprocessor ~/src/buildscripts/buildljt -d $TRAVIS_BUILD_DIR -v &&
|
|
||||||
mv ~/src/ljt.nightly/latest/log-$TRAVIS_OS_NAME.txt ~/src/ljt.nightly/latest/files/;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
|
|
||||||
mkdir build &&
|
|
||||||
pushd build &&
|
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE "-DCMAKE_C_FLAGS_RELWITHDEBINFO=$CFLAGS_RELWITHDEBINFO" $CMAKE_FLAGS .. &&
|
|
||||||
export NUMCPUS=`grep -c '^processor' /proc/cpuinfo` &&
|
|
||||||
make -j$NUMCPUS --load-average=$NUMCPUS &&
|
|
||||||
make test &&
|
|
||||||
if [[ ! "${CMAKE_FLAGS[0]}" =~ "WITH_12BIT" &&
|
|
||||||
! "${CMAKE_FLAGS[0]}" =~ "WITH_SIMD" ]]; then
|
|
||||||
JSIMD_FORCESSE2=1 make test &&
|
|
||||||
cmake -DFLOATTEST=32bit .. &&
|
|
||||||
JSIMD_FORCENONE=1 make test;
|
|
||||||
fi &&
|
|
||||||
popd;
|
|
||||||
fi
|
|
||||||
|
|
||||||
after_failure:
|
|
||||||
- if [ "${BUILD_OFFICIAL:-}" == "" ]; then
|
|
||||||
if [ -f $TRAVIS_BUILD_DIR/build/config.log ]; then
|
|
||||||
cat $TRAVIS_BUILD_DIR/build/config.log;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
- provider: s3
|
|
||||||
bucket: libjpeg-turbo-pr
|
|
||||||
access_key_id:
|
|
||||||
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
|
|
||||||
secret_access_key:
|
|
||||||
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
|
|
||||||
acl: public_read
|
|
||||||
local-dir: $HOME/src/ljt.nightly/latest/files
|
|
||||||
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
condition: -n "$BUILD_OFFICIAL"
|
|
||||||
- provider: s3
|
|
||||||
bucket: libjpeg-turbo-pr
|
|
||||||
access_key_id:
|
|
||||||
secure: bmFEt4H90/oR/LiN9XI+G26Pd6hiyrTw3+Vg3lS4ynwAYk33weApaVM8CyzQTgIhGSPzFStqVm9fTrb3RmrYP/PnNS+/surOeWLkH2DMRxvc0qmetBuNx1+vAN7FUkY8MO/u5uE9WXHAdp4e64pXcLXEbKmh+wgDm72b35WmMxErtHsGbpqy+j47rQkY4BJGi7XQzjjafaamfm4PzitsjkYYsgX8KLI16jyJEIirvyDHCPTn9wKR/jSjelDl+xTlgZGuCqmLCBW8f6JgycIspWjcYfO4WpWvkbnnI2sl3rCMPvOYc4wHe8SwzG0l4tM1PblZZDRcU7vjE15PmNf1Xfq9Vx3RpgBJv+UBNL/Vn0rKdpUCeEcfC12hxrske8DWpV6waBiDivjQJreE+YRXqa5YBhV/EdkoKYCqafnJvRASlOko9evje8F9KXTNsIGTT1HPmU9QM9WoJwLs/Xa3t09EmA2IjhcuAvvUmwCTuBBQVAlDjExiTT3Zhc9IYZDD92JgpAYLgridtzR87ElOxKhTkR4PowdI6UiLYArPjMFTjoz5Rivb9qNpbLaQC8HCYgLWxpWtUTzlW/9rM8izHpF8ySFHjO6E2aA9OJFc0tcbEGwAs2jLGD01OduU+DbBfsIkW0EgfXCPbD3FVgHsn3tkuzgO/bg20SM7uuCEYKQ=
|
|
||||||
secret_access_key:
|
|
||||||
secure: mrkOpEtqd2dEmi/qNJyX9vkME+6xgVBnXaRETKF7jT+flcQCQ0ayQkRkMV7lzGqq44XFg+n6Cpfn6oW0gH9RNdcC8YQvFP+kgzPx6nw6V/M31Vz6ySapJf59HBzVevf0NJkr0/1JoWsp1iq4IoN10WPzsCXZB55Io3Cf7DgpR+yiyBlWOctDfNdjJ97Juw3ENE80MHDf0fVqdUOIknQka1p68yAGkjar9kc2Oe7o94RzzmoqEn8tuFumiBQjIcuVRALsKqz+eIxBNgkL3BF9shVyRjOWLAeBhMPVFxZs5Dgd4ECbvU0i33gfmje3d6qqcw78N2lZaLefoVvWol3pOzVO133ewOSY9/lmpqEiRUU2ohEe8T4aSoS7posBW42itUTO4Y5w+eVOnHsm4sRQaI+/AXWTe7GPel+P8Qbe8Ya10A5gnpoag7o3raRDcHx+/qaZw1Af/u4XiAOYz3be3U90Qc+YMc/kS5i8BH0GXBbSfaWQ00CwRFlZQ3n1xUqmjC2CmjZTki3W/p7mEt0DjhcH9ZIXscK603sCC+mF6pEd9019k5fG/8fr2Y4Ptai9kd3BxZJCX9/jSoMfWOBbgkA5bRgHU0xrAj+p49qD6Ej9Xr8GE3+uebz3sEuhSFRnCKwKoOHOemfgevfO2y/jQXP677WPf3xQX7bVDfTFSHU=
|
|
||||||
acl: public_read
|
|
||||||
local-dir: $HOME/src/ljt.nightly/latest/files
|
|
||||||
upload-dir: $TRAVIS_BRANCH/$TRAVIS_OS_NAME
|
|
||||||
on:
|
|
||||||
branch: dev
|
|
||||||
condition: -n "$BUILD_OFFICIAL"
|
|
||||||
189
BUILDING.md
189
BUILDING.md
@@ -15,13 +15,18 @@ Build Requirements
|
|||||||
* If using NASM, 2.10 or later is required.
|
* If using NASM, 2.10 or later is required.
|
||||||
* If using NASM, 2.10 or later (except 2.11.08) is required for an x86-64 Mac
|
* If using NASM, 2.10 or later (except 2.11.08) is required for an x86-64 Mac
|
||||||
build (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code
|
build (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code
|
||||||
when building macho64 objects.) NASM or YASM can be obtained from
|
when building macho64 objects.)
|
||||||
[MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
|
|
||||||
* If using YASM, 1.2.0 or later is required.
|
* If using YASM, 1.2.0 or later is required.
|
||||||
|
* If building on macOS, NASM or YASM can be obtained from
|
||||||
|
[MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
|
||||||
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
|
- NOTE: Currently, if it is desirable to hide the SIMD function symbols in
|
||||||
Mac executables or shared libraries that statically link with
|
Mac executables or shared libraries that statically link with
|
||||||
libjpeg-turbo, then YASM must be used when building libjpeg-turbo.
|
libjpeg-turbo, then NASM 2.14 or later or YASM must be used when
|
||||||
|
building libjpeg-turbo.
|
||||||
* If building on Windows, **nasm.exe**/**yasm.exe** should be in your `PATH`.
|
* If building on Windows, **nasm.exe**/**yasm.exe** should be in your `PATH`.
|
||||||
|
* NASM and YASM are located in the CRB (Code Ready Builder) repository on
|
||||||
|
Red Hat Enterprise Linux 8 and in the PowerTools repository on CentOS 8,
|
||||||
|
which is not enabled by default.
|
||||||
|
|
||||||
The binary RPMs released by the NASM project do not work on older Linux
|
The binary RPMs released by the NASM project do not work on older Linux
|
||||||
systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily
|
systems, such as Red Hat Enterprise Linux 5. On such systems, you can easily
|
||||||
@@ -48,8 +53,9 @@ Build Requirements
|
|||||||
install the Java Developer Package, which can be downloaded from
|
install the Java Developer Package, which can be downloaded from
|
||||||
<http://developer.apple.com/downloads> (Apple ID required.) For other
|
<http://developer.apple.com/downloads> (Apple ID required.) For other
|
||||||
systems, you can obtain the Oracle Java Development Kit from
|
systems, you can obtain the Oracle Java Development Kit from
|
||||||
<http://www.java.com>.
|
<http://www.oracle.com/technetwork/java/javase/downloads>.
|
||||||
|
|
||||||
|
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@@ -83,7 +89,22 @@ Build Requirements
|
|||||||
appropriate compiler paths automatically set.
|
appropriate compiler paths automatically set.
|
||||||
|
|
||||||
- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
|
- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
|
||||||
can be downloaded from <http://www.java.com>.
|
can be downloaded from
|
||||||
|
<http://www.oracle.com/technetwork/java/javase/downloads>.
|
||||||
|
|
||||||
|
* If using JDK 11 or later, CMake 3.10.x or later must also be used.
|
||||||
|
|
||||||
|
- Vcpkg
|
||||||
|
|
||||||
|
You can download and install mozjpeg using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||||
|
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
./bootstrap-vcpkg.sh
|
||||||
|
./vcpkg integrate install
|
||||||
|
vcpkg install mozjpeg
|
||||||
|
|
||||||
|
The mozjpeg port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||||
|
|
||||||
|
|
||||||
Out-of-Tree Builds
|
Out-of-Tree Builds
|
||||||
@@ -416,13 +437,14 @@ iPhone 3GS-4S/iPad 1st-3rd Generation and newer:
|
|||||||
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
||||||
export CFLAGS="-mfloat-abi=softfp -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0"
|
export CFLAGS="-mfloat-abi=softfp -march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -miphoneos-version-min=3.0"
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
cat <<EOF >toolchain.cmake
|
||||||
set(CMAKE_SYSTEM_NAME Darwin)
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||||
set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
|
set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd {build_directory}
|
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||||
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
@@ -441,13 +463,14 @@ Same as above, but replace the first line with:
|
|||||||
export CFLAGS="-mfloat-abi=softfp -arch armv7 -miphoneos-version-min=3.0"
|
export CFLAGS="-mfloat-abi=softfp -arch armv7 -miphoneos-version-min=3.0"
|
||||||
export ASMFLAGS="-no-integrated-as"
|
export ASMFLAGS="-no-integrated-as"
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
cat <<EOF >toolchain.cmake
|
||||||
set(CMAKE_SYSTEM_NAME Darwin)
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||||
set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd {build_directory}
|
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||||
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
@@ -467,13 +490,14 @@ iPhone 5/iPad 4th Generation and newer:
|
|||||||
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
||||||
export CFLAGS="-Wall -mfloat-abi=softfp -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0"
|
export CFLAGS="-Wall -mfloat-abi=softfp -march=armv7s -mcpu=swift -mtune=swift -mfpu=neon -miphoneos-version-min=6.0"
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
cat <<EOF >toolchain.cmake
|
||||||
set(CMAKE_SYSTEM_NAME Darwin)
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||||
set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
|
set(CMAKE_C_COMPILER ${IOS_PLATFORMDIR}/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd {build_directory}
|
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||||
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
@@ -498,13 +522,14 @@ iPhone 5S/iPad Mini 2/iPad Air and newer.
|
|||||||
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
|
||||||
export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=7.0 -funwind-tables"
|
export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=7.0 -funwind-tables"
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
cat <<EOF >toolchain.cmake
|
||||||
set(CMAKE_SYSTEM_NAME Darwin)
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||||
set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd {build_directory}
|
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||||
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
-DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
@@ -517,7 +542,7 @@ a universal library.
|
|||||||
Building libjpeg-turbo for Android
|
Building libjpeg-turbo for Android
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
Building libjpeg-turbo for Android platforms requires the
|
Building libjpeg-turbo for Android platforms requires v13b or later of the
|
||||||
[Android NDK](https://developer.android.com/tools/sdk/ndk).
|
[Android NDK](https://developer.android.com/tools/sdk/ndk).
|
||||||
|
|
||||||
|
|
||||||
@@ -527,34 +552,21 @@ The following is a general recipe script that can be modified for your specific
|
|||||||
needs.
|
needs.
|
||||||
|
|
||||||
# Set these variables to suit your needs
|
# Set these variables to suit your needs
|
||||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
|
NDK_PATH={full path to the NDK directory-- for example,
|
||||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
/opt/android/android-ndk-r16b}
|
||||||
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r16b and earlier,
|
||||||
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
and "clang" must be used with NDK r17c and later}
|
||||||
toolchain directory under ${NDK_PATH}/toolchains/.}
|
ANDROID_VERSION={the minimum version of Android to support-- for example,
|
||||||
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
|
||||||
"16", "19", etc.}
|
"16", "19", etc.}
|
||||||
|
|
||||||
# It should not be necessary to modify the rest
|
|
||||||
HOST=arm-linux-androideabi
|
|
||||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
|
|
||||||
export CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
|
|
||||||
-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
|
|
||||||
export LDFLAGS=-pie
|
|
||||||
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
|
||||||
set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cd {build_directory}
|
cd {build_directory}
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" \
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
|
-DANDROID_ABI=armeabi-v7a \
|
||||||
|
-DANDROID_ARM_MODE=arm \
|
||||||
|
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
|
||||||
|
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
|
||||||
|
-DCMAKE_ASM_FLAGS="--target=arm-linux-androideabi${ANDROID_VERSION}" \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -565,33 +577,21 @@ The following is a general recipe script that can be modified for your specific
|
|||||||
needs.
|
needs.
|
||||||
|
|
||||||
# Set these variables to suit your needs
|
# Set these variables to suit your needs
|
||||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
|
NDK_PATH={full path to the NDK directory-- for example,
|
||||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
/opt/android/android-ndk-r16b}
|
||||||
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
|
||||||
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
and "clang" must be used with NDK r17c and later}
|
||||||
toolchain directory under ${NDK_PATH}/toolchains/.}
|
ANDROID_VERSION={the minimum version of Android to support. "21" or later
|
||||||
ANDROID_VERSION={The minimum version of Android to support. "21" or later
|
|
||||||
is required for a 64-bit build.}
|
is required for a 64-bit build.}
|
||||||
|
|
||||||
# It should not be necessary to modify the rest
|
|
||||||
HOST=aarch64-linux-android
|
|
||||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
|
|
||||||
export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
|
|
||||||
export LDFLAGS=-pie
|
|
||||||
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
|
||||||
set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cd {build_directory}
|
cd {build_directory}
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" \
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
|
-DANDROID_ABI=arm64-v8a \
|
||||||
|
-DANDROID_ARM_MODE=arm \
|
||||||
|
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
|
||||||
|
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
|
||||||
|
-DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -602,33 +602,19 @@ The following is a general recipe script that can be modified for your specific
|
|||||||
needs.
|
needs.
|
||||||
|
|
||||||
# Set these variables to suit your needs
|
# Set these variables to suit your needs
|
||||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
|
NDK_PATH={full path to the NDK directory-- for example,
|
||||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
/opt/android/android-ndk-r16b}
|
||||||
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
|
||||||
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
and "clang" must be used with NDK r17c and later}
|
||||||
toolchain directory under ${NDK_PATH}/toolchains/.}
|
|
||||||
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
||||||
"16", "19", etc.}
|
"16", "19", etc.}
|
||||||
|
|
||||||
# It should not be necessary to modify the rest
|
|
||||||
HOST=i686-linux-android
|
|
||||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86
|
|
||||||
export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
|
|
||||||
export LDFLAGS=-pie
|
|
||||||
TOOLCHAIN=${NDK_PATH}/toolchains/x86-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR i386)
|
|
||||||
set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cd {build_directory}
|
cd {build_directory}
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" \
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
|
-DANDROID_ABI=x86 \
|
||||||
|
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
|
||||||
|
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -639,42 +625,23 @@ The following is a general recipe script that can be modified for your specific
|
|||||||
needs.
|
needs.
|
||||||
|
|
||||||
# Set these variables to suit your needs
|
# Set these variables to suit your needs
|
||||||
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/sdk/ndk-bundle}
|
NDK_PATH={full path to the NDK directory-- for example,
|
||||||
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
/opt/android/android-ndk-r16b}
|
||||||
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
|
||||||
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
and "clang" must be used with NDK r17c and later}
|
||||||
toolchain directory under ${NDK_PATH}/toolchains/.}
|
ANDROID_VERSION={the minimum version of Android to support. "21" or later
|
||||||
ANDROID_VERSION={The minimum version of Android to support. "21" or later
|
|
||||||
is required for a 64-bit build.}
|
is required for a 64-bit build.}
|
||||||
|
|
||||||
# It should not be necessary to modify the rest
|
|
||||||
HOST=x86_64-linux-android
|
|
||||||
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-x86_64
|
|
||||||
export CFLAGS="-D__ANDROID_API__=${ANDROID_VERSION} --sysroot=${SYSROOT} \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include \
|
|
||||||
-isystem ${NDK_PATH}/sysroot/usr/include/${HOST}"
|
|
||||||
export LDFLAGS=-pie
|
|
||||||
TOOLCHAIN=${NDK_PATH}/toolchains/x86_64-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
|
||||||
|
|
||||||
cat <<EOF >toolchain.cmake
|
|
||||||
set(CMAKE_SYSTEM_NAME Linux)
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
|
||||||
set(CMAKE_C_COMPILER ${TOOLCHAIN}/bin/${HOST}-gcc)
|
|
||||||
set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN}/${HOST})
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cd {build_directory}
|
cd {build_directory}
|
||||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
cmake -G"Unix Makefiles" \
|
||||||
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
|
-DANDROID_ABI=x86_64 \
|
||||||
|
-DANDROID_PLATFORM=android-${ANDROID_VERSION} \
|
||||||
|
-DANDROID_TOOLCHAIN=${TOOLCHAIN} \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
|
||||||
[additional CMake flags] {source_directory}
|
[additional CMake flags] {source_directory}
|
||||||
make
|
make
|
||||||
|
|
||||||
|
|
||||||
If building for Android 4.0.x (API level < 16) or earlier, remove
|
|
||||||
`-DCMAKE_POSITION_INDEPENDENT_CODE=1` from the CMake arguments and `-pie` from
|
|
||||||
`LDFLAGS`.
|
|
||||||
|
|
||||||
|
|
||||||
Advanced CMake Options
|
Advanced CMake Options
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|||||||
902
BUILDING.txt
Normal file
902
BUILDING.txt
Normal file
@@ -0,0 +1,902 @@
|
|||||||
|
*******************************************************************************
|
||||||
|
** Building on Un*x Platforms (including Cygwin and OS X)
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Build Requirements
|
||||||
|
==================
|
||||||
|
|
||||||
|
-- pkg-config
|
||||||
|
-- autoconf 2.56 or later
|
||||||
|
-- automake 1.7 or later
|
||||||
|
-- libtool 1.4 or later
|
||||||
|
* If using Xcode 4.3 or later on OS X, autoconf and automake are no longer
|
||||||
|
provided. The easiest way to obtain them is from MacPorts
|
||||||
|
(http://www.macports.org/).
|
||||||
|
|
||||||
|
-- NASM or YASM (if building x86 or x86-64 SIMD extensions)
|
||||||
|
* NASM 0.98, or 2.01 or later is required for an x86 build (0.99 and 2.00 do
|
||||||
|
not work properly with libjpeg-turbo's x86 SIMD code.)
|
||||||
|
* NASM 2.00 or later is required for an x86-64 build.
|
||||||
|
* NASM 2.07, or 2.11.09 or later is required for an x86-64 Mac build
|
||||||
|
(2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code when
|
||||||
|
building macho64 objects.) NASM or YASM can be obtained from MacPorts
|
||||||
|
(http://www.macports.org/).
|
||||||
|
|
||||||
|
The binary RPMs released by the NASM project do not work on older Linux
|
||||||
|
systems, such as Red Hat Enterprise Linux 4. On such systems, you can
|
||||||
|
easily build and install NASM from a source RPM by downloading one of the
|
||||||
|
SRPMs from
|
||||||
|
|
||||||
|
http://www.nasm.us/pub/nasm/releasebuilds
|
||||||
|
|
||||||
|
and executing the following as root:
|
||||||
|
|
||||||
|
ARCH=`uname -m`
|
||||||
|
rpmbuild --rebuild nasm-{version}.src.rpm
|
||||||
|
rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
|
||||||
|
|
||||||
|
NOTE: the NASM build will fail if texinfo is not installed.
|
||||||
|
|
||||||
|
-- GCC v4.1 or later recommended for best performance
|
||||||
|
* Beginning with Xcode 4, Apple stopped distributing GCC and switched to
|
||||||
|
the LLVM compiler. Xcode v4.0 through v4.6 provides a GCC front end
|
||||||
|
called LLVM-GCC. Unfortunately, as of this writing, neither LLVM-GCC nor
|
||||||
|
the LLVM (clang) compiler produces optimal performance with libjpeg-turbo.
|
||||||
|
Building mozjpeg with LLVM-GCC v4.2 results in a 10% performance
|
||||||
|
degradation when compressing using 64-bit code, relative to building
|
||||||
|
libjpeg-turbo with GCC v4.2. Building libjpeg-turbo with LLVM (clang)
|
||||||
|
results in a 20% performance degradation when compressing using 64-bit
|
||||||
|
code, relative to building libjpeg-turbo with GCC v4.2. If you are
|
||||||
|
running Snow Leopard or earlier, it is suggested that you continue to use
|
||||||
|
Xcode v3.2.6, which provides GCC v4.2. If you are using Lion or later, it
|
||||||
|
is suggested that you install Apple GCC v4.2 or GCC v5 through MacPorts.
|
||||||
|
|
||||||
|
-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
|
||||||
|
required. Some systems, such as Solaris 10 and later and Red Hat Enterprise
|
||||||
|
Linux 5 and later, have this pre-installed. On OS X 10.5 and later, it will
|
||||||
|
be necessary to install the Java Developer Package, which can be downloaded
|
||||||
|
from http://developer.apple.com/downloads (Apple ID required.) For systems
|
||||||
|
that do not have a JDK installed, you can obtain the Oracle Java Development
|
||||||
|
Kit from http://www.java.com.
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Out-of-Tree Builds
|
||||||
|
==================
|
||||||
|
|
||||||
|
Binary objects, libraries, and executables are generated in the same directory
|
||||||
|
from which configure was executed (the "binary directory"), and this directory
|
||||||
|
need not necessarily be the same as the mozjpeg source directory. You
|
||||||
|
can create multiple independent binary directories, in which different versions
|
||||||
|
of mozjpeg can be built from the same source tree using different
|
||||||
|
compilers or settings. In the sections below, {build_directory} refers to the
|
||||||
|
binary directory, whereas {source_directory} refers to the mozjpeg source
|
||||||
|
directory. For in-tree builds, these directories are the same.
|
||||||
|
|
||||||
|
|
||||||
|
================
|
||||||
|
Building mozjpeg
|
||||||
|
================
|
||||||
|
|
||||||
|
The following procedure will build mozjpeg on Linux, FreeBSD, Cygwin, and
|
||||||
|
Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below
|
||||||
|
for 64-bit build instructions.)
|
||||||
|
|
||||||
|
Simple Release tar.gz Source Build
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
cd {source_directory}
|
||||||
|
./configure [additional configure flags]
|
||||||
|
make
|
||||||
|
|
||||||
|
Non-Release Source Build (e.g. GitHub clone)
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
cd {source_directory}
|
||||||
|
autoreconf -fiv
|
||||||
|
cd {build_directory}
|
||||||
|
sh {source_directory}/configure [additional configure flags]
|
||||||
|
make
|
||||||
|
|
||||||
|
NOTE: Running autoreconf in the source directory is not necessary if building
|
||||||
|
mozjpeg from one of the official release tarballs.
|
||||||
|
|
||||||
|
This will generate the following files under .libs/
|
||||||
|
|
||||||
|
libjpeg.a
|
||||||
|
Static link library for the libjpeg API
|
||||||
|
|
||||||
|
libjpeg.so.{version} (Linux, Unix)
|
||||||
|
libjpeg.{version}.dylib (OS X)
|
||||||
|
cygjpeg-{version}.dll (Cygwin)
|
||||||
|
Shared library for the libjpeg API
|
||||||
|
|
||||||
|
By default, {version} is 62.2.0, 7.2.0, or 8.1.2, depending on whether
|
||||||
|
libjpeg v6b (default), v7, or v8 emulation is enabled. If using Cygwin,
|
||||||
|
{version} is 62, 7, or 8.
|
||||||
|
|
||||||
|
libjpeg.so (Linux, Unix)
|
||||||
|
libjpeg.dylib (OS X)
|
||||||
|
Development symlink for the libjpeg API
|
||||||
|
|
||||||
|
libjpeg.dll.a (Cygwin)
|
||||||
|
Import library for the libjpeg API
|
||||||
|
|
||||||
|
libturbojpeg.a
|
||||||
|
Static link library for the TurboJPEG API
|
||||||
|
|
||||||
|
libturbojpeg.so.0.1.0 (Linux, Unix)
|
||||||
|
libturbojpeg.0.1.0.dylib (OS X)
|
||||||
|
cygturbojpeg-0.dll (Cygwin)
|
||||||
|
Shared library for the TurboJPEG API
|
||||||
|
|
||||||
|
libturbojpeg.so (Linux, Unix)
|
||||||
|
libturbojpeg.dylib (OS X)
|
||||||
|
Development symlink for the TurboJPEG API
|
||||||
|
|
||||||
|
libturbojpeg.dll.a (Cygwin)
|
||||||
|
Import library for the TurboJPEG API
|
||||||
|
|
||||||
|
|
||||||
|
libjpeg v7 or v8 API/ABI Emulation
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Add --with-jpeg7 to the configure command line to build a version of
|
||||||
|
mozjpeg that is API/ABI-compatible with libjpeg v7. Add --with-jpeg8 to
|
||||||
|
the configure command to build a version of mozjpeg that is
|
||||||
|
API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
|
||||||
|
on libjpeg v7 and v8 emulation.
|
||||||
|
|
||||||
|
|
||||||
|
In-Memory Source/Destination Managers
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
When using libjpeg v6b or v7 API/ABI emulation, add --without-mem-srcdst to the
|
||||||
|
configure command line to build a version of mozjpeg that lacks the
|
||||||
|
jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
|
||||||
|
the original libjpeg v6b and v7 APIs, so removing them ensures strict
|
||||||
|
conformance with those APIs. See README-turbo.txt for more information.
|
||||||
|
|
||||||
|
|
||||||
|
Arithmetic Coding Support
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Since the patent on arithmetic coding has expired, this functionality has been
|
||||||
|
included in this release of mozjpeg. mozjpeg's implementation is
|
||||||
|
based on the implementation in libjpeg v8, but it works when emulating libjpeg
|
||||||
|
v7 or v6b as well. The default is to enable both arithmetic encoding and
|
||||||
|
decoding, but those who have philosophical objections to arithmetic coding can
|
||||||
|
add --without-arith-enc or --without-arith-dec to the configure command line to
|
||||||
|
disable encoding or decoding (respectively.)
|
||||||
|
|
||||||
|
|
||||||
|
TurboJPEG Java Wrapper
|
||||||
|
----------------------
|
||||||
|
Add --with-java to the configure command line to incorporate an optional Java
|
||||||
|
Native Interface wrapper into the TurboJPEG shared library and build the Java
|
||||||
|
front-end classes to support it. This allows the TurboJPEG shared library to
|
||||||
|
be used directly from Java applications. See java/README for more details.
|
||||||
|
|
||||||
|
You can set the JAVAC, JAR, and JAVA configure variables to specify
|
||||||
|
alternate commands for javac, jar, and java (respectively.) You can also
|
||||||
|
set the JAVACFLAGS configure variable to specify arguments that should be
|
||||||
|
passed to the Java compiler when building the front-end classes, and JNI_CFLAGS
|
||||||
|
to specify arguments that should be passed to the C compiler when building the
|
||||||
|
JNI wrapper. Run 'configure --help' for more details.
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Installing mozjpeg
|
||||||
|
==================
|
||||||
|
|
||||||
|
If you intend to install these libraries and the associated header files, then
|
||||||
|
replace 'make' in the instructions above with
|
||||||
|
|
||||||
|
make install prefix={base dir} libdir={library directory}
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
make install prefix=/usr/local libdir=/usr/local/lib64
|
||||||
|
|
||||||
|
will install the header files in /usr/local/include and the library files in
|
||||||
|
/usr/local/lib64. If 'prefix' and 'libdir' are not specified, then the default
|
||||||
|
is to install the header files in /opt/mozjpeg/include and the library
|
||||||
|
files in /opt/mozjpeg/lib32 (32-bit) or /opt/mozjpeg/lib64
|
||||||
|
(64-bit.)
|
||||||
|
|
||||||
|
NOTE: You can specify a prefix of /usr and a libdir of, for instance,
|
||||||
|
/usr/lib64 to overwrite the system's version of libjpeg. If you do this,
|
||||||
|
however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
|
||||||
|
overwriting it. It is recommended that you instead install mozjpeg into
|
||||||
|
a non-system directory and manipulate the LD_LIBRARY_PATH or create symlinks
|
||||||
|
to force applications to use mozjpeg instead of libjpeg. See
|
||||||
|
README-turbo.txt for more information.
|
||||||
|
|
||||||
|
|
||||||
|
=============
|
||||||
|
Build Recipes
|
||||||
|
=============
|
||||||
|
|
||||||
|
|
||||||
|
32-bit Build on 64-bit Linux
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
64-bit Build on 64-bit OS X
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm
|
||||||
|
|
||||||
|
to the configure command line. NASM 2.07 or later from MacPorts must be
|
||||||
|
installed.
|
||||||
|
|
||||||
|
|
||||||
|
32-bit Build on 64-bit OS X
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
64-bit Backward-Compatible Build on 64-bit OS X
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
|
||||||
|
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
|
||||||
|
-mmacosx-version-min=10.5 -O3' \
|
||||||
|
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
|
||||||
|
-mmacosx-version-min=10.5'
|
||||||
|
|
||||||
|
to the configure command line. The OS X 10.5 SDK, and NASM 2.07 or later from
|
||||||
|
MacPorts, must be installed.
|
||||||
|
|
||||||
|
|
||||||
|
32-bit Backward-Compatible Build on OS X
|
||||||
|
----------------------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host i686-apple-darwin \
|
||||||
|
CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
|
||||||
|
-mmacosx-version-min=10.5 -O3 -m32' \
|
||||||
|
LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
|
||||||
|
-mmacosx-version-min=10.5 -m32'
|
||||||
|
|
||||||
|
to the configure command line. The OS X 10.5 SDK must be installed.
|
||||||
|
|
||||||
|
|
||||||
|
64-bit Library Build on 64-bit Solaris
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
32-bit Build on 64-bit FreeBSD
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
--host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
|
||||||
|
LDFLAGS='-B/usr/lib32'
|
||||||
|
|
||||||
|
to the configure command line. NASM 2.07 or later from FreeBSD ports must be
|
||||||
|
installed.
|
||||||
|
|
||||||
|
|
||||||
|
Oracle Solaris Studio
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Add
|
||||||
|
|
||||||
|
CC=cc
|
||||||
|
|
||||||
|
to the configure command line. mozjpeg will automatically be built with
|
||||||
|
the maximum optimization level (-xO5) unless you override CFLAGS.
|
||||||
|
|
||||||
|
To build a 64-bit version of mozjpeg using Oracle Solaris Studio, add
|
||||||
|
|
||||||
|
--host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
MinGW Build on Cygwin
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Use CMake (see recipes below)
|
||||||
|
|
||||||
|
|
||||||
|
===========
|
||||||
|
ARM Support
|
||||||
|
===========
|
||||||
|
|
||||||
|
This release of mozjpeg can use ARM NEON SIMD instructions to accelerate
|
||||||
|
JPEG compression/decompression by approximately 2-4x on ARMv7 and later
|
||||||
|
platforms. If mozjpeg is configured on an ARM Linux platform, then the
|
||||||
|
build system will automatically include the NEON SIMD routines, if they are
|
||||||
|
supported. Build instructions for other ARM-based platforms follow.
|
||||||
|
|
||||||
|
|
||||||
|
Building mozjpeg for iOS
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
|
||||||
|
support NEON instructions. Additional steps are required in order to build
|
||||||
|
mozjpeg for these platforms.
|
||||||
|
|
||||||
|
Additional build requirements:
|
||||||
|
|
||||||
|
gas-preprocessor.pl
|
||||||
|
(https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl)
|
||||||
|
should be installed in your PATH.
|
||||||
|
|
||||||
|
|
||||||
|
ARM 32-bit Build (Xcode 4.6.x and earlier, LLVM-GCC):
|
||||||
|
|
||||||
|
Set the following shell variables for simplicity:
|
||||||
|
|
||||||
|
Xcode 4.2 and earlier:
|
||||||
|
IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform
|
||||||
|
Xcode 4.3 and later:
|
||||||
|
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
|
||||||
|
|
||||||
|
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
|
||||||
|
IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
|
||||||
|
|
||||||
|
ARMv6 (code will run on all iOS devices, not SIMD-accelerated):
|
||||||
|
[NOTE: Requires Xcode 4.4.x or earlier]
|
||||||
|
IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
|
||||||
|
|
||||||
|
ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
|
||||||
|
IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
|
||||||
|
|
||||||
|
ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
|
||||||
|
[NOTE: Requires Xcode 4.5 or later]
|
||||||
|
IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
|
||||||
|
|
||||||
|
Follow the procedure under "Building mozjpeg" above, adding
|
||||||
|
|
||||||
|
--host arm-apple-darwin10 \
|
||||||
|
CC="$IOS_GCC" LD="$IOS_GCC" \
|
||||||
|
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
|
||||||
|
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS"
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
ARM 32-bit Build (Xcode 5.0.x and later, Clang):
|
||||||
|
|
||||||
|
Set the following shell variables for simplicity:
|
||||||
|
|
||||||
|
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
|
||||||
|
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
|
||||||
|
IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
|
||||||
|
|
||||||
|
ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
|
||||||
|
IOS_CFLAGS="-arch armv7"
|
||||||
|
|
||||||
|
ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
|
||||||
|
IOS_CFLAGS="-arch armv7s"
|
||||||
|
|
||||||
|
Follow the procedure under "Building libjpeg-turbo" above, adding
|
||||||
|
|
||||||
|
--host arm-apple-darwin10 \
|
||||||
|
CC="$IOS_GCC" LD="$IOS_GCC" \
|
||||||
|
CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
|
||||||
|
LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" \
|
||||||
|
CCASFLAGS="-no-integrated-as $IOS_CFLAGS"
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
ARMv8 64-bit Build (Xcode 5.0.x and later, Clang):
|
||||||
|
|
||||||
|
Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
|
||||||
|
|
||||||
|
Set the following shell variables for simplicity:
|
||||||
|
|
||||||
|
IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
|
||||||
|
IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
|
||||||
|
IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
|
||||||
|
IOS_CFLAGS="-arch arm64"
|
||||||
|
|
||||||
|
Follow the procedure under "Building libjpeg-turbo" above, adding
|
||||||
|
|
||||||
|
--host aarch64-apple-darwin \
|
||||||
|
CC="$IOS_GCC" LD="$IOS_GCC" \
|
||||||
|
CFLAGS="-isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
|
||||||
|
LDFLAGS="-isysroot $IOS_SYSROOT $IOS_CFLAGS"
|
||||||
|
|
||||||
|
to the configure command line.
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: You can also add -miphoneos-version-min={version} to $IOS_CFLAGS above
|
||||||
|
in order to support older versions of iOS than the default version supported by
|
||||||
|
the SDK.
|
||||||
|
|
||||||
|
Once built, lipo can be used to combine the ARMv6, v7, v7s, and/or v8 variants
|
||||||
|
into a universal library.
|
||||||
|
|
||||||
|
|
||||||
|
Building libjpeg-turbo for Android
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Building libjpeg-turbo for Android platforms requires the Android NDK
|
||||||
|
(https://developer.android.com/tools/sdk/ndk) and autotools. The following is
|
||||||
|
a general recipe script that can be modified for your specific needs.
|
||||||
|
|
||||||
|
# Set these variables to suit your needs
|
||||||
|
NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
|
||||||
|
BUILD_PLATFORM={the platform name for the NDK package you installed--
|
||||||
|
for example, "windows-x86" or "linux-x86_64" or "darwin-x86_64"}
|
||||||
|
TOOLCHAIN_VERSION={"4.8", "4.9", "clang3.5", etc. This corresponds to a
|
||||||
|
toolchain directory under ${NDK_PATH}/toolchains/.}
|
||||||
|
ANDROID_VERSION={The minimum version of Android to support-- for example,
|
||||||
|
"16", "19", etc. "21" or later is required for a 64-bit build.}
|
||||||
|
|
||||||
|
# 32-bit ARMv7 build
|
||||||
|
HOST=arm-linux-androideabi
|
||||||
|
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
|
||||||
|
ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
|
||||||
|
--sysroot=${SYSROOT}"
|
||||||
|
|
||||||
|
# 64-bit ARMv8 build
|
||||||
|
HOST=aarch64-linux-android
|
||||||
|
SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm64
|
||||||
|
ANDROID_CFLAGS="--sysroot=${SYSROOT}"
|
||||||
|
|
||||||
|
TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
|
||||||
|
ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
|
||||||
|
export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
|
||||||
|
export AR=${TOOLCHAIN}/bin/${HOST}-ar
|
||||||
|
export AS=${TOOLCHAIN}/bin/${HOST}-as
|
||||||
|
export NM=${TOOLCHAIN}/bin/${HOST}-nm
|
||||||
|
export CC=${TOOLCHAIN}/bin/${HOST}-gcc
|
||||||
|
export LD=${TOOLCHAIN}/bin/${HOST}-ld
|
||||||
|
export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
|
||||||
|
export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
|
||||||
|
export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
|
||||||
|
cd {build_directory}
|
||||||
|
sh {source_directory}/configure --host=${HOST} \
|
||||||
|
CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3 -fPIE" \
|
||||||
|
CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
|
||||||
|
LDFLAGS="${ANDROID_CFLAGS} -pie" --with-simd ${1+"$@"}
|
||||||
|
make
|
||||||
|
|
||||||
|
If building for Android 4.0.x (API level < 16) or earlier, remove -fPIE from
|
||||||
|
CFLAGS and -pie from LDFLAGS.
|
||||||
|
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
** Building on Windows (Visual C++ or MinGW)
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Build Requirements
|
||||||
|
==================
|
||||||
|
|
||||||
|
-- CMake (http://www.cmake.org) v2.8.8 or later
|
||||||
|
|
||||||
|
-- Microsoft Visual C++ 2005 or later
|
||||||
|
|
||||||
|
If you don't already have Visual C++, then the easiest way to get it is by
|
||||||
|
installing the Windows SDK:
|
||||||
|
|
||||||
|
http://msdn.microsoft.com/en-us/windows/bb980924.aspx
|
||||||
|
|
||||||
|
The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
|
||||||
|
everything necessary to build mozjpeg.
|
||||||
|
|
||||||
|
* You can also use Microsoft Visual Studio Express Edition, which is a free
|
||||||
|
download. (NOTE: versions prior to 2012 can only be used to build 32-bit
|
||||||
|
code.)
|
||||||
|
* If you intend to build mozjpeg from the command line, then add the
|
||||||
|
appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
|
||||||
|
environment variables. This is generally accomplished by executing
|
||||||
|
vcvars32.bat or vcvars64.bat and SetEnv.cmd. vcvars32.bat and
|
||||||
|
vcvars64.bat are part of Visual C++ and are located in the same directory
|
||||||
|
as the compiler. SetEnv.cmd is part of the Windows SDK. You can pass
|
||||||
|
optional arguments to SetEnv.cmd to specify a 32-bit or 64-bit build
|
||||||
|
environment.
|
||||||
|
|
||||||
|
... OR ...
|
||||||
|
|
||||||
|
-- MinGW
|
||||||
|
|
||||||
|
MinGW-builds (http://sourceforge.net/projects/mingwbuilds/) or
|
||||||
|
tdm-gcc (http://tdm-gcc.tdragon.net/) recommended if building on a Windows
|
||||||
|
machine. Both distributions install a Start Menu link that can be used to
|
||||||
|
launch a command prompt with the appropriate compiler paths automatically
|
||||||
|
set.
|
||||||
|
|
||||||
|
-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
|
||||||
|
a 64-bit build)
|
||||||
|
|
||||||
|
-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required. This
|
||||||
|
can be downloaded from http://www.java.com.
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Out-of-Tree Builds
|
||||||
|
==================
|
||||||
|
|
||||||
|
Binary objects, libraries, and executables are generated in the same directory
|
||||||
|
from which cmake was executed (the "binary directory"), and this directory need
|
||||||
|
not necessarily be the same as the mozjpeg source directory. You can
|
||||||
|
create multiple independent binary directories, in which different versions of
|
||||||
|
mozjpeg can be built from the same source tree using different compilers
|
||||||
|
or settings. In the sections below, {build_directory} refers to the binary
|
||||||
|
directory, whereas {source_directory} refers to the mozjpeg source
|
||||||
|
directory. For in-tree builds, these directories are the same.
|
||||||
|
|
||||||
|
|
||||||
|
================
|
||||||
|
Building mozjpeg
|
||||||
|
================
|
||||||
|
|
||||||
|
|
||||||
|
Visual C++ (Command Line)
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
|
||||||
|
nmake
|
||||||
|
|
||||||
|
This will build either a 32-bit or a 64-bit version of mozjpeg, depending
|
||||||
|
on which version of cl.exe is in the PATH.
|
||||||
|
|
||||||
|
The following files will be generated under {build_directory}:
|
||||||
|
|
||||||
|
jpeg-static.lib
|
||||||
|
Static link library for the libjpeg API
|
||||||
|
sharedlib/jpeg{version}.dll
|
||||||
|
DLL for the libjpeg API
|
||||||
|
sharedlib/jpeg.lib
|
||||||
|
Import library for the libjpeg API
|
||||||
|
turbojpeg-static.lib
|
||||||
|
Static link library for the TurboJPEG API
|
||||||
|
turbojpeg.dll
|
||||||
|
DLL for the TurboJPEG API
|
||||||
|
turbojpeg.lib
|
||||||
|
Import library for the TurboJPEG API
|
||||||
|
|
||||||
|
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
|
||||||
|
v8 emulation is enabled.
|
||||||
|
|
||||||
|
|
||||||
|
Visual C++ (IDE)
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Choose the appropriate CMake generator option for your version of Visual Studio
|
||||||
|
(run "cmake" with no arguments for a list of available generators.) For
|
||||||
|
instance:
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
cmake -G "Visual Studio 10" {source_directory}
|
||||||
|
|
||||||
|
NOTE: Add "Win64" to the generator name (for example, "Visual Studio 10
|
||||||
|
Win64") to build a 64-bit version of libjpeg-turbo. Recent versions of CMake
|
||||||
|
no longer document that. A separate build directory must be used for 32-bit
|
||||||
|
and 64-bit builds.
|
||||||
|
|
||||||
|
You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
|
||||||
|
configurations in that project ("Debug", "Release", etc.) to generate a full
|
||||||
|
build of mozjpeg.
|
||||||
|
|
||||||
|
This will generate the following files under {build_directory}:
|
||||||
|
|
||||||
|
{configuration}/jpeg-static.lib
|
||||||
|
Static link library for the libjpeg API
|
||||||
|
sharedlib/{configuration}/jpeg{version}.dll
|
||||||
|
DLL for the libjpeg API
|
||||||
|
sharedlib/{configuration}/jpeg.lib
|
||||||
|
Import library for the libjpeg API
|
||||||
|
{configuration}/turbojpeg-static.lib
|
||||||
|
Static link library for the TurboJPEG API
|
||||||
|
{configuration}/turbojpeg.dll
|
||||||
|
DLL for the TurboJPEG API
|
||||||
|
{configuration}/turbojpeg.lib
|
||||||
|
Import library for the TurboJPEG API
|
||||||
|
|
||||||
|
{configuration} is Debug, Release, RelWithDebInfo, or MinSizeRel, depending on
|
||||||
|
the configuration you built in the IDE, and {version} is 62, 7, or 8,
|
||||||
|
depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
|
||||||
|
|
||||||
|
|
||||||
|
MinGW
|
||||||
|
-----
|
||||||
|
|
||||||
|
NOTE: This assumes that you are building on a Windows machine. If you are
|
||||||
|
cross-compiling on a Linux/Unix machine, then see "Build Recipes" below.
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
cmake -G "MinGW Makefiles" {source_directory}
|
||||||
|
mingw32-make
|
||||||
|
|
||||||
|
This will generate the following files under {build_directory}
|
||||||
|
|
||||||
|
libjpeg.a
|
||||||
|
Static link library for the libjpeg API
|
||||||
|
sharedlib/libjpeg-{version}.dll
|
||||||
|
DLL for the libjpeg API
|
||||||
|
sharedlib/libjpeg.dll.a
|
||||||
|
Import library for the libjpeg API
|
||||||
|
libturbojpeg.a
|
||||||
|
Static link library for the TurboJPEG API
|
||||||
|
libturbojpeg.dll
|
||||||
|
DLL for the TurboJPEG API
|
||||||
|
libturbojpeg.dll.a
|
||||||
|
Import library for the TurboJPEG API
|
||||||
|
|
||||||
|
{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
|
||||||
|
v8 emulation is enabled.
|
||||||
|
|
||||||
|
|
||||||
|
Debug Build
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Add "-DCMAKE_BUILD_TYPE=Debug" to the cmake command line. Or, if building with
|
||||||
|
NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
|
||||||
|
NMake.)
|
||||||
|
|
||||||
|
|
||||||
|
libjpeg v7 or v8 API/ABI Emulation
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
|
||||||
|
mozjpeg that is API/ABI-compatible with libjpeg v7. Add "-DWITH_JPEG8=1"
|
||||||
|
to the cmake command to build a version of mozjpeg that is
|
||||||
|
API/ABI-compatible with libjpeg v8. See README-turbo.txt for more information
|
||||||
|
on libjpeg v7 and v8 emulation.
|
||||||
|
|
||||||
|
|
||||||
|
In-Memory Source/Destination Managers
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
When using libjpeg v6b or v7 API/ABI emulation, add -DWITH_MEM_SRCDST=0 to the
|
||||||
|
CMake command line to build a version of mozjpeg that lacks the
|
||||||
|
jpeg_mem_src() and jpeg_mem_dest() functions. These functions were not part of
|
||||||
|
the original libjpeg v6b and v7 APIs, so removing them ensures strict
|
||||||
|
conformance with those APIs. See README-turbo.txt for more information.
|
||||||
|
|
||||||
|
|
||||||
|
Arithmetic Coding Support
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Since the patent on arithmetic coding has expired, this functionality has been
|
||||||
|
included in this release of mozjpeg. mozjpeg's implementation is
|
||||||
|
based on the implementation in libjpeg v8, but it works when emulating libjpeg
|
||||||
|
v7 or v6b as well. The default is to enable both arithmetic encoding and
|
||||||
|
decoding, but those who have philosophical objections to arithmetic coding can
|
||||||
|
add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
|
||||||
|
disable encoding or decoding (respectively.)
|
||||||
|
|
||||||
|
|
||||||
|
TurboJPEG Java Wrapper
|
||||||
|
----------------------
|
||||||
|
Add "-DWITH_JAVA=1" to the cmake command line to incorporate an optional Java
|
||||||
|
Native Interface wrapper into the TurboJPEG shared library and build the Java
|
||||||
|
front-end classes to support it. This allows the TurboJPEG shared library to
|
||||||
|
be used directly from Java applications. See java/README for more details.
|
||||||
|
|
||||||
|
If you are using CMake 2.8, you can set the Java_JAVAC_EXECUTABLE,
|
||||||
|
Java_JAVA_EXECUTABLE, and Java_JAR_EXECUTABLE CMake variables to specify
|
||||||
|
alternate commands or locations for javac, jar, and java (respectively.) If
|
||||||
|
you are using CMake 2.6, set JAVA_COMPILE, JAVA_RUNTIME, and JAVA_ARCHIVE
|
||||||
|
instead. You can also set the JAVACFLAGS CMake variable to specify arguments
|
||||||
|
that should be passed to the Java compiler when building the front-end classes.
|
||||||
|
|
||||||
|
|
||||||
|
==================
|
||||||
|
Installing mozjpeg
|
||||||
|
==================
|
||||||
|
|
||||||
|
You can use the build system to install mozjpeg into a directory of your
|
||||||
|
choosing (as opposed to creating an installer.) To do this, add:
|
||||||
|
|
||||||
|
-DCMAKE_INSTALL_PREFIX={install_directory}
|
||||||
|
|
||||||
|
to the cmake command line.
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=c:\mozjpeg {source_directory}
|
||||||
|
nmake install
|
||||||
|
|
||||||
|
will install the header files in c:\mozjpeg\include, the library files
|
||||||
|
in c:\mozjpeg\lib, the DLL's in c:\mozjpeg\bin, and the
|
||||||
|
documentation in c:\mozjpeg\doc.
|
||||||
|
|
||||||
|
|
||||||
|
=============
|
||||||
|
Build Recipes
|
||||||
|
=============
|
||||||
|
|
||||||
|
|
||||||
|
64-bit MinGW Build on Cygwin
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
CC=/usr/bin/x86_64-w64-mingw32-gcc \
|
||||||
|
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||||
|
-DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \
|
||||||
|
{source_directory}
|
||||||
|
make
|
||||||
|
|
||||||
|
This produces a 64-bit build of mozjpeg that does not depend on
|
||||||
|
cygwin1.dll or other Cygwin DLL's. The mingw64-x86_64-gcc-core and
|
||||||
|
mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
|
||||||
|
|
||||||
|
|
||||||
|
32-bit MinGW Build on Cygwin
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
CC=/usr/bin/i686-w64-mingw32-gcc \
|
||||||
|
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||||
|
-DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \
|
||||||
|
{source_directory}
|
||||||
|
make
|
||||||
|
|
||||||
|
This produces a 32-bit build of mozjpeg that does not depend on
|
||||||
|
cygwin1.dll or other Cygwin DLL's. The mingw64-i686-gcc-core and
|
||||||
|
mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
|
||||||
|
|
||||||
|
|
||||||
|
MinGW Build on Linux
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
CC={mingw_binary_path}/i386-mingw32-gcc \
|
||||||
|
cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
|
||||||
|
-DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
|
||||||
|
-DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
|
||||||
|
{source_directory}
|
||||||
|
make
|
||||||
|
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
** Creating Release Packages
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
The following commands can be used to create various types of release packages:
|
||||||
|
|
||||||
|
|
||||||
|
Unix/Linux
|
||||||
|
----------
|
||||||
|
|
||||||
|
make rpm
|
||||||
|
|
||||||
|
Create Red Hat-style binary RPM package. Requires RPM v4 or later.
|
||||||
|
|
||||||
|
make srpm
|
||||||
|
|
||||||
|
This runs 'make dist' to create a pristine source tarball, then creates a
|
||||||
|
Red Hat-style source RPM package from the tarball. Requires RPM v4 or later.
|
||||||
|
|
||||||
|
make deb
|
||||||
|
|
||||||
|
Create Debian-style binary package. Requires dpkg.
|
||||||
|
|
||||||
|
make dmg
|
||||||
|
|
||||||
|
Create Macintosh package/disk image. This requires pkgbuild and
|
||||||
|
productbuild, which are installed by default on OS X 10.7 and later and which
|
||||||
|
can be obtained by installing Xcode 3.2.6 (with the "Unix Development"
|
||||||
|
option) on OS X 10.6. Packages built in this manner can be installed on OS X
|
||||||
|
10.5 and later, but they must be built on OS X 10.6 or later.
|
||||||
|
|
||||||
|
make udmg [BUILDDIR32={32-bit build directory}]
|
||||||
|
|
||||||
|
On 64-bit OS X systems, this creates a Macintosh package and disk image that
|
||||||
|
contains universal i386/x86-64 binaries. You should first configure a 32-bit
|
||||||
|
out-of-tree build of mozjpeg, then configure a 64-bit out-of-tree
|
||||||
|
build, then run 'make udmg' from the 64-bit build directory. The build
|
||||||
|
system will look for the 32-bit build under {source_directory}/osxx86 by
|
||||||
|
default, but you can override this by setting the BUILDDIR32 variable on the
|
||||||
|
make command line as shown above.
|
||||||
|
|
||||||
|
make iosdmg [BUILDDIR32={32-bit build directory}] \
|
||||||
|
[BUILDDIRARMV6={ARMv6 build directory}] \
|
||||||
|
[BUILDDIRARMV7={ARMv7 build directory}] \
|
||||||
|
[BUILDDIRARMV7S={ARMv7s build directory}] \
|
||||||
|
[BUILDDIRARMV8={ARMv8 build directory}]
|
||||||
|
|
||||||
|
On OS X systems, this creates a Macintosh package and disk image in which the
|
||||||
|
mozjpeg static libraries contain ARM architectures necessary to build
|
||||||
|
iOS applications. If building on an x86-64 system, the binaries will also
|
||||||
|
contain the i386 architecture, as with 'make udmg' above. You should first
|
||||||
|
configure ARMv6, ARMv7, ARMv7s, and/or ARMv8 out-of-tree builds of
|
||||||
|
mozjpeg (see "Building mozjpeg for iOS" above.) If you are
|
||||||
|
building an x86-64 version of mozjpeg, you should configure a 32-bit
|
||||||
|
out-of-tree build as well. Next, build mozjpeg as you would normally,
|
||||||
|
using an out-of-tree build. When it is built, run 'make iosdmg' from the
|
||||||
|
build directory. The build system will look for the ARMv6 build under
|
||||||
|
{source_directory}/iosarmv6 by default, the ARMv7 build under
|
||||||
|
{source_directory}/iosarmv7 by default, the ARMv7s build under
|
||||||
|
{source_directory}/iosarmv7s by default, the ARMv8 build under
|
||||||
|
{source_directory}/iosarmv8 by default, and (if applicable) the 32-bit build
|
||||||
|
under {source_directory}/osxx86 by default, but you can override this by
|
||||||
|
setting the BUILDDIR32, BUILDDIRARMV6, BUILDDIRARMV7, BUILDDIRARMV7S, and/or
|
||||||
|
BUILDDIRARMV8 variables on the make command line as shown above.
|
||||||
|
|
||||||
|
NOTE: If including an ARMv8 build in the package, then you may need to use
|
||||||
|
Xcode's version of lipo instead of the operating system's. To do this, pass
|
||||||
|
an argument of LIPO="xcrun lipo" on the make command line.
|
||||||
|
|
||||||
|
make cygwinpkg
|
||||||
|
|
||||||
|
Build a Cygwin binary package.
|
||||||
|
|
||||||
|
|
||||||
|
Windows
|
||||||
|
-------
|
||||||
|
|
||||||
|
If using NMake:
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
nmake installer
|
||||||
|
|
||||||
|
If using MinGW:
|
||||||
|
|
||||||
|
cd {build_directory}
|
||||||
|
make installer
|
||||||
|
|
||||||
|
If using the Visual Studio IDE, build the "installer" project.
|
||||||
|
|
||||||
|
The installer package (mozjpeg[-gcc][64].exe) will be located under
|
||||||
|
{build_directory}. If building using the Visual Studio IDE, then the installer
|
||||||
|
package will be located in a subdirectory with the same name as the
|
||||||
|
configuration you built (such as {build_directory}\Debug\ or
|
||||||
|
{build_directory}\Release\).
|
||||||
|
|
||||||
|
Building a Windows installer requires the Nullsoft Install System
|
||||||
|
(http://nsis.sourceforge.net/.) makensis.exe should be in your PATH.
|
||||||
|
|
||||||
|
|
||||||
|
*******************************************************************************
|
||||||
|
** Regression testing
|
||||||
|
*******************************************************************************
|
||||||
|
|
||||||
|
The most common way to test mozjpeg is by invoking 'make test' on
|
||||||
|
Unix/Linux platforms or 'ctest' on Windows platforms, once the build has
|
||||||
|
completed. This runs a series of tests to ensure that mathematical
|
||||||
|
compatibility has been maintained. This also invokes the TurboJPEG unit tests,
|
||||||
|
which ensure that the colorspace extensions, YUV encoding, decompression
|
||||||
|
scaling, and other features of the TurboJPEG C and Java APIs are working
|
||||||
|
properly (and, by extension, that the equivalent features of the underlying
|
||||||
|
libjpeg API are also working.)
|
||||||
|
|
||||||
|
Invoking 'make testclean' or 'nmake testclean' (if using NMake) or building
|
||||||
|
the 'testclean' target (if using the Visual Studio IDE) will clean up the
|
||||||
|
output images generated by 'make test'.
|
||||||
|
|
||||||
|
On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
|
||||||
|
wrappers can be run by invoking 'make tjtest'. These extended TurboJPEG tests
|
||||||
|
essentially iterate through all of the available features of the TurboJPEG APIs
|
||||||
|
that are not covered by the TurboJPEG unit tests (this includes the lossless
|
||||||
|
transform options) and compare the images generated by each feature to images
|
||||||
|
generated using the equivalent feature in the libjpeg API. The extended
|
||||||
|
TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
|
||||||
|
not in the underlying libjpeg API library.
|
||||||
4
Brewfile
4
Brewfile
@@ -1,4 +0,0 @@
|
|||||||
brew 'yasm'
|
|
||||||
brew 'gcc@5'
|
|
||||||
brew 'md5sha1sum'
|
|
||||||
cask 'Caskroom/versions/java6'
|
|
||||||
227
CMakeLists.txt
227
CMakeLists.txt
@@ -1,7 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
project(libjpeg-turbo C)
|
if(CMAKE_EXECUTABLE_SUFFIX)
|
||||||
set(VERSION 1.5.90)
|
set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(mozjpeg C)
|
||||||
|
set(VERSION 4.0.1)
|
||||||
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
|
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
|
||||||
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
|
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
|
||||||
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
|
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
|
||||||
@@ -105,8 +109,6 @@ endif()
|
|||||||
|
|
||||||
include(cmakescripts/GNUInstallDirs.cmake)
|
include(cmakescripts/GNUInstallDirs.cmake)
|
||||||
|
|
||||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
|
|
||||||
|
|
||||||
macro(report_directory var)
|
macro(report_directory var)
|
||||||
if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
|
if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
|
||||||
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
|
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
|
||||||
@@ -143,11 +145,13 @@ option(ENABLE_STATIC "Build static libraries" TRUE)
|
|||||||
boolean_number(ENABLE_STATIC)
|
boolean_number(ENABLE_STATIC)
|
||||||
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
|
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
|
||||||
boolean_number(REQUIRE_SIMD)
|
boolean_number(REQUIRE_SIMD)
|
||||||
|
option(PNG_SUPPORTED "Enable PNG support (requires libpng)" TRUE)
|
||||||
|
boolean_number(PNG_SUPPORTED)
|
||||||
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE)
|
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE)
|
||||||
boolean_number(WITH_12BIT)
|
boolean_number(WITH_12BIT)
|
||||||
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
|
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" FALSE)
|
||||||
boolean_number(WITH_ARITH_DEC)
|
boolean_number(WITH_ARITH_DEC)
|
||||||
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
|
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" FALSE)
|
||||||
boolean_number(WITH_ARITH_ENC)
|
boolean_number(WITH_ARITH_ENC)
|
||||||
option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
|
option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
|
||||||
boolean_number(WITH_JAVA)
|
boolean_number(WITH_JAVA)
|
||||||
@@ -187,6 +191,10 @@ endif()
|
|||||||
report_option(ENABLE_SHARED "Shared libraries")
|
report_option(ENABLE_SHARED "Shared libraries")
|
||||||
report_option(ENABLE_STATIC "Static libraries")
|
report_option(ENABLE_STATIC "Static libraries")
|
||||||
|
|
||||||
|
if(ENABLE_SHARED)
|
||||||
|
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WITH_12BIT)
|
if(WITH_12BIT)
|
||||||
set(WITH_ARITH_DEC 0)
|
set(WITH_ARITH_DEC 0)
|
||||||
set(WITH_ARITH_ENC 0)
|
set(WITH_ARITH_ENC 0)
|
||||||
@@ -351,6 +359,9 @@ if(SIZE_T EQUAL UNSIGNED_LONG)
|
|||||||
check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
|
check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
|
||||||
HAVE_BUILTIN_CTZL)
|
HAVE_BUILTIN_CTZL)
|
||||||
endif()
|
endif()
|
||||||
|
if(MSVC)
|
||||||
|
check_include_files("intrin.h" HAVE_INTRIN_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
# Check for headers
|
# Check for headers
|
||||||
@@ -360,9 +371,9 @@ if(UNIX)
|
|||||||
check_include_files(sys/types.h NEED_SYS_TYPES_H)
|
check_include_files(sys/types.h NEED_SYS_TYPES_H)
|
||||||
|
|
||||||
# Check for functions
|
# Check for functions
|
||||||
include(CheckFunctionExists)
|
include(CheckSymbolExists)
|
||||||
check_function_exists(memset HAVE_MEMSET)
|
check_symbol_exists(memset string.h HAVE_MEMSET)
|
||||||
check_function_exists(memcpy HAVE_MEMCPY)
|
check_symbol_exists(memcpy string.h HAVE_MEMCPY)
|
||||||
if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
|
if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
|
||||||
set(NEED_BSD_STRINGS 1)
|
set(NEED_BSD_STRINGS 1)
|
||||||
endif()
|
endif()
|
||||||
@@ -372,7 +383,7 @@ if(UNIX)
|
|||||||
check_type_size("unsigned short" UNSIGNED_SHORT)
|
check_type_size("unsigned short" UNSIGNED_SHORT)
|
||||||
|
|
||||||
# Check for compiler features
|
# Check for compiler features
|
||||||
check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr; }"
|
check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr; undef_struct_ptr ptr = 0; return ptr != 0; }"
|
||||||
INCOMPLETE_TYPES)
|
INCOMPLETE_TYPES)
|
||||||
if(INCOMPLETE_TYPES)
|
if(INCOMPLETE_TYPES)
|
||||||
message(STATUS "Compiler supports pointers to undefined structures.")
|
message(STATUS "Compiler supports pointers to undefined structures.")
|
||||||
@@ -415,7 +426,6 @@ if(UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
check_include_files("intrin.h" HAVE_INTRIN_H)
|
|
||||||
set(INLINE_OPTIONS "__inline;inline")
|
set(INLINE_OPTIONS "__inline;inline")
|
||||||
else()
|
else()
|
||||||
set(INLINE_OPTIONS "__inline__;inline")
|
set(INLINE_OPTIONS "__inline__;inline")
|
||||||
@@ -431,7 +441,7 @@ if(FORCE_INLINE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
foreach(inline ${INLINE_OPTIONS})
|
foreach(inline ${INLINE_OPTIONS})
|
||||||
check_c_source_compiles("${inline} static void foo(void) {} int main(void) { foo(); }"
|
check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }"
|
||||||
INLINE_WORKS)
|
INLINE_WORKS)
|
||||||
if(INLINE_WORKS)
|
if(INLINE_WORKS)
|
||||||
set(INLINE ${inline})
|
set(INLINE ${inline})
|
||||||
@@ -443,6 +453,21 @@ if(NOT INLINE_WORKS)
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
|
message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
|
||||||
|
|
||||||
|
if(WITH_TURBOJPEG)
|
||||||
|
if(MSVC)
|
||||||
|
set(THREAD_LOCAL "__declspec(thread)")
|
||||||
|
else()
|
||||||
|
set(THREAD_LOCAL "__thread")
|
||||||
|
endif()
|
||||||
|
check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL)
|
||||||
|
if(HAVE_THREAD_LOCAL)
|
||||||
|
message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
|
||||||
|
else()
|
||||||
|
message(WARNING "Thread-local storage is not available. The TurboJPEG API library's global error handler will not be thread-safe.")
|
||||||
|
unset(THREAD_LOCAL)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
|
||||||
set(CMAKE_REQUIRED_FLAGS
|
set(CMAKE_REQUIRED_FLAGS
|
||||||
@@ -462,8 +487,8 @@ if(UNIX AND NOT APPLE)
|
|||||||
# still work.
|
# still work.
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
|
||||||
"VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
|
"VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
|
||||||
check_c_source_compiles("void foo() {} void foo2() {} int main(void) { return 0; }"
|
check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
|
||||||
HAVE_MAPFILE)
|
HAVE_MAPFILE)
|
||||||
set(CMAKE_REQUIRED_FLAGS)
|
set(CMAKE_REQUIRED_FLAGS)
|
||||||
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
|
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
|
||||||
@@ -496,7 +521,12 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|||||||
# TARGETS
|
# TARGETS
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
|
if(CMAKE_EXECUTABLE_SUFFIX_TMP)
|
||||||
|
set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP})
|
||||||
|
endif()
|
||||||
|
message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
|
||||||
|
|
||||||
|
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c jcext.c
|
||||||
jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
|
jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
|
||||||
jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
|
jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
|
||||||
jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
|
jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
|
||||||
@@ -523,7 +553,7 @@ elseif(NOT WITH_12BIT)
|
|||||||
endif()
|
endif()
|
||||||
if(WITH_SIMD)
|
if(WITH_SIMD)
|
||||||
message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
|
message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
|
||||||
if(MSVC_IDE)
|
if(MSVC_IDE OR XCODE)
|
||||||
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
|
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
@@ -566,7 +596,8 @@ if(WITH_TURBOJPEG)
|
|||||||
if(MINGW)
|
if(MINGW)
|
||||||
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
|
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
|
||||||
|
CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
|
||||||
if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
|
if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
|
||||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
|
||||||
endif()
|
endif()
|
||||||
@@ -581,6 +612,9 @@ if(WITH_TURBOJPEG)
|
|||||||
|
|
||||||
add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
|
add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
|
||||||
target_link_libraries(tjunittest turbojpeg)
|
target_link_libraries(tjunittest turbojpeg)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(tjunittest m)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(tjbench tjbench.c tjutil.c)
|
add_executable(tjbench tjbench.c tjutil.c)
|
||||||
target_link_libraries(tjbench turbojpeg)
|
target_link_libraries(tjbench turbojpeg)
|
||||||
@@ -590,6 +624,9 @@ if(WITH_TURBOJPEG)
|
|||||||
|
|
||||||
add_executable(tjexample tjexample.c)
|
add_executable(tjexample tjexample.c)
|
||||||
target_link_libraries(tjexample turbojpeg)
|
target_link_libraries(tjexample turbojpeg)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(tjexample m)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_STATIC)
|
if(ENABLE_STATIC)
|
||||||
@@ -605,6 +642,9 @@ if(WITH_TURBOJPEG)
|
|||||||
add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
|
add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
|
||||||
md5/md5hl.c)
|
md5/md5hl.c)
|
||||||
target_link_libraries(tjunittest-static turbojpeg-static)
|
target_link_libraries(tjunittest-static turbojpeg-static)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(tjunittest-static m)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(tjbench-static tjbench.c tjutil.c)
|
add_executable(tjbench-static tjbench.c tjutil.c)
|
||||||
target_link_libraries(tjbench-static turbojpeg-static)
|
target_link_libraries(tjbench-static turbojpeg-static)
|
||||||
@@ -623,21 +663,58 @@ else()
|
|||||||
set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
|
set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
|
||||||
set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
|
set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
|
||||||
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
|
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
|
||||||
|
|
||||||
|
if(PNG_SUPPORTED)
|
||||||
|
report_option(PNG_SUPPORTED "PNG reading support")
|
||||||
|
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DPNG_SUPPORTED")
|
||||||
|
set(CJPEG_BMP_SOURCES ${CJPEG_BMP_SOURCES} rdpng.c)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_STATIC)
|
if(ENABLE_STATIC)
|
||||||
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
|
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdjpeg.c rdswitch.c
|
||||||
${CJPEG_BMP_SOURCES})
|
${CJPEG_BMP_SOURCES})
|
||||||
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||||
target_link_libraries(cjpeg-static jpeg-static)
|
target_link_libraries(cjpeg-static jpeg-static)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(cjpeg-static m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PNG_SUPPORTED)
|
||||||
|
# to avoid finding shared library from CMake cache
|
||||||
|
unset(PNG_LIBRARY CACHE)
|
||||||
|
unset(PNG_LIBRARY_RELEASE CACHE)
|
||||||
|
unset(PNG_LIBRARY_DEBUG CACHE)
|
||||||
|
unset(ZLIB_LIBRARY CACHE)
|
||||||
|
unset(ZLIB_LIBRARY_RELEASE CACHE)
|
||||||
|
unset(ZLIB_LIBRARY_DEBUG CACHE)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
find_package(ZLIB REQUIRED) # macos doesn't have static zlib
|
||||||
|
endif()
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||||
|
find_package(PNG 1.6 REQUIRED)
|
||||||
|
if (NOT APPLE)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
endif()
|
||||||
|
target_include_directories(cjpeg-static PUBLIC ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||||
|
target_link_libraries(cjpeg-static ${PNG_LIBRARY} ${ZLIB_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
|
add_executable(djpeg-static djpeg.c cdjpeg.c rdcolmap.c rdswitch.c wrgif.c
|
||||||
wrppm.c ${DJPEG_BMP_SOURCES})
|
wrppm.c ${DJPEG_BMP_SOURCES})
|
||||||
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
set_property(TARGET djpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS})
|
||||||
target_link_libraries(djpeg-static jpeg-static)
|
target_link_libraries(djpeg-static jpeg-static)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(djpeg-static m)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
|
add_executable(jpegtran-static jpegtran.c cdjpeg.c rdswitch.c transupp.c)
|
||||||
target_link_libraries(jpegtran-static jpeg-static)
|
target_link_libraries(jpegtran-static jpeg-static)
|
||||||
|
if(UNIX)
|
||||||
|
target_link_libraries(jpegtran-static m)
|
||||||
|
endif()
|
||||||
|
|
||||||
set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
|
set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "${USE_SETMODE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -652,7 +729,7 @@ add_executable(wrjpgcom wrjpgcom.c)
|
|||||||
|
|
||||||
add_subdirectory(md5)
|
add_subdirectory(md5)
|
||||||
|
|
||||||
if(MSVC_IDE)
|
if(MSVC_IDE OR XCODE)
|
||||||
set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
|
set(OBJDIR "\${CTEST_CONFIGURATION_TYPE}/")
|
||||||
else()
|
else()
|
||||||
set(OBJDIR "")
|
set(OBJDIR "")
|
||||||
@@ -668,7 +745,7 @@ if(WITH_12BIT)
|
|||||||
set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
|
set(MD5_JPEG_422_IFAST_OPT 7322e3bd2f127f7de4b40d4480ce60e4)
|
||||||
set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
|
set(MD5_PPM_422_IFAST 79807fa552899e66a04708f533e16950)
|
||||||
set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
|
set(MD5_PPM_422M_IFAST 07737bfe8a7c1c87aaa393a0098d16b0)
|
||||||
set(MD5_JPEG_420_IFAST_Q100_PROG a1da220b5604081863a504297ed59e55)
|
set(MD5_JPEG_420_IFAST_Q100_PROG 008ab68d6ddbba04a8f01deee4e0f9f8)
|
||||||
set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
|
set(MD5_PPM_420_Q100_IFAST 1b3730122709f53d007255e8dfd3305e)
|
||||||
set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
|
set(MD5_PPM_420M_Q100_IFAST 980a1a3c5bf9510022869d30b7d26566)
|
||||||
set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
|
set(MD5_JPEG_GRAY_ISLOW 235c90707b16e2e069f37c888b2636d9)
|
||||||
@@ -718,7 +795,7 @@ else()
|
|||||||
set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
|
set(MD5_PPM_422M_IFAST 8dbc65323d62cca7c91ba02dd1cfa81d)
|
||||||
set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
|
set(MD5_BMP_422M_IFAST_565 3294bd4d9a1f2b3d08ea6020d0db7065)
|
||||||
set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
|
set(MD5_BMP_422M_IFAST_565D da98c9c7b6039511be4a79a878a9abc1)
|
||||||
set(MD5_JPEG_420_IFAST_Q100_PROG 990cbe0329c882420a2094da7e5adade)
|
set(MD5_JPEG_420_IFAST_Q100_PROG e59bb462016a8d9a748c330a3474bb55)
|
||||||
set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
|
set(MD5_PPM_420_Q100_IFAST 5a732542015c278ff43635e473a8a294)
|
||||||
set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
|
set(MD5_PPM_420M_Q100_IFAST ff692ee9323a3b424894862557c092f1)
|
||||||
set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
|
set(MD5_JPEG_GRAY_ISLOW 72b51f894b8f4a10b3ee3066770aa38d)
|
||||||
@@ -874,12 +951,18 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
set(suffix -static)
|
set(suffix -static)
|
||||||
endif()
|
endif()
|
||||||
if(WITH_TURBOJPEG)
|
if(WITH_TURBOJPEG)
|
||||||
add_test(tjunittest-${libtype} tjunittest${suffix})
|
add_test(tjunittest-${libtype}
|
||||||
add_test(tjunittest-${libtype}-alloc tjunittest${suffix} -alloc)
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix})
|
||||||
add_test(tjunittest-${libtype}-yuv tjunittest${suffix} -yuv)
|
add_test(tjunittest-${libtype}-alloc
|
||||||
add_test(tjunittest-${libtype}-yuv-alloc tjunittest${suffix} -yuv -alloc)
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -alloc)
|
||||||
add_test(tjunittest-${libtype}-yuv-nopad tjunittest${suffix} -yuv -noyuvpad)
|
add_test(tjunittest-${libtype}-yuv
|
||||||
add_test(tjunittest-${libtype}-bmp tjunittest${suffix} -bmp)
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv)
|
||||||
|
add_test(tjunittest-${libtype}-yuv-alloc
|
||||||
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -alloc)
|
||||||
|
add_test(tjunittest-${libtype}-yuv-nopad
|
||||||
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -yuv -noyuvpad)
|
||||||
|
add_test(tjunittest-${libtype}-bmp
|
||||||
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjunittest${suffix} -bmp)
|
||||||
|
|
||||||
set(MD5_PPM_GRAY_TILE 89d3ca21213d9d864b50b4e4e7de4ca6)
|
set(MD5_PPM_GRAY_TILE 89d3ca21213d9d864b50b4e4e7de4ca6)
|
||||||
set(MD5_PPM_420_8x8_TILE 847fceab15c5b7b911cb986cf0f71de3)
|
set(MD5_PPM_420_8x8_TILE 847fceab15c5b7b911cb986cf0f71de3)
|
||||||
@@ -904,22 +987,23 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
|
${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
|
||||||
testout_tile.ppm)
|
testout_tile.ppm)
|
||||||
add_test(tjbench-${libtype}-tile
|
add_test(tjbench-${libtype}-tile
|
||||||
tjbench${suffix} testout_tile.ppm 95 -rgb -quiet -tile -benchtime 0.01
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tile.ppm 95
|
||||||
-warmup 0)
|
-rgb -quiet -tile -benchtime 0.01 -warmup 0)
|
||||||
set_tests_properties(tjbench-${libtype}-tile
|
set_tests_properties(tjbench-${libtype}-tile
|
||||||
PROPERTIES DEPENDS tjbench-${libtype}-tile-cp)
|
PROPERTIES DEPENDS tjbench-${libtype}-tile-cp)
|
||||||
|
|
||||||
foreach(tile 8 16 32 64 128)
|
foreach(tile 8 16 32 64 128)
|
||||||
add_test(tjbench-${libtype}-tile-gray-${tile}x${tile}-cmp
|
add_test(tjbench-${libtype}-tile-gray-${tile}x${tile}-cmp
|
||||||
${MD5CMP} ${MD5_PPM_GRAY_TILE}
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_GRAY_TILE}
|
||||||
testout_tile_GRAY_Q95_${tile}x${tile}.ppm)
|
testout_tile_GRAY_Q95_${tile}x${tile}.ppm)
|
||||||
foreach(subsamp 420 422)
|
foreach(subsamp 420 422)
|
||||||
add_test(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
|
add_test(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
|
||||||
${MD5CMP} ${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
|
||||||
|
${MD5_PPM_${subsamp}_${tile}x${tile}_TILE}
|
||||||
testout_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
|
testout_tile_${subsamp}_Q95_${tile}x${tile}.ppm)
|
||||||
endforeach()
|
endforeach()
|
||||||
add_test(tjbench-${libtype}-tile-444-${tile}x${tile}-cmp
|
add_test(tjbench-${libtype}-tile-444-${tile}x${tile}-cmp
|
||||||
${MD5CMP} ${MD5_PPM_444_TILE}
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_444_TILE}
|
||||||
testout_tile_444_Q95_${tile}x${tile}.ppm)
|
testout_tile_444_Q95_${tile}x${tile}.ppm)
|
||||||
foreach(subsamp gray 420 422 444)
|
foreach(subsamp gray 420 422 444)
|
||||||
set_tests_properties(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
|
set_tests_properties(tjbench-${libtype}-tile-${subsamp}-${tile}x${tile}-cmp
|
||||||
@@ -931,19 +1015,22 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
|
${CMAKE_COMMAND} -E copy_if_different ${TESTIMAGES}/testorig.ppm
|
||||||
testout_tilem.ppm)
|
testout_tilem.ppm)
|
||||||
add_test(tjbench-${libtype}-tilem
|
add_test(tjbench-${libtype}-tilem
|
||||||
tjbench${suffix} testout_tilem.ppm 95 -rgb -fastupsample -quiet -tile
|
${CMAKE_CROSSCOMPILING_EMULATOR} tjbench${suffix} testout_tilem.ppm 95
|
||||||
-benchtime 0.01 -warmup 0)
|
-rgb -fastupsample -quiet -tile -benchtime 0.01 -warmup 0)
|
||||||
set_tests_properties(tjbench-${libtype}-tilem
|
set_tests_properties(tjbench-${libtype}-tilem
|
||||||
PROPERTIES DEPENDS tjbench-${libtype}-tilem-cp)
|
PROPERTIES DEPENDS tjbench-${libtype}-tilem-cp)
|
||||||
|
|
||||||
add_test(tjbench-${libtype}-tile-420m-8x8-cmp
|
add_test(tjbench-${libtype}-tile-420m-8x8-cmp
|
||||||
${MD5CMP} ${MD5_PPM_420M_8x8_TILE} testout_tilem_420_Q95_8x8.ppm)
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_420M_8x8_TILE}
|
||||||
|
testout_tilem_420_Q95_8x8.ppm)
|
||||||
add_test(tjbench-${libtype}-tile-422m-8x8-cmp
|
add_test(tjbench-${libtype}-tile-422m-8x8-cmp
|
||||||
${MD5CMP} ${MD5_PPM_422M_8x8_TILE} testout_tilem_422_Q95_8x8.ppm)
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5_PPM_422M_8x8_TILE}
|
||||||
|
testout_tilem_422_Q95_8x8.ppm)
|
||||||
foreach(tile 16 32 64 128)
|
foreach(tile 16 32 64 128)
|
||||||
foreach(subsamp 420 422)
|
foreach(subsamp 420 422)
|
||||||
add_test(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
|
add_test(tjbench-${libtype}-tile-${subsamp}m-${tile}x${tile}-cmp
|
||||||
${MD5CMP} ${MD5_PPM_${subsamp}M_TILE}
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
|
||||||
|
${MD5_PPM_${subsamp}M_TILE}
|
||||||
testout_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
|
testout_tilem_${subsamp}_Q95_${tile}x${tile}.ppm)
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -961,9 +1048,10 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
macro(add_bittest PROG NAME ARGS OUTFILE INFILE MD5SUM)
|
macro(add_bittest PROG NAME ARGS OUTFILE INFILE MD5SUM)
|
||||||
add_test(${PROG}-${libtype}-${NAME}
|
add_test(${PROG}-${libtype}-${NAME}
|
||||||
${PROG}${suffix} ${ARGS} -outfile ${OUTFILE} ${INFILE})
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${PROG}${suffix} ${ARGS}
|
||||||
|
-outfile ${OUTFILE} ${INFILE})
|
||||||
add_test(${PROG}-${libtype}-${NAME}-cmp
|
add_test(${PROG}-${libtype}-${NAME}-cmp
|
||||||
${MD5CMP} ${MD5SUM} ${OUTFILE})
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP} ${MD5SUM} ${OUTFILE})
|
||||||
set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
|
set_tests_properties(${PROG}-${libtype}-${NAME}-cmp PROPERTIES
|
||||||
DEPENDS ${PROG}-${libtype}-${NAME})
|
DEPENDS ${PROG}-${libtype}-${NAME})
|
||||||
if(${ARGC} GREATER 6)
|
if(${ARGC} GREATER 6)
|
||||||
@@ -984,10 +1072,14 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
${MD5_PPM_RGB_ISLOW} cjpeg-${libtype}-rgb-islow)
|
${MD5_PPM_RGB_ISLOW} cjpeg-${libtype}-rgb-islow)
|
||||||
|
|
||||||
add_test(djpeg-${libtype}-rgb-islow-icc-cmp
|
add_test(djpeg-${libtype}-rgb-islow-icc-cmp
|
||||||
${MD5CMP} b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
|
${CMAKE_CROSSCOMPILING_EMULATOR} ${MD5CMP}
|
||||||
|
b06a39d730129122e85c1363ed1bbc9e testout_rgb_islow.icc)
|
||||||
|
set_tests_properties(djpeg-${libtype}-rgb-islow-icc-cmp PROPERTIES
|
||||||
|
DEPENDS djpeg-${libtype}-rgb-islow)
|
||||||
|
|
||||||
add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
|
add_bittest(jpegtran icc "-copy;all;-icc;${TESTIMAGES}/test2.icc"
|
||||||
testout_rgb_islow2.jpg testout_rgb_islow.jpg ${MD5_JPEG_RGB_ISLOW2})
|
testout_rgb_islow2.jpg testout_rgb_islow.jpg
|
||||||
|
${MD5_JPEG_RGB_ISLOW2} cjpeg-${libtype}-rgb-islow)
|
||||||
|
|
||||||
if(NOT WITH_12BIT)
|
if(NOT WITH_12BIT)
|
||||||
# CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
# CC: RGB->RGB565 SAMP: fullsize IDCT: islow ENT: huff
|
||||||
@@ -1031,7 +1123,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
|
# CC: RGB->YCC SAMP: fullsize/h2v2 FDCT: ifast ENT: prog huff
|
||||||
add_bittest(cjpeg 420-q100-ifast-prog
|
add_bittest(cjpeg 420-q100-ifast-prog
|
||||||
"-sample;2x2;-quality;100;-dct;fast;-prog"
|
"-sample;2x2;-quality;100;-dct;fast;-scans;${TESTIMAGES}/test.scan"
|
||||||
testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
|
testout_420_q100_ifast_prog.jpg ${TESTIMAGES}/testorig.ppm
|
||||||
${MD5_JPEG_420_IFAST_Q100_PROG})
|
${MD5_JPEG_420_IFAST_Q100_PROG})
|
||||||
|
|
||||||
@@ -1200,7 +1292,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
|
# Context rows: Yes Intra-iMCU row: No iMCU row prefetch: No ENT: prog huff
|
||||||
add_test(cjpeg-${libtype}-420-islow-prog
|
add_test(cjpeg-${libtype}-420-islow-prog
|
||||||
cjpeg${suffix} -dct int -prog
|
${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog
|
||||||
-outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
|
-outfile testout_420_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
|
||||||
add_bittest(djpeg 420-islow-prog-crop62x62_71_71
|
add_bittest(djpeg 420-islow-prog-crop62x62_71_71
|
||||||
"-dct;int;-crop;62x62+71+71;-ppm"
|
"-dct;int;-crop;62x62+71+71;-ppm"
|
||||||
@@ -1217,7 +1309,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
# Context rows: No Intra-iMCU row: Yes ENT: huff
|
# Context rows: No Intra-iMCU row: Yes ENT: huff
|
||||||
add_test(cjpeg-${libtype}-444-islow
|
add_test(cjpeg-${libtype}-444-islow
|
||||||
cjpeg${suffix} -dct int -sample 1x1
|
${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -sample 1x1
|
||||||
-outfile testout_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
|
-outfile testout_444_islow.jpg ${TESTIMAGES}/testorig.ppm)
|
||||||
add_bittest(djpeg 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
|
add_bittest(djpeg 444-islow-skip1_6 "-dct;int;-skip;1,6;-ppm"
|
||||||
testout_444_islow_skip1,6.ppm testout_444_islow.jpg
|
testout_444_islow_skip1,6.ppm testout_444_islow.jpg
|
||||||
@@ -1225,7 +1317,7 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
|
|
||||||
# Context rows: No Intra-iMCU row: No ENT: prog huff
|
# Context rows: No Intra-iMCU row: No ENT: prog huff
|
||||||
add_test(cjpeg-${libtype}-444-islow-prog
|
add_test(cjpeg-${libtype}-444-islow-prog
|
||||||
cjpeg${suffix} -dct int -prog -sample 1x1
|
${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -prog -sample 1x1
|
||||||
-outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
|
-outfile testout_444_islow_prog.jpg ${TESTIMAGES}/testorig.ppm)
|
||||||
add_bittest(djpeg 444-islow-prog-crop98x98_13_13
|
add_bittest(djpeg 444-islow-prog-crop98x98_13_13
|
||||||
"-dct;int;-crop;98x98+13+13;-ppm"
|
"-dct;int;-crop;98x98+13+13;-ppm"
|
||||||
@@ -1235,8 +1327,9 @@ foreach(libtype ${TEST_LIBTYPES})
|
|||||||
# Context rows: No Intra-iMCU row: No ENT: arith
|
# Context rows: No Intra-iMCU row: No ENT: arith
|
||||||
if(WITH_ARITH_ENC)
|
if(WITH_ARITH_ENC)
|
||||||
add_test(cjpeg-${libtype}-444-islow-ari
|
add_test(cjpeg-${libtype}-444-islow-ari
|
||||||
cjpeg${suffix} -dct int -arithmetic -sample 1x1
|
${CMAKE_CROSSCOMPILING_EMULATOR} cjpeg${suffix} -dct int -arithmetic
|
||||||
-outfile testout_444_islow_ari.jpg ${TESTIMAGES}/testorig.ppm)
|
-sample 1x1 -outfile testout_444_islow_ari.jpg
|
||||||
|
${TESTIMAGES}/testorig.ppm)
|
||||||
if(WITH_ARITH_DEC)
|
if(WITH_ARITH_DEC)
|
||||||
add_bittest(djpeg 444-islow-ari-crop37x37_0_0
|
add_bittest(djpeg 444-islow-ari-crop37x37_0_0
|
||||||
"-dct;int;-crop;37x37+0+0;-ppm"
|
"-dct;int;-crop;37x37+0+0;-ppm"
|
||||||
@@ -1274,6 +1367,8 @@ if(WITH_TURBOJPEG)
|
|||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
|
||||||
COMMAND echo tjbenchtest -progressive
|
COMMAND echo tjbenchtest -progressive
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
|
||||||
|
COMMAND echo tjbenchtest -progressive -yuv
|
||||||
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
|
||||||
COMMAND echo tjexampletest
|
COMMAND echo tjexampletest
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
|
||||||
COMMAND echo tjbenchtest.java
|
COMMAND echo tjbenchtest.java
|
||||||
@@ -1282,6 +1377,9 @@ if(WITH_TURBOJPEG)
|
|||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -yuv
|
||||||
COMMAND echo tjbenchtest.java -progressive
|
COMMAND echo tjbenchtest.java -progressive
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java -progressive
|
||||||
|
COMMAND echo tjexampletest.java -progressive -yuv
|
||||||
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest.java
|
||||||
|
-progressive -yuv
|
||||||
COMMAND echo tjexampletest.java
|
COMMAND echo tjexampletest.java
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest.java
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest
|
||||||
@@ -1297,6 +1395,10 @@ if(WITH_TURBOJPEG)
|
|||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv
|
||||||
COMMAND echo tjbenchtest -yuv -alloc
|
COMMAND echo tjbenchtest -yuv -alloc
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -yuv -alloc
|
||||||
|
COMMAND echo tjbenchtest -progressive
|
||||||
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive
|
||||||
|
COMMAND echo tjbenchtest -progressive -yuv
|
||||||
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest -progressive -yuv
|
||||||
COMMAND echo tjexampletest
|
COMMAND echo tjexampletest
|
||||||
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
|
COMMAND ${BASH} ${CMAKE_CURRENT_BINARY_DIR}/tjexampletest
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
|
||||||
@@ -1308,9 +1410,7 @@ endif()
|
|||||||
# INSTALLATION
|
# INSTALLATION
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
if(WIN32)
|
set(EXE ${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
set(EXE ".exe")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_TURBOJPEG)
|
if(WITH_TURBOJPEG)
|
||||||
if(ENABLE_SHARED)
|
if(ENABLE_SHARED)
|
||||||
@@ -1318,12 +1418,22 @@ if(WITH_TURBOJPEG)
|
|||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
|
||||||
|
CMAKE_C_LINKER_SUPPORTS_PDB)
|
||||||
|
install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
|
||||||
|
DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(ENABLE_STATIC)
|
if(ENABLE_STATIC)
|
||||||
install(TARGETS turbojpeg-static ARCHIVE
|
install(TARGETS turbojpeg-static ARCHIVE
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
if(NOT ENABLE_SHARED)
|
if(NOT ENABLE_SHARED)
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static${EXE}
|
if(MSVC_IDE OR XCODE)
|
||||||
|
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
|
||||||
|
else()
|
||||||
|
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
install(PROGRAMS ${DIR}/tjbench-static${EXE}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
|
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -1334,11 +1444,16 @@ endif()
|
|||||||
if(ENABLE_STATIC)
|
if(ENABLE_STATIC)
|
||||||
install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(TARGETS jpeg-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
if(NOT ENABLE_SHARED)
|
if(NOT ENABLE_SHARED)
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static${EXE}
|
if(MSVC_IDE OR XCODE)
|
||||||
|
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
|
||||||
|
else()
|
||||||
|
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
install(PROGRAMS ${DIR}/cjpeg-static${EXE}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
|
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME cjpeg${EXE})
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static${EXE}
|
install(PROGRAMS ${DIR}/djpeg-static${EXE}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
|
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME djpeg${EXE})
|
||||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/jpegtran-static${EXE}
|
install(PROGRAMS ${DIR}/jpegtran-static${EXE}
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
|
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -1363,10 +1478,10 @@ if(UNIX OR MINGW)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
|
${CMAKE_CURRENT_SOURCE_DIR}/rdjpgcom.1
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
|
${CMAKE_CURRENT_SOURCE_DIR}/wrjpgcom.1
|
||||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
|
endif()
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
|
${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||||
endif()
|
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
|
${CMAKE_CURRENT_SOURCE_DIR}/jerror.h ${CMAKE_CURRENT_SOURCE_DIR}/jmorecfg.h
|
||||||
|
|||||||
15
CODE_OF_CONDUCT.md
Normal file
15
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Community Participation Guidelines
|
||||||
|
|
||||||
|
This repository is governed by Mozilla's code of conduct and etiquette guidelines.
|
||||||
|
For more details, please read the
|
||||||
|
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).
|
||||||
|
|
||||||
|
## How to Report
|
||||||
|
For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.
|
||||||
|
|
||||||
|
<!--
|
||||||
|
## Project Specific Etiquette
|
||||||
|
|
||||||
|
In some cases, there will be additional project etiquette i.e.: (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html).
|
||||||
|
Please update for your project.
|
||||||
|
-->
|
||||||
282
ChangeLog.md
282
ChangeLog.md
@@ -1,3 +1,244 @@
|
|||||||
|
2.0.5
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0.4:
|
||||||
|
|
||||||
|
1. Worked around issues in the MIPS DSPr2 SIMD extensions that caused failures
|
||||||
|
in the libjpeg-turbo regression tests. Specifically, the
|
||||||
|
`jsimd_h2v1_downsample_dspr2()` and `jsimd_h2v2_downsample_dspr2()` functions
|
||||||
|
in the MIPS DSPr2 SIMD extensions are now disabled until/unless they can be
|
||||||
|
fixed, and other functions that are incompatible with big endian MIPS CPUs are
|
||||||
|
disabled when building libjpeg-turbo for such CPUs.
|
||||||
|
|
||||||
|
2. Fixed an oversight in the `TJCompressor.compress(int)` method in the
|
||||||
|
TurboJPEG Java API that caused an error ("java.lang.IllegalStateException: No
|
||||||
|
source image is associated with this instance") when attempting to use that
|
||||||
|
method to compress a YUV image.
|
||||||
|
|
||||||
|
3. Fixed an issue (CVE-2020-13790) in the PPM reader that caused a buffer
|
||||||
|
overrun in cjpeg, TJBench, or the `tjLoadImage()` function if one of the values
|
||||||
|
in a binary PPM/PGM input file exceeded the maximum value defined in the file's
|
||||||
|
header and that maximum value was less than 255. libjpeg-turbo 1.5.0 already
|
||||||
|
included a similar fix for binary PPM/PGM files with maximum values greater
|
||||||
|
than 255.
|
||||||
|
|
||||||
|
4. The TurboJPEG API library's global error handler, which is used in functions
|
||||||
|
such as `tjBufSize()` and `tjLoadImage()` that do not require a TurboJPEG
|
||||||
|
instance handle, is now thread-safe on platforms that support thread-local
|
||||||
|
storage.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.4
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0.3:
|
||||||
|
|
||||||
|
1. Fixed a regression in the Windows packaging system (introduced by
|
||||||
|
2.0 beta1[2]) whereby, if both the 64-bit libjpeg-turbo SDK for GCC and the
|
||||||
|
64-bit libjpeg-turbo SDK for Visual C++ were installed on the same system, only
|
||||||
|
one of them could be uninstalled.
|
||||||
|
|
||||||
|
2. Fixed a signed integer overflow and subsequent segfault that occurred when
|
||||||
|
attempting to decompress images with more than 715827882 pixels using the
|
||||||
|
64-bit C version of TJBench.
|
||||||
|
|
||||||
|
3. Fixed out-of-bounds write in `tjDecompressToYUV2()` and
|
||||||
|
`tjDecompressToYUVPlanes()` (sometimes manifesting as a double free) that
|
||||||
|
occurred when attempting to decompress grayscale JPEG images that were
|
||||||
|
compressed with a sampling factor other than 1 (for instance, with
|
||||||
|
`cjpeg -grayscale -sample 2x2`).
|
||||||
|
|
||||||
|
4. Fixed a regression introduced by 2.0.2[5] that caused the TurboJPEG API to
|
||||||
|
incorrectly identify some JPEG images with unusual sampling factors as 4:4:4
|
||||||
|
JPEG images. This was known to cause a buffer overflow when attempting to
|
||||||
|
decompress some such images using `tjDecompressToYUV2()` or
|
||||||
|
`tjDecompressToYUVPlanes()`.
|
||||||
|
|
||||||
|
5. Fixed an issue, detected by ASan, whereby attempting to losslessly transform
|
||||||
|
a specially-crafted malformed JPEG image containing an extremely-high-frequency
|
||||||
|
coefficient block (junk image data that could never be generated by a
|
||||||
|
legitimate JPEG compressor) could cause the Huffman encoder's local buffer to
|
||||||
|
be overrun. (Refer to 1.4.0[9] and 1.4beta1[15].) Given that the buffer
|
||||||
|
overrun was fully contained within the stack and did not cause a segfault or
|
||||||
|
other user-visible errant behavior, and given that the lossless transformer
|
||||||
|
(unlike the decompressor) is not generally exposed to arbitrary data exploits,
|
||||||
|
this issue did not likely pose a security risk.
|
||||||
|
|
||||||
|
6. The ARM 64-bit (ARMv8) NEON SIMD assembly code now stores constants in a
|
||||||
|
separate read-only data section rather than in the text section, to support
|
||||||
|
execute-only memory layouts.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.3
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0.2:
|
||||||
|
|
||||||
|
1. Fixed "using JNI after critical get" errors that occurred on Android
|
||||||
|
platforms when passing invalid arguments to certain methods in the TurboJPEG
|
||||||
|
Java API.
|
||||||
|
|
||||||
|
2. Fixed a regression in the SIMD feature detection code, introduced by
|
||||||
|
the AVX2 SIMD extensions (2.0 beta1[1]), that was known to cause an illegal
|
||||||
|
instruction exception, in rare cases, on CPUs that lack support for CPUID leaf
|
||||||
|
07H (or on which the maximum CPUID leaf has been limited by way of a BIOS
|
||||||
|
setting.)
|
||||||
|
|
||||||
|
3. The 4:4:0 (h1v2) fancy (smooth) chroma upsampling algorithm in the
|
||||||
|
decompressor now uses a similar bias pattern to that of the 4:2:2 (h2v1) fancy
|
||||||
|
chroma upsampling algorithm, rounding up or down the upsampled result for
|
||||||
|
alternate pixels rather than always rounding down. This ensures that,
|
||||||
|
regardless of whether a 4:2:2 JPEG image is rotated or transposed prior to
|
||||||
|
decompression (in the frequency domain) or after decompression (in the spatial
|
||||||
|
domain), the final image will be similar.
|
||||||
|
|
||||||
|
4. Fixed an integer overflow and subsequent segfault that occurred when
|
||||||
|
attempting to compress or decompress images with more than 1 billion pixels
|
||||||
|
using the TurboJPEG API.
|
||||||
|
|
||||||
|
5. Fixed a regression introduced by 2.0 beta1[15] whereby attempting to
|
||||||
|
generate a progressive JPEG image on an SSE2-capable CPU using a scan script
|
||||||
|
containing one or more scans with lengths divisible by 16 would result in an
|
||||||
|
error ("Missing Huffman code table entry") and an invalid JPEG image.
|
||||||
|
|
||||||
|
6. Fixed an issue whereby `tjDecodeYUV()` and `tjDecodeYUVPlanes()` would throw
|
||||||
|
an error ("Invalid progressive parameters") or a warning ("Inconsistent
|
||||||
|
progression sequence") if passed a TurboJPEG instance that was previously used
|
||||||
|
to decompress a progressive JPEG image.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.2
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0.1:
|
||||||
|
|
||||||
|
1. Fixed a regression introduced by 2.0.1[5] that prevented a runtime search
|
||||||
|
path (rpath) from being embedded in the libjpeg-turbo shared libraries and
|
||||||
|
executables for macOS and iOS. This caused a fatal error of the form
|
||||||
|
"dyld: Library not loaded" when attempting to use one of the executables,
|
||||||
|
unless `DYLD_LIBRARY_PATH` was explicitly set to the location of the
|
||||||
|
libjpeg-turbo shared libraries.
|
||||||
|
|
||||||
|
2. Fixed an integer overflow and subsequent segfault (CVE-2018-20330) that
|
||||||
|
occurred when attempting to load a BMP file with more than 1 billion pixels
|
||||||
|
using the `tjLoadImage()` function.
|
||||||
|
|
||||||
|
3. Fixed a buffer overrun (CVE-2018-19664) that occurred when attempting to
|
||||||
|
decompress a specially-crafted malformed JPEG image to a 256-color BMP using
|
||||||
|
djpeg.
|
||||||
|
|
||||||
|
4. Fixed a floating point exception that occurred when attempting to
|
||||||
|
decompress a specially-crafted malformed JPEG image with a specified image
|
||||||
|
width or height of 0 using the C version of TJBench.
|
||||||
|
|
||||||
|
5. The TurboJPEG API will now decompress 4:4:4 JPEG images with 2x1, 1x2, 3x1,
|
||||||
|
or 1x3 luminance and chrominance sampling factors. This is a non-standard way
|
||||||
|
of specifying 1x subsampling (normally 4:4:4 JPEGs have 1x1 luminance and
|
||||||
|
chrominance sampling factors), but the JPEG format and the libjpeg API both
|
||||||
|
allow it.
|
||||||
|
|
||||||
|
6. Fixed a regression introduced by 2.0 beta1[7] that caused djpeg to generate
|
||||||
|
incorrect PPM images when used with the `-colors` option.
|
||||||
|
|
||||||
|
7. Fixed an issue whereby a static build of libjpeg-turbo (a build in which
|
||||||
|
`ENABLE_SHARED` is `0`) could not be installed using the Visual Studio IDE.
|
||||||
|
|
||||||
|
8. Fixed a severe performance issue in the Loongson MMI SIMD extensions that
|
||||||
|
occurred when compressing RGB images whose image rows were not 64-bit-aligned.
|
||||||
|
|
||||||
|
|
||||||
|
2.0.1
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0.0:
|
||||||
|
|
||||||
|
1. Fixed a regression introduced with the new CMake-based Un*x build system,
|
||||||
|
whereby jconfig.h could cause compiler warnings of the form
|
||||||
|
`"HAVE_*_H" redefined` if it was included by downstream Autotools-based
|
||||||
|
projects that used `AC_CHECK_HEADERS()` to check for the existence of locale.h,
|
||||||
|
stddef.h, or stdlib.h.
|
||||||
|
|
||||||
|
2. The `jsimd_quantize_float_dspr2()` and `jsimd_convsamp_float_dspr2()`
|
||||||
|
functions in the MIPS DSPr2 SIMD extensions are now disabled at compile time
|
||||||
|
if the soft float ABI is enabled. Those functions use instructions that are
|
||||||
|
incompatible with the soft float ABI.
|
||||||
|
|
||||||
|
3. Fixed a regression in the SIMD feature detection code, introduced by
|
||||||
|
the AVX2 SIMD extensions (2.0 beta1[1]), that caused libjpeg-turbo to crash on
|
||||||
|
Windows 7 if Service Pack 1 was not installed.
|
||||||
|
|
||||||
|
4. Fixed out-of-bounds read in cjpeg that occurred when attempting to compress
|
||||||
|
a specially-crafted malformed color-index (8-bit-per-sample) Targa file in
|
||||||
|
which some of the samples (color indices) exceeded the bounds of the Targa
|
||||||
|
file's color table.
|
||||||
|
|
||||||
|
5. Fixed an issue whereby installing a fully static build of libjpeg-turbo
|
||||||
|
(a build in which `CFLAGS` contains `-static` and `ENABLE_SHARED` is `0`) would
|
||||||
|
fail with "No valid ELF RPATH or RUNPATH entry exists in the file."
|
||||||
|
|
||||||
|
|
||||||
|
2.0.0
|
||||||
|
=====
|
||||||
|
|
||||||
|
### Significant changes relative to 2.0 beta1:
|
||||||
|
|
||||||
|
1. The TurboJPEG API can now decompress CMYK JPEG images that have subsampled M
|
||||||
|
and Y components (not to be confused with YCCK JPEG images, in which the C/M/Y
|
||||||
|
components have been transformed into luma and chroma.) Previously, an error
|
||||||
|
was generated ("Could not determine subsampling type for JPEG image") when such
|
||||||
|
an image was passed to `tjDecompressHeader3()`, `tjTransform()`,
|
||||||
|
`tjDecompressToYUVPlanes()`, `tjDecompressToYUV2()`, or the equivalent Java
|
||||||
|
methods.
|
||||||
|
|
||||||
|
2. Fixed an issue (CVE-2018-11813) whereby a specially-crafted malformed input
|
||||||
|
file (specifically, a file with a valid Targa header but incomplete pixel data)
|
||||||
|
would cause cjpeg to generate a JPEG file that was potentially thousands of
|
||||||
|
times larger than the input file. The Targa reader in cjpeg was not properly
|
||||||
|
detecting that the end of the input file had been reached prematurely, so after
|
||||||
|
all valid pixels had been read from the input, the reader injected dummy pixels
|
||||||
|
with values of 255 into the JPEG compressor until the number of pixels
|
||||||
|
specified in the Targa header had been compressed. The Targa reader in cjpeg
|
||||||
|
now behaves like the PPM reader and aborts compression if the end of the input
|
||||||
|
file is reached prematurely. Because this issue only affected cjpeg and not
|
||||||
|
the underlying library, and because it did not involve any out-of-bounds reads
|
||||||
|
or other exploitable behaviors, it was not believed to represent a security
|
||||||
|
threat.
|
||||||
|
|
||||||
|
3. Fixed an issue whereby the `tjLoadImage()` and `tjSaveImage()` functions
|
||||||
|
would produce a "Bogus message code" error message if the underlying bitmap and
|
||||||
|
PPM readers/writers threw an error that was specific to the readers/writers
|
||||||
|
(as opposed to a general libjpeg API error.)
|
||||||
|
|
||||||
|
4. Fixed an issue (CVE-2018-1152) whereby a specially-crafted malformed BMP
|
||||||
|
file, one in which the header specified an image width of 1073741824 pixels,
|
||||||
|
would trigger a floating point exception (division by zero) in the
|
||||||
|
`tjLoadImage()` function when attempting to load the BMP file into a
|
||||||
|
4-component image buffer.
|
||||||
|
|
||||||
|
5. Fixed an issue whereby certain combinations of calls to
|
||||||
|
`jpeg_skip_scanlines()` and `jpeg_read_scanlines()` could trigger an infinite
|
||||||
|
loop when decompressing progressive JPEG images that use vertical chroma
|
||||||
|
subsampling (for instance, 4:2:0 or 4:4:0.)
|
||||||
|
|
||||||
|
6. Fixed a segfault in `jpeg_skip_scanlines()` that occurred when decompressing
|
||||||
|
a 4:2:2 or 4:2:0 JPEG image using the merged (non-fancy) upsampling algorithms
|
||||||
|
(that is, when setting `cinfo.do_fancy_upsampling` to `FALSE`.)
|
||||||
|
|
||||||
|
7. The new CMake-based build system will now disable the MIPS DSPr2 SIMD
|
||||||
|
extensions if it detects that the compiler does not support DSPr2 instructions.
|
||||||
|
|
||||||
|
8. Fixed out-of-bounds read in cjpeg (CVE-2018-14498) that occurred when
|
||||||
|
attempting to compress a specially-crafted malformed color-index
|
||||||
|
(8-bit-per-sample) BMP file in which some of the samples (color indices)
|
||||||
|
exceeded the bounds of the BMP file's color table.
|
||||||
|
|
||||||
|
9. Fixed a signed integer overflow in the progressive Huffman decoder, detected
|
||||||
|
by the Clang and GCC undefined behavior sanitizers, that could be triggered by
|
||||||
|
attempting to decompress a specially-crafted malformed JPEG image. This issue
|
||||||
|
did not pose a security threat, but removing the warning made it easier to
|
||||||
|
detect actual security issues, should they arise in the future.
|
||||||
|
|
||||||
|
|
||||||
1.5.90 (2.0 beta1)
|
1.5.90 (2.0 beta1)
|
||||||
==================
|
==================
|
||||||
|
|
||||||
@@ -149,8 +390,8 @@ write scanlines in bottom-up order.) djpeg will now exit gracefully if an
|
|||||||
output format other than PPM/PGM, GIF, or Targa is selected along with the
|
output format other than PPM/PGM, GIF, or Targa is selected along with the
|
||||||
`-crop` option.
|
`-crop` option.
|
||||||
|
|
||||||
4. Fixed an issue whereby `jpeg_skip_scanlines()` would segfault if color
|
4. Fixed an issue (CVE-2017-15232) whereby `jpeg_skip_scanlines()` would
|
||||||
quantization was enabled.
|
segfault if color quantization was enabled.
|
||||||
|
|
||||||
5. TJBench (both C and Java versions) will now display usage information if any
|
5. TJBench (both C and Java versions) will now display usage information if any
|
||||||
command-line argument is unrecognized. This prevents the program from silently
|
command-line argument is unrecognized. This prevents the program from silently
|
||||||
@@ -305,8 +546,8 @@ specified.)
|
|||||||
2x2 luminance sampling factors and 2x1 or 1x2 chrominance sampling factors.
|
2x2 luminance sampling factors and 2x1 or 1x2 chrominance sampling factors.
|
||||||
This is a non-standard way of specifying 2x subsampling (normally 4:2:2 JPEGs
|
This is a non-standard way of specifying 2x subsampling (normally 4:2:2 JPEGs
|
||||||
have 2x1 luminance and 1x1 chrominance sampling factors, and 4:4:0 JPEGs have
|
have 2x1 luminance and 1x1 chrominance sampling factors, and 4:4:0 JPEGs have
|
||||||
1x2 luminance and 1x1 chrominance sampling factors), but the JPEG specification
|
1x2 luminance and 1x1 chrominance sampling factors), but the JPEG format and
|
||||||
and the libjpeg API both allow it.
|
the libjpeg API both allow it.
|
||||||
|
|
||||||
7. Fixed an unsigned integer overflow in the libjpeg memory manager, detected
|
7. Fixed an unsigned integer overflow in the libjpeg memory manager, detected
|
||||||
by the Clang undefined behavior sanitizer, that could be triggered by
|
by the Clang undefined behavior sanitizer, that could be triggered by
|
||||||
@@ -351,10 +592,10 @@ application was linked against.
|
|||||||
|
|
||||||
3. Fixed a couple of issues in the PPM reader that would cause buffer overruns
|
3. Fixed a couple of issues in the PPM reader that would cause buffer overruns
|
||||||
in cjpeg if one of the values in a binary PPM/PGM input file exceeded the
|
in cjpeg if one of the values in a binary PPM/PGM input file exceeded the
|
||||||
maximum value defined in the file's header. libjpeg-turbo 1.4.2 already
|
maximum value defined in the file's header and that maximum value was greater
|
||||||
included a similar fix for ASCII PPM/PGM files. Note that these issues were
|
than 255. libjpeg-turbo 1.4.2 already included a similar fix for ASCII PPM/PGM
|
||||||
not security bugs, since they were confined to the cjpeg program and did not
|
files. Note that these issues were not security bugs, since they were confined
|
||||||
affect any of the libjpeg-turbo libraries.
|
to the cjpeg program and did not affect any of the libjpeg-turbo libraries.
|
||||||
|
|
||||||
4. Fixed an issue whereby attempting to decompress a JPEG file with a corrupt
|
4. Fixed an issue whereby attempting to decompress a JPEG file with a corrupt
|
||||||
header using the `tjDecompressToYUV2()` function would cause the function to
|
header using the `tjDecompressToYUV2()` function would cause the function to
|
||||||
@@ -777,13 +1018,13 @@ and IDCT algorithms (both are used during JPEG decompression.) For unknown
|
|||||||
reasons (probably related to clang), this code cannot currently be compiled for
|
reasons (probably related to clang), this code cannot currently be compiled for
|
||||||
iOS.
|
iOS.
|
||||||
|
|
||||||
15. Fixed an extremely rare bug that could cause the Huffman encoder's local
|
15. Fixed an extremely rare bug (CVE-2014-9092) that could cause the Huffman
|
||||||
buffer to overrun when a very high-frequency MCU is compressed using quality
|
encoder's local buffer to overrun when a very high-frequency MCU is compressed
|
||||||
100 and no subsampling, and when the JPEG output buffer is being dynamically
|
using quality 100 and no subsampling, and when the JPEG output buffer is being
|
||||||
resized by the destination manager. This issue was so rare that, even with a
|
dynamically resized by the destination manager. This issue was so rare that,
|
||||||
test program specifically designed to make the bug occur (by injecting random
|
even with a test program specifically designed to make the bug occur (by
|
||||||
high-frequency YUV data into the compressor), it was reproducible only once in
|
injecting random high-frequency YUV data into the compressor), it was
|
||||||
about every 25 million iterations.
|
reproducible only once in about every 25 million iterations.
|
||||||
|
|
||||||
16. Fixed an oversight in the TurboJPEG C wrapper: if any of the JPEG
|
16. Fixed an oversight in the TurboJPEG C wrapper: if any of the JPEG
|
||||||
compression functions was called repeatedly with the same
|
compression functions was called repeatedly with the same
|
||||||
@@ -818,8 +1059,9 @@ entropy coding (by passing arguments of `-progressive -arithmetic` to cjpeg or
|
|||||||
jpegtran, for instance) would result in an error, `Requested feature was
|
jpegtran, for instance) would result in an error, `Requested feature was
|
||||||
omitted at compile time`.
|
omitted at compile time`.
|
||||||
|
|
||||||
4. Fixed a couple of issues whereby malformed JPEG images would cause
|
4. Fixed a couple of issues (CVE-2013-6629 and CVE-2013-6630) whereby malformed
|
||||||
libjpeg-turbo to use uninitialized memory during decompression.
|
JPEG images would cause libjpeg-turbo to use uninitialized memory during
|
||||||
|
decompression.
|
||||||
|
|
||||||
5. Fixed an error (`Buffer passed to JPEG library is too small`) that occurred
|
5. Fixed an error (`Buffer passed to JPEG library is too small`) that occurred
|
||||||
when calling the TurboJPEG YUV encoding function with a very small (< 5x5)
|
when calling the TurboJPEG YUV encoding function with a very small (< 5x5)
|
||||||
@@ -958,9 +1200,9 @@ correct behavior of the colorspace extensions when merged upsampling is used.
|
|||||||
upper 64 bits of xmm6 and xmm7 on Win64 platforms, which violated the Win64
|
upper 64 bits of xmm6 and xmm7 on Win64 platforms, which violated the Win64
|
||||||
calling conventions.
|
calling conventions.
|
||||||
|
|
||||||
4. Fixed a regression caused by 1.2.0[6] whereby decompressing corrupt JPEG
|
4. Fixed a regression (CVE-2012-2806) caused by 1.2.0[6] whereby decompressing
|
||||||
images (specifically, images in which the component count was erroneously set
|
corrupt JPEG images (specifically, images in which the component count was
|
||||||
to a large value) would cause libjpeg-turbo to segfault.
|
erroneously set to a large value) would cause libjpeg-turbo to segfault.
|
||||||
|
|
||||||
5. Worked around a severe performance issue with "Bobcat" (AMD Embedded APU)
|
5. Worked around a severe performance issue with "Bobcat" (AMD Embedded APU)
|
||||||
processors. The `MASKMOVDQU` instruction, which was used by the libjpeg-turbo
|
processors. The `MASKMOVDQU` instruction, which was used by the libjpeg-turbo
|
||||||
|
|||||||
36
LICENSE.md
36
LICENSE.md
@@ -14,7 +14,7 @@ libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
|||||||
This license covers the TurboJPEG API library and associated programs, as
|
This license covers the TurboJPEG API library and associated programs, as
|
||||||
well as the build system.
|
well as the build system.
|
||||||
|
|
||||||
- The zlib License, which is listed below
|
- The [zlib License](https://opensource.org/licenses/Zlib)
|
||||||
|
|
||||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||||
SIMD extensions.
|
SIMD extensions.
|
||||||
@@ -66,7 +66,7 @@ best of our understanding.
|
|||||||
|
|
||||||
2. If your binary distribution includes or uses the TurboJPEG API, then
|
2. If your binary distribution includes or uses the TurboJPEG API, then
|
||||||
your product documentation must include the text of the Modified BSD
|
your product documentation must include the text of the Modified BSD
|
||||||
License.
|
License (see below.)
|
||||||
|
|
||||||
**Origin**
|
**Origin**
|
||||||
- Clause 2 of the Modified BSD License
|
- Clause 2 of the Modified BSD License
|
||||||
@@ -91,7 +91,8 @@ best of our understanding.
|
|||||||
The Modified (3-clause) BSD License
|
The Modified (3-clause) BSD License
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
Copyright (C)\<YEAR\> \<AUTHOR\>. All Rights Reserved.
|
Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.
|
||||||
|
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are met:
|
modification, are permitted provided that the following conditions are met:
|
||||||
@@ -118,23 +119,14 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
The zlib License
|
Why Three Licenses?
|
||||||
================
|
===================
|
||||||
|
|
||||||
Copyright (C) \<YEAR\>, \<AUTHOR\>.
|
The zlib License could have been used instead of the Modified (3-clause) BSD
|
||||||
|
License, and since the IJG License effectively subsumes the distribution
|
||||||
This software is provided 'as-is', without any express or implied
|
conditions of the zlib License, this would have effectively placed
|
||||||
warranty. In no event will the authors be held liable for any damages
|
libjpeg-turbo binary distributions under the IJG License. However, the IJG
|
||||||
arising from the use of this software.
|
License specifically refers to the Independent JPEG Group and does not extend
|
||||||
|
attribution and endorsement protections to other entities. Thus, it was
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
desirable to choose a license that granted us the same protections for new code
|
||||||
including commercial applications, and to alter it and redistribute it
|
that were granted to the IJG for code derived from their software.
|
||||||
freely, subject to the following restrictions:
|
|
||||||
|
|
||||||
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 notice may not be removed or altered from any source distribution.
|
|
||||||
|
|||||||
194
README-mozilla.txt
Normal file
194
README-mozilla.txt
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
Mozilla JPEG Encoder Project
|
||||||
|
============================
|
||||||
|
|
||||||
|
mozjpeg is a fork of libjpeg-turbo that aims to speed up load times of web
|
||||||
|
pages by reducing the size (and, by extension, the transmission time) of JPEG
|
||||||
|
files. It accomplishes this by enabling optimized Huffman trees and
|
||||||
|
progressive entropy coding by default in the JPEG compressor, as well as
|
||||||
|
splitting the spectrum of DCT coefficients into separate scans and using
|
||||||
|
Trellis quantisation.
|
||||||
|
|
||||||
|
Although it is based on libjpeg-turbo, mozjpeg is not intended to be a
|
||||||
|
general-purpose or high-performance JPEG library. Its performance is highly
|
||||||
|
"asymmetric". That is, the JPEG files it generates require much more time to
|
||||||
|
compress than to decompress. When the default settings are used, mozjpeg is
|
||||||
|
considerably slower than libjpeg-turbo or even libjpeg at compressing images.
|
||||||
|
Thus, it is not generally suitable for real-time compression. It is best used
|
||||||
|
as part of a web encoding workflow.
|
||||||
|
|
||||||
|
|
||||||
|
libjpeg API Extensibility Framework
|
||||||
|
===================================
|
||||||
|
|
||||||
|
mozjpeg's implementation of the libjpeg API includes an extensibility framework
|
||||||
|
that allows new features to be added without modifying the transparent libjpeg
|
||||||
|
compress/decompress structures (which would break backward ABI compatibility.)
|
||||||
|
Extension parameters are placed into the opaque jpeg_comp_master structure, and
|
||||||
|
a set of accessor functions and globally unique tokens allows for
|
||||||
|
getting/setting those parameters without directly accessing the structure.
|
||||||
|
|
||||||
|
Currently, only the accessor functions necessary to support the mozjpeg
|
||||||
|
extensions are implemented, but the framework can be easily extended in the
|
||||||
|
future to accommodate additional simple parameter types, complex or
|
||||||
|
multi-valued parameters, or decompressor extensions.
|
||||||
|
|
||||||
|
|
||||||
|
The currently-implemented accessor functions are as follows:
|
||||||
|
|
||||||
|
boolean jpeg_c_bool_param_supported (j_compress_ptr cinfo,
|
||||||
|
J_BOOLEAN_PARAM param)
|
||||||
|
Returns TRUE if the given boolean extension parameter is supported by
|
||||||
|
this implementation of the libjpeg API, or FALSE otherwise.
|
||||||
|
|
||||||
|
void jpeg_c_set_bool_param (j_compress_ptr cinfo,
|
||||||
|
J_BOOLEAN_PARAM param, boolean value);
|
||||||
|
Set the given boolean extension parameter to the given value (TRUE or
|
||||||
|
FALSE.)
|
||||||
|
|
||||||
|
boolean jpeg_c_get_bool_param (j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
|
||||||
|
Get the value of the given boolean extension parameter (TRUE or FALSE.)
|
||||||
|
|
||||||
|
boolean jpeg_c_float_param_supported (j_compress_ptr cinfo,
|
||||||
|
J_FLOAT_PARAM param)
|
||||||
|
Returns TRUE if the given floating point extension parameter is
|
||||||
|
supported by this implementation of the libjpeg API, or FALSE
|
||||||
|
otherwise.
|
||||||
|
|
||||||
|
void jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param,
|
||||||
|
float value)
|
||||||
|
Set the given floating point extension parameter to the given value.
|
||||||
|
|
||||||
|
float jpeg_c_get_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param);
|
||||||
|
Get the value of the given floating point extension parameter.
|
||||||
|
|
||||||
|
boolean jpeg_c_int_param_supported (j_compress_ptr cinfo,
|
||||||
|
J_INT_PARAM param)
|
||||||
|
Returns TRUE if the given integer extension parameter is supported by
|
||||||
|
this implementation of the libjpeg API, or FALSE otherwise.
|
||||||
|
|
||||||
|
void jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param,
|
||||||
|
int value)
|
||||||
|
Set the given integer extension parameter to the given value.
|
||||||
|
|
||||||
|
int jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param)
|
||||||
|
Get the value of the given integer extension parameter.
|
||||||
|
|
||||||
|
|
||||||
|
Boolean Extension Parameters Supported by mozjpeg
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
* JBOOLEAN_OPTIMIZE_SCANS (default: TRUE)
|
||||||
|
Specifies whether scan parameters should be optimized. Parameter
|
||||||
|
optimization is done as in jpgcrush. jpeg_simple_progression() should be called
|
||||||
|
after setting JBOOLEAN_OPTIMIZE_SCANS.
|
||||||
|
When disabling JBOOLEAN_OPTIMIZE_SCANS, cinfo.scan_info should additionally be
|
||||||
|
set to NULL to disable use of the progressive coding mode, if so desired.
|
||||||
|
|
||||||
|
* JBOOLEAN_TRELLIS_QUANT (default: TRUE)
|
||||||
|
Specifies whether to apply trellis quantization. For each 8x8 block, trellis
|
||||||
|
quantization determines the best tradeoff between rate and distortion.
|
||||||
|
|
||||||
|
* JBOOLEAN_TRELLIS_QUANT_DC (default: TRUE)
|
||||||
|
Specifies whether to apply trellis quantization to DC coefficients.
|
||||||
|
|
||||||
|
* JBOOLEAN_TRELLIS_EOB_OPT (default: FALSE)
|
||||||
|
Specifies whether to optimize runs of zero blocks in trellis quantization.
|
||||||
|
This is applicable only when JBOOLEAN_USE_SCANS_IN_TRELLIS is enabled.
|
||||||
|
|
||||||
|
* JBOOLEAN_USE_LAMBDA_WEIGHT_TBL currently has no effect.
|
||||||
|
|
||||||
|
* JBOOLEAN_USE_SCANS_IN_TRELLIS (default: FALSE)
|
||||||
|
Specifies whether multiple scans should be considered during trellis
|
||||||
|
quantization.
|
||||||
|
|
||||||
|
* JBOOLEAN_TRELLIS_Q_OPT (default: FALSE)
|
||||||
|
Specifies whether to optimize the quantization table after trellis
|
||||||
|
quantization. If enabled, then a revised quantization table is derived so
|
||||||
|
as to minimize the reconstruction error of the quantized coefficients.
|
||||||
|
|
||||||
|
* JBOOLEAN_OVERSHOOT_DERINGING (default: TRUE)
|
||||||
|
Specifies whether overshooting is applied to samples with extreme values
|
||||||
|
(for example, 0 and 255 for 8-bit samples). Overshooting may reduce ringing
|
||||||
|
artifacts from compression, in particular in areas where black text appears
|
||||||
|
on a white background.
|
||||||
|
|
||||||
|
|
||||||
|
Floating Point Extension Parameters Supported by mozjpeg
|
||||||
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
* JFLOAT_LAMBDA_LOG_SCALE1 (default: 14.75)
|
||||||
|
JFLOAT_LAMBDA_LOG_SCALE2 (default: 16.5)
|
||||||
|
These parameters specify the lambda value used in trellis quantization. The
|
||||||
|
lambda value (Lagrange multiplier) in the
|
||||||
|
R + lambda * D
|
||||||
|
equation is derived from
|
||||||
|
lambda = 2^s1 / ((2^s2 + n) * q^2),
|
||||||
|
where s1 and s2 are the values of JFLOAT_LAMBDA_LOG_SCALE1 and
|
||||||
|
JFLOAT_LAMBDA_LOG_SCALE2, n is the average of the squared unquantized AC
|
||||||
|
coefficients within the current 8x8 block, and q is the quantization table
|
||||||
|
entry associated with the current coefficient frequency. If
|
||||||
|
JFLOAT_LAMBDA_LOG_SCALE2 is 0, then an alternate form is used that does not
|
||||||
|
rely on n:
|
||||||
|
lambda = 2^(s1-12) / q^2.
|
||||||
|
|
||||||
|
* JFLOAT_TRELLIS_DELTA_DC_WEIGHT (default: 0.0)
|
||||||
|
This parameter controls how distortion is calculated in DC trellis quantization
|
||||||
|
(enabled with JBOOLEAN_TRELLIS_QUANT_DC). It defines weighting between distortion
|
||||||
|
of the DC coefficient and distortion of the vertical gradient of DC coefficients.
|
||||||
|
The value of the parameter corresponds to the weight applied to the distortion
|
||||||
|
of the vertical gradient.
|
||||||
|
|
||||||
|
|
||||||
|
Integer Extension Parameters Supported by mozjpeg
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
* JINT_COMPRESS_PROFILE (default: JCP_MAX_COMPRESSION)
|
||||||
|
Select a compression profile, which is a set of default parameters that will
|
||||||
|
achieve a desired compression goal. This parameter controls the behavior of
|
||||||
|
the jpeg_set_defaults() function. Thus, setting JINT_COMPRESS_PROFILE does
|
||||||
|
not cause any other parameters to be modified until jpeg_set_defaults() is
|
||||||
|
called. The following compression profiles are supported:
|
||||||
|
|
||||||
|
- JCP_MAX_COMPRESSION (default)
|
||||||
|
Increase the compression ratio as much as possible, at the expense of
|
||||||
|
increased encoding time. This enables progressive entropy coding and all
|
||||||
|
mozjpeg extensions.
|
||||||
|
|
||||||
|
- JCP_FASTEST
|
||||||
|
Use the libjpeg[-turbo] defaults (baseline entropy coding, no mozjpeg
|
||||||
|
extensions enabled.)
|
||||||
|
|
||||||
|
* JINT_TRELLIS_FREQ_SPLIT (default: 8)
|
||||||
|
Specifies the position within the zigzag scan at which the split between
|
||||||
|
scans is positioned in the context of trellis quantization.
|
||||||
|
JBOOLEAN_USE_SCANS_IN_TRELLIS must be enabled for this parameter to have any
|
||||||
|
effect.
|
||||||
|
|
||||||
|
* JINT_TRELLIS_NUM_LOOPS (default: 1)
|
||||||
|
Specifies the number of trellis quantization passes. Huffman tables are
|
||||||
|
updated between passes.
|
||||||
|
|
||||||
|
* JINT_BASE_QUANT_TBL_IDX (default: 3)
|
||||||
|
Specifies which quantization table set to use. The following options are
|
||||||
|
available:
|
||||||
|
0 = Tables from JPEG Annex K
|
||||||
|
1 = Flat table
|
||||||
|
2 = Table tuned for MSSIM on Kodak image set
|
||||||
|
3 = Table from http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
|
||||||
|
4 = Table tuned for PSNR-HVS-M on Kodak image set
|
||||||
|
5 = Table from: Relevance of Human Vision to JPEG-DCT Compression
|
||||||
|
(1992) Klein, Silverstein and Carney
|
||||||
|
6 = Table from: DCTune Perceptual Optimization of Compressed Dental X-Rays
|
||||||
|
(1997) Watson, Taylor, Borthwick
|
||||||
|
7 = Table from: A Visual Detection Model for DCT Coefficient Quantization
|
||||||
|
(12/9/93) Ahumada, Watson, Peterson
|
||||||
|
8 = Table from: An Improved Detection Model for DCT Coefficient Quantization
|
||||||
|
(1993) Peterson, Ahumada and Watson
|
||||||
|
|
||||||
|
* JINT_DC_SCAN_OPT_MODE (default: 1)
|
||||||
|
Specifies the DC scan optimization mode. The following options are
|
||||||
|
available:
|
||||||
|
0 = One scan for all components
|
||||||
|
1 = One scan per component
|
||||||
|
2 = Optimize between one scan for all components and one scan for the first
|
||||||
|
component plus one scan for the remaining components
|
||||||
346
README-turbo.txt
Normal file
346
README-turbo.txt
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
Background
|
||||||
|
==========
|
||||||
|
|
||||||
|
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
|
||||||
|
AVX2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression
|
||||||
|
on x86, x86-64, ARM, and PowerPC systems, as well as progressive JPEG
|
||||||
|
compression on x86 and x86-64 systems. On such systems, libjpeg-turbo is
|
||||||
|
generally 2-6x as fast as libjpeg, all else being equal. On other types of
|
||||||
|
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
|
||||||
|
virtue of its highly-optimized Huffman coding routines. In many cases, the
|
||||||
|
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
|
||||||
|
|
||||||
|
libjpeg-turbo implements both the traditional libjpeg API as well as the less
|
||||||
|
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
|
||||||
|
colorspace extensions that allow it to compress from/decompress to 32-bit and
|
||||||
|
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
|
||||||
|
interface.
|
||||||
|
|
||||||
|
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
|
||||||
|
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
|
||||||
|
VirtualGL projects made numerous enhancements to the codec in 2009, and in
|
||||||
|
early 2010, libjpeg-turbo spun off into an independent project, with the goal
|
||||||
|
of making high-speed JPEG compression/decompression technology available to a
|
||||||
|
broader range of users and developers.
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
=======
|
||||||
|
|
||||||
|
libjpeg-turbo is covered by three compatible BSD-style open source licenses.
|
||||||
|
Refer to [LICENSE.md](LICENSE.md) for a roll-up of license terms.
|
||||||
|
|
||||||
|
|
||||||
|
Building libjpeg-turbo
|
||||||
|
======================
|
||||||
|
|
||||||
|
Refer to [BUILDING.md](BUILDING.md) for complete instructions.
|
||||||
|
|
||||||
|
|
||||||
|
Using libjpeg-turbo
|
||||||
|
===================
|
||||||
|
|
||||||
|
libjpeg-turbo includes two APIs that can be used to compress and decompress
|
||||||
|
JPEG images:
|
||||||
|
|
||||||
|
- **TurboJPEG API**<br>
|
||||||
|
This API provides an easy-to-use interface for compressing and decompressing
|
||||||
|
JPEG images in memory. It also provides some functionality that would not be
|
||||||
|
straightforward to achieve using the underlying libjpeg API, such as
|
||||||
|
generating planar YUV images and performing multiple simultaneous lossless
|
||||||
|
transforms on an image. The Java interface for libjpeg-turbo is written on
|
||||||
|
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
|
||||||
|
users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
|
||||||
|
[TJExample.java](java/TJExample.java) for examples of its usage and to
|
||||||
|
<http://libjpeg-turbo.org/Documentation/Documentation> for API documentation.
|
||||||
|
|
||||||
|
- **libjpeg API**<br>
|
||||||
|
This is the de facto industry-standard API for compressing and decompressing
|
||||||
|
JPEG images. It is more difficult to use than the TurboJPEG API but also
|
||||||
|
more powerful. The libjpeg API implementation in libjpeg-turbo is both
|
||||||
|
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
|
||||||
|
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
|
||||||
|
(see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
|
||||||
|
of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
|
||||||
|
|
||||||
|
There is no significant performance advantage to either API when both are used
|
||||||
|
to perform similar operations.
|
||||||
|
|
||||||
|
Colorspace Extensions
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
libjpeg-turbo includes extensions that allow JPEG images to be compressed
|
||||||
|
directly from (and decompressed directly to) buffers that use BGR, BGRX,
|
||||||
|
RGBX, XBGR, and XRGB pixel ordering. This is implemented with ten new
|
||||||
|
colorspace constants:
|
||||||
|
|
||||||
|
JCS_EXT_RGB /* red/green/blue */
|
||||||
|
JCS_EXT_RGBX /* red/green/blue/x */
|
||||||
|
JCS_EXT_BGR /* blue/green/red */
|
||||||
|
JCS_EXT_BGRX /* blue/green/red/x */
|
||||||
|
JCS_EXT_XBGR /* x/blue/green/red */
|
||||||
|
JCS_EXT_XRGB /* x/red/green/blue */
|
||||||
|
JCS_EXT_RGBA /* red/green/blue/alpha */
|
||||||
|
JCS_EXT_BGRA /* blue/green/red/alpha */
|
||||||
|
JCS_EXT_ABGR /* alpha/blue/green/red */
|
||||||
|
JCS_EXT_ARGB /* alpha/red/green/blue */
|
||||||
|
|
||||||
|
Setting `cinfo.in_color_space` (compression) or `cinfo.out_color_space`
|
||||||
|
(decompression) to one of these values will cause libjpeg-turbo to read the
|
||||||
|
red, green, and blue values from (or write them to) the appropriate position in
|
||||||
|
the pixel when compressing from/decompressing to an RGB buffer.
|
||||||
|
|
||||||
|
Your application can check for the existence of these extensions at compile
|
||||||
|
time with:
|
||||||
|
|
||||||
|
#ifdef JCS_EXTENSIONS
|
||||||
|
|
||||||
|
At run time, attempting to use these extensions with a libjpeg implementation
|
||||||
|
that does not support them will result in a "Bogus input colorspace" error.
|
||||||
|
Applications can trap this error in order to test whether run-time support is
|
||||||
|
available for the colorspace extensions.
|
||||||
|
|
||||||
|
When using the RGBX, BGRX, XBGR, and XRGB colorspaces during decompression, the
|
||||||
|
X byte is undefined, and in order to ensure the best performance, libjpeg-turbo
|
||||||
|
can set that byte to whatever value it wishes. If an application expects the X
|
||||||
|
byte to be used as an alpha channel, then it should specify `JCS_EXT_RGBA`,
|
||||||
|
`JCS_EXT_BGRA`, `JCS_EXT_ABGR`, or `JCS_EXT_ARGB`. When these colorspace
|
||||||
|
constants are used, the X byte is guaranteed to be 0xFF, which is interpreted
|
||||||
|
as opaque.
|
||||||
|
|
||||||
|
Your application can check for the existence of the alpha channel colorspace
|
||||||
|
extensions at compile time with:
|
||||||
|
|
||||||
|
#ifdef JCS_ALPHA_EXTENSIONS
|
||||||
|
|
||||||
|
[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
|
||||||
|
how to check for the existence of the colorspace extensions at compile time and
|
||||||
|
run time.
|
||||||
|
|
||||||
|
libjpeg v7 and v8 API/ABI Emulation
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
With libjpeg v7 and v8, new features were added that necessitated extending the
|
||||||
|
compression and decompression structures. Unfortunately, due to the exposed
|
||||||
|
nature of those structures, extending them also necessitated breaking backward
|
||||||
|
ABI compatibility with previous libjpeg releases. Thus, programs that were
|
||||||
|
built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
|
||||||
|
based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not
|
||||||
|
as widely used as v6b, enough programs (including a few Linux distros) made
|
||||||
|
the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs
|
||||||
|
in libjpeg-turbo. It should be noted, however, that this feature was added
|
||||||
|
primarily so that applications that had already been compiled to use libjpeg
|
||||||
|
v7+ could take advantage of accelerated baseline JPEG encoding/decoding
|
||||||
|
without recompiling. libjpeg-turbo does not claim to support all of the
|
||||||
|
libjpeg v7+ features, nor to produce identical output to libjpeg v7+ in all
|
||||||
|
cases (see below.)
|
||||||
|
|
||||||
|
By passing an argument of `--with-jpeg7` or `--with-jpeg8` to `configure`, or
|
||||||
|
an argument of `-DWITH_JPEG7=1` or `-DWITH_JPEG8=1` to `cmake`, you can build a
|
||||||
|
version of libjpeg-turbo that emulates the libjpeg v7 or v8 ABI, so that
|
||||||
|
programs that are built against libjpeg v7 or v8 can be run with libjpeg-turbo.
|
||||||
|
The following section describes which libjpeg v7+ features are supported and
|
||||||
|
which aren't.
|
||||||
|
|
||||||
|
### Support for libjpeg v7 and v8 Features
|
||||||
|
|
||||||
|
#### Fully supported
|
||||||
|
|
||||||
|
- **libjpeg: IDCT scaling extensions in decompressor**<br>
|
||||||
|
libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
|
||||||
|
1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
|
||||||
|
and 1/2 are SIMD-accelerated.)
|
||||||
|
|
||||||
|
- **libjpeg: Arithmetic coding**
|
||||||
|
|
||||||
|
- **libjpeg: In-memory source and destination managers**<br>
|
||||||
|
See notes below.
|
||||||
|
|
||||||
|
- **cjpeg: Separate quality settings for luminance and chrominance**<br>
|
||||||
|
Note that the libpjeg v7+ API was extended to accommodate this feature only
|
||||||
|
for convenience purposes. It has always been possible to implement this
|
||||||
|
feature with libjpeg v6b (see rdswitch.c for an example.)
|
||||||
|
|
||||||
|
- **cjpeg: 32-bit BMP support**
|
||||||
|
|
||||||
|
- **cjpeg: `-rgb` option**
|
||||||
|
|
||||||
|
- **jpegtran: Lossless cropping**
|
||||||
|
|
||||||
|
- **jpegtran: `-perfect` option**
|
||||||
|
|
||||||
|
- **jpegtran: Forcing width/height when performing lossless crop**
|
||||||
|
|
||||||
|
- **rdjpgcom: `-raw` option**
|
||||||
|
|
||||||
|
- **rdjpgcom: Locale awareness**
|
||||||
|
|
||||||
|
|
||||||
|
#### Not supported
|
||||||
|
|
||||||
|
NOTE: As of this writing, extensive research has been conducted into the
|
||||||
|
usefulness of DCT scaling as a means of data reduction and SmartScale as a
|
||||||
|
means of quality improvement. The reader is invited to peruse the research at
|
||||||
|
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
|
||||||
|
but it is the general belief of our project that these features have not
|
||||||
|
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
||||||
|
|
||||||
|
- **libjpeg: DCT scaling in compressor**<br>
|
||||||
|
`cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
|
||||||
|
There is no technical reason why DCT scaling could not be supported when
|
||||||
|
emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
|
||||||
|
below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
|
||||||
|
8/9 would be available, which is of limited usefulness.
|
||||||
|
|
||||||
|
- **libjpeg: SmartScale**<br>
|
||||||
|
`cinfo.block_size` is silently ignored.
|
||||||
|
SmartScale is an extension to the JPEG format that allows for DCT block
|
||||||
|
sizes other than 8x8. Providing support for this new format would be
|
||||||
|
feasible (particularly without full acceleration.) However, until/unless
|
||||||
|
the format becomes either an official industry standard or, at minimum, an
|
||||||
|
accepted solution in the community, we are hesitant to implement it, as
|
||||||
|
there is no sense of whether or how it might change in the future. It is
|
||||||
|
our belief that SmartScale has not demonstrated sufficient usefulness as a
|
||||||
|
lossless format nor as a means of quality enhancement, and thus our primary
|
||||||
|
interest in providing this feature would be as a means of supporting
|
||||||
|
additional DCT scaling factors.
|
||||||
|
|
||||||
|
- **libjpeg: Fancy downsampling in compressor**<br>
|
||||||
|
`cinfo.do_fancy_downsampling` is silently ignored.
|
||||||
|
This requires the DCT scaling feature, which is not supported.
|
||||||
|
|
||||||
|
- **jpegtran: Scaling**<br>
|
||||||
|
This requires both the DCT scaling and SmartScale features, which are not
|
||||||
|
supported.
|
||||||
|
|
||||||
|
- **Lossless RGB JPEG files**<br>
|
||||||
|
This requires the SmartScale feature, which is not supported.
|
||||||
|
|
||||||
|
### What About libjpeg v9?
|
||||||
|
|
||||||
|
libjpeg v9 introduced yet another field to the JPEG compression structure
|
||||||
|
(`color_transform`), thus making the ABI backward incompatible with that of
|
||||||
|
libjpeg v8. This new field was introduced solely for the purpose of supporting
|
||||||
|
lossless SmartScale encoding. Furthermore, there was actually no reason to
|
||||||
|
extend the API in this manner, as the color transform could have just as easily
|
||||||
|
been activated by way of a new JPEG colorspace constant, thus preserving
|
||||||
|
backward ABI compatibility.
|
||||||
|
|
||||||
|
Our research (see link above) has shown that lossless SmartScale does not
|
||||||
|
generally accomplish anything that can't already be accomplished better with
|
||||||
|
existing, standard lossless formats. Therefore, at this time it is our belief
|
||||||
|
that there is not sufficient technical justification for software projects to
|
||||||
|
upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
|
||||||
|
technical justification for us to emulate the libjpeg v9 ABI.
|
||||||
|
|
||||||
|
In-Memory Source/Destination Managers
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
By default, libjpeg-turbo 1.3 and later includes the `jpeg_mem_src()` and
|
||||||
|
`jpeg_mem_dest()` functions, even when not emulating the libjpeg v8 API/ABI.
|
||||||
|
Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8
|
||||||
|
API/ABI emulation in order to use the in-memory source/destination managers,
|
||||||
|
but several projects requested that those functions be included when emulating
|
||||||
|
the libjpeg v6b API/ABI as well. This allows the use of those functions by
|
||||||
|
programs that need them, without breaking ABI compatibility for programs that
|
||||||
|
don't, and it allows those functions to be provided in the "official"
|
||||||
|
libjpeg-turbo binaries.
|
||||||
|
|
||||||
|
Those who are concerned about maintaining strict conformance with the libjpeg
|
||||||
|
v6b or v7 API can pass an argument of `--without-mem-srcdst` to `configure` or
|
||||||
|
an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to building
|
||||||
|
libjpeg-turbo. This will restore the pre-1.3 behavior, in which
|
||||||
|
`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
|
||||||
|
libjpeg v8 API/ABI.
|
||||||
|
|
||||||
|
On Un*x systems, including the in-memory source/destination managers changes
|
||||||
|
the dynamic library version from 62.1.0 to 62.2.0 if using libjpeg v6b API/ABI
|
||||||
|
emulation and from 7.1.0 to 7.2.0 if using libjpeg v7 API/ABI emulation.
|
||||||
|
|
||||||
|
Note that, on most Un*x systems, the dynamic linker will not look for a
|
||||||
|
function in a library until that function is actually used. Thus, if a program
|
||||||
|
is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
|
||||||
|
`jpeg_mem_dest()`, that program will not fail if run against an older version
|
||||||
|
of libjpeg-turbo or against libjpeg v7- until the program actually tries to
|
||||||
|
call `jpeg_mem_src()` or `jpeg_mem_dest()`. Such is not the case on Windows.
|
||||||
|
If a program is built against the libjpeg-turbo 1.3+ DLL and uses
|
||||||
|
`jpeg_mem_src()` or `jpeg_mem_dest()`, then it must use the libjpeg-turbo 1.3+
|
||||||
|
DLL at run time.
|
||||||
|
|
||||||
|
Both cjpeg and djpeg have been extended to allow testing the in-memory
|
||||||
|
source/destination manager functions. See their respective man pages for more
|
||||||
|
details.
|
||||||
|
|
||||||
|
|
||||||
|
Mathematical Compatibility
|
||||||
|
==========================
|
||||||
|
|
||||||
|
For the most part, libjpeg-turbo should produce identical output to libjpeg
|
||||||
|
v6b. The one exception to this is when using the floating point DCT/IDCT, in
|
||||||
|
which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
|
||||||
|
following reasons:
|
||||||
|
|
||||||
|
- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
|
||||||
|
slightly more accurate than the implementation in libjpeg v6b, but not by
|
||||||
|
any amount perceptible to human vision (generally in the range of 0.01 to
|
||||||
|
0.08 dB gain in PNSR.)
|
||||||
|
|
||||||
|
- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
|
||||||
|
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
|
||||||
|
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
|
||||||
|
however, that this algorithm basically brings the accuracy of the floating
|
||||||
|
point IDCT in line with the accuracy of the slow integer IDCT. The floating
|
||||||
|
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
|
||||||
|
produce significantly more accuracy than the slow integer algorithms (to put
|
||||||
|
numbers on this, the typical difference in PNSR between the two algorithms
|
||||||
|
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
|
||||||
|
range of the quality scale is typically more like a 1.0 dB difference.)
|
||||||
|
|
||||||
|
- If the floating point algorithms in libjpeg-turbo are not implemented using
|
||||||
|
SIMD instructions on a particular platform, then the accuracy of the
|
||||||
|
floating point DCT/IDCT can depend on the compiler settings.
|
||||||
|
|
||||||
|
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
|
||||||
|
still using the same algorithms as libjpeg v6b, so there are several specific
|
||||||
|
cases in which libjpeg-turbo cannot be expected to produce the same output as
|
||||||
|
libjpeg v8:
|
||||||
|
|
||||||
|
- When decompressing using scaling factors of 1/2 and 1/4, because libjpeg v8
|
||||||
|
implements those scaling algorithms differently than libjpeg v6b does, and
|
||||||
|
libjpeg-turbo's SIMD extensions are based on the libjpeg v6b behavior.
|
||||||
|
|
||||||
|
- When using chrominance subsampling, because libjpeg v8 implements this
|
||||||
|
with its DCT/IDCT scaling algorithms rather than with a separate
|
||||||
|
downsampling/upsampling algorithm. In our testing, the subsampled/upsampled
|
||||||
|
output of libjpeg v8 is less accurate than that of libjpeg v6b for this
|
||||||
|
reason.
|
||||||
|
|
||||||
|
- When decompressing using a scaling factor > 1 and merged (AKA "non-fancy" or
|
||||||
|
"non-smooth") chrominance upsampling, because libjpeg v8 does not support
|
||||||
|
merged upsampling with scaling factors > 1.
|
||||||
|
|
||||||
|
|
||||||
|
Performance Pitfalls
|
||||||
|
====================
|
||||||
|
|
||||||
|
Restart Markers
|
||||||
|
---------------
|
||||||
|
|
||||||
|
The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
|
||||||
|
in a way that makes the rest of the libjpeg infrastructure happy, so it is
|
||||||
|
necessary to use the slow Huffman decoder when decompressing a JPEG image that
|
||||||
|
has restart markers. This can cause the decompression performance to drop by
|
||||||
|
as much as 20%, but the performance will still be much greater than that of
|
||||||
|
libjpeg. Many consumer packages, such as PhotoShop, use restart markers when
|
||||||
|
generating JPEG images, so images generated by those programs will experience
|
||||||
|
this issue.
|
||||||
|
|
||||||
|
Fast Integer Forward DCT at High Quality Levels
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
The algorithm used by the SIMD-accelerated quantization function cannot produce
|
||||||
|
correct results whenever the fast integer forward DCT is used along with a JPEG
|
||||||
|
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
|
||||||
|
function in those cases. This causes performance to drop by as much as 40%.
|
||||||
|
It is therefore strongly advised that you use the slow integer forward DCT
|
||||||
|
whenever encoding images with a JPEG quality of 98 or higher.
|
||||||
42
README.ijg
42
README.ijg
@@ -214,14 +214,14 @@ Continuous-tone Still Images, Part 2: Compliance testing" and has document
|
|||||||
numbers ISO/IEC IS 10918-2, ITU-T T.83.
|
numbers ISO/IEC IS 10918-2, ITU-T T.83.
|
||||||
|
|
||||||
The JPEG standard does not specify all details of an interchangeable file
|
The JPEG standard does not specify all details of an interchangeable file
|
||||||
format. For the omitted details we follow the "JFIF" conventions, revision
|
format. For the omitted details, we follow the "JFIF" conventions, revision
|
||||||
1.02. JFIF 1.02 has been adopted as an Ecma International Technical Report
|
1.02. JFIF version 1 has been adopted as ISO/IEC 10918-5 (05/2013) and
|
||||||
and thus received a formal publication status. It is available as a free
|
Recommendation ITU-T T.871 (05/2011): Information technology - Digital
|
||||||
download in PDF format from
|
compression and coding of continuous-tone still images: JPEG File Interchange
|
||||||
http://www.ecma-international.org/publications/techreports/E-TR-098.htm.
|
Format (JFIF). It is available as a free download in PDF file format from
|
||||||
A PostScript version of the JFIF document is available at
|
https://www.iso.org/standard/54989.html and http://www.itu.int/rec/T-REC-T.871.
|
||||||
http://www.ijg.org/files/jfif.ps.gz. There is also a plain text version at
|
A PDF file of the older JFIF 1.02 specification is available at
|
||||||
http://www.ijg.org/files/jfif.txt.gz, but it is missing the figures.
|
http://www.w3.org/Graphics/JPEG/jfif3.pdf.
|
||||||
|
|
||||||
The TIFF 6.0 file format specification can be obtained by FTP from
|
The TIFF 6.0 file format specification can be obtained by FTP from
|
||||||
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
|
||||||
@@ -253,18 +253,22 @@ with body
|
|||||||
send usenet/news.answers/jpeg-faq/part2
|
send usenet/news.answers/jpeg-faq/part2
|
||||||
|
|
||||||
|
|
||||||
FILE FORMAT WARS
|
FILE FORMAT COMPATIBILITY
|
||||||
================
|
=========================
|
||||||
|
|
||||||
The ISO/IEC JTC1/SC29/WG1 standards committee (also known as JPEG, together
|
This software implements ITU T.81 | ISO/IEC 10918 with some extensions from
|
||||||
with ITU-T SG16) currently promotes different formats containing the name
|
ITU T.871 | ISO/IEC 10918-5 (JPEG File Interchange Format-- see REFERENCES).
|
||||||
"JPEG" which are incompatible with original DCT-based JPEG. IJG therefore does
|
Informally, the term "JPEG image" or "JPEG file" most often refers to JFIF or
|
||||||
not support these formats (see REFERENCES). Indeed, one of the original
|
a subset thereof, but there are other formats containing the name "JPEG" that
|
||||||
reasons for developing this free software was to help force convergence on
|
are incompatible with the DCT-based JPEG standard or with JFIF (for instance,
|
||||||
common, interoperable format standards for JPEG files.
|
JPEG 2000 and JPEG XR). This software therefore does not support these
|
||||||
Don't use an incompatible file format!
|
formats. Indeed, one of the original reasons for developing this free software
|
||||||
(In any case, our decoder will remain capable of reading existing JPEG
|
was to help force convergence on a common, interoperable format standard for
|
||||||
image files indefinitely.)
|
JPEG files.
|
||||||
|
|
||||||
|
JFIF is a minimal or "low end" representation. TIFF/JPEG (TIFF revision 6.0 as
|
||||||
|
modified by TIFF Technical Note #2) can be used for "high end" applications
|
||||||
|
that need to record a lot of additional data about an image.
|
||||||
|
|
||||||
|
|
||||||
TO DO
|
TO DO
|
||||||
|
|||||||
356
README.md
356
README.md
@@ -1,345 +1,37 @@
|
|||||||
Background
|
> ## News: About Instagram's flaw
|
||||||
==========
|
>
|
||||||
|
> Instagram had [a security vulnerability](https://m.facebook.com/security/advisories/cve-2020-1895). Instagram uses MozJPEG. These two facts were somewhat conflated in the [vulnerability report](https://research.checkpoint.com/2020/instagram_rce-code-execution-vulnerability-in-instagram-app-for-android-and-ios/) that gets reposted all over the Internet right now.
|
||||||
|
|
||||||
libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2,
|
> MozJPEG is **NOT** affected by this vulnerability. The issue was in Facebook's own integration code, unique to only Instagram, and not in MozJPEG. There will be no MozJPEG patches in response to that report, because it's not a MozJPEG issue.
|
||||||
AVX2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression
|
|
||||||
on x86, x86-64, ARM, and PowerPC systems. On such systems, libjpeg-turbo is
|
|
||||||
generally 2-6x as fast as libjpeg, all else being equal. On other types of
|
|
||||||
systems, libjpeg-turbo can still outperform libjpeg by a significant amount, by
|
|
||||||
virtue of its highly-optimized Huffman coding routines. In many cases, the
|
|
||||||
performance of libjpeg-turbo rivals that of proprietary high-speed JPEG codecs.
|
|
||||||
|
|
||||||
libjpeg-turbo implements both the traditional libjpeg API as well as the less
|
----
|
||||||
powerful but more straightforward TurboJPEG API. libjpeg-turbo also features
|
|
||||||
colorspace extensions that allow it to compress from/decompress to 32-bit and
|
|
||||||
big-endian pixel buffers (RGBX, XBGR, etc.), as well as a full-featured Java
|
|
||||||
interface.
|
|
||||||
|
|
||||||
libjpeg-turbo was originally based on libjpeg/SIMD, an MMX-accelerated
|
Mozilla JPEG Encoder Project [](https://ci.appveyor.com/project/kornel/mozjpeg-4ekrx)
|
||||||
derivative of libjpeg v6b developed by Miyasaka Masaru. The TigerVNC and
|
============================
|
||||||
VirtualGL projects made numerous enhancements to the codec in 2009, and in
|
|
||||||
early 2010, libjpeg-turbo spun off into an independent project, with the goal
|
|
||||||
of making high-speed JPEG compression/decompression technology available to a
|
|
||||||
broader range of users and developers.
|
|
||||||
|
|
||||||
|
MozJPEG reduces file sizes of JPEG images while retaining quality and compatibility with the vast majority of the world's deployed decoders.
|
||||||
|
|
||||||
License
|
MozJPEG is based on [libjpeg-turbo](https://github.com/libjpeg-turbo/libjpeg-turbo). **Please send pull requests to libjpeg-turbo** if the changes aren't specific to newly-added MozJPEG-only compression code. This project aims to keep differences with libjpeg-turbo minimal, so whenever possible, improvements and bug fixes should go there first.
|
||||||
=======
|
|
||||||
|
|
||||||
libjpeg-turbo is covered by three compatible BSD-style open source licenses.
|
It's compatible with libjpeg API and ABI, and can be used as a drop-in replacement for libjpeg. MozJPEG makes tradeoffs that are intended to benefit Web use cases and focuses solely on improving encoding, so it's best used as part of a Web encoding workflow.
|
||||||
Refer to [LICENSE.md](LICENSE.md) for a roll-up of license terms.
|
|
||||||
|
|
||||||
|
MozJPEG is meant to be used as a library in graphics programs and image processing tools. We include a demo `cjpeg` tool, but it's not intended for serious use. We encourage authors of graphics programs to use MozJPEG's [C API](libjpeg.txt) instead.
|
||||||
|
|
||||||
Building libjpeg-turbo
|
## Features
|
||||||
======================
|
|
||||||
|
|
||||||
Refer to [BUILDING.md](BUILDING.md) for complete instructions.
|
* Progressive encoding with "jpegrescan" optimization. It can be applied to any JPEG file (with `jpegtran`) to losslessly reduce file size.
|
||||||
|
* Trellis quantization. When converting other formats to JPEG it maximizes quality/filesize ratio.
|
||||||
|
* Comes with new quantization table presets, e.g. tuned for high-resolution displays.
|
||||||
|
* Fully compatible with all web browsers.
|
||||||
|
* Can be seamlessly integrated into any program using libjpeg.
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
Using libjpeg-turbo
|
* [Latest release](https://github.com/mozilla/mozjpeg/releases/latest)
|
||||||
===================
|
* [Overview of 3.0 features](https://calendar.perfplanet.com/2014/mozjpeg-3-0/)
|
||||||
|
* [Version 2.0 Announcement](https://blog.mozilla.org/research/2014/07/15/mozilla-advances-jpeg-encoding-with-mozjpeg-2-0/)
|
||||||
|
* [Version 1.0 Announcement](https://blog.mozilla.org/research/2014/03/05/introducing-the-mozjpeg-project/)
|
||||||
|
|
||||||
libjpeg-turbo includes two APIs that can be used to compress and decompress
|
## Compiling
|
||||||
JPEG images:
|
|
||||||
|
|
||||||
- **TurboJPEG API**<br>
|
See [BUILDING](BUILDING.md).
|
||||||
This API provides an easy-to-use interface for compressing and decompressing
|
|
||||||
JPEG images in memory. It also provides some functionality that would not be
|
|
||||||
straightforward to achieve using the underlying libjpeg API, such as
|
|
||||||
generating planar YUV images and performing multiple simultaneous lossless
|
|
||||||
transforms on an image. The Java interface for libjpeg-turbo is written on
|
|
||||||
top of the TurboJPEG API. The TurboJPEG API is recommended for first-time
|
|
||||||
users of libjpeg-turbo. Refer to [tjexample.c](tjexample.c) and
|
|
||||||
[TJExample.java](java/TJExample.java) for examples of its usage and to
|
|
||||||
<http://libjpeg-turbo.org/Documentation/Documentation> for API documentation.
|
|
||||||
|
|
||||||
- **libjpeg API**<br>
|
|
||||||
This is the de facto industry-standard API for compressing and decompressing
|
|
||||||
JPEG images. It is more difficult to use than the TurboJPEG API but also
|
|
||||||
more powerful. The libjpeg API implementation in libjpeg-turbo is both
|
|
||||||
API/ABI-compatible and mathematically compatible with libjpeg v6b. It can
|
|
||||||
also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8
|
|
||||||
(see below.) Refer to [cjpeg.c](cjpeg.c) and [djpeg.c](djpeg.c) for examples
|
|
||||||
of its usage and to [libjpeg.txt](libjpeg.txt) for API documentation.
|
|
||||||
|
|
||||||
There is no significant performance advantage to either API when both are used
|
|
||||||
to perform similar operations.
|
|
||||||
|
|
||||||
Colorspace Extensions
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
libjpeg-turbo includes extensions that allow JPEG images to be compressed
|
|
||||||
directly from (and decompressed directly to) buffers that use BGR, BGRX,
|
|
||||||
RGBX, XBGR, and XRGB pixel ordering. This is implemented with ten new
|
|
||||||
colorspace constants:
|
|
||||||
|
|
||||||
JCS_EXT_RGB /* red/green/blue */
|
|
||||||
JCS_EXT_RGBX /* red/green/blue/x */
|
|
||||||
JCS_EXT_BGR /* blue/green/red */
|
|
||||||
JCS_EXT_BGRX /* blue/green/red/x */
|
|
||||||
JCS_EXT_XBGR /* x/blue/green/red */
|
|
||||||
JCS_EXT_XRGB /* x/red/green/blue */
|
|
||||||
JCS_EXT_RGBA /* red/green/blue/alpha */
|
|
||||||
JCS_EXT_BGRA /* blue/green/red/alpha */
|
|
||||||
JCS_EXT_ABGR /* alpha/blue/green/red */
|
|
||||||
JCS_EXT_ARGB /* alpha/red/green/blue */
|
|
||||||
|
|
||||||
Setting `cinfo.in_color_space` (compression) or `cinfo.out_color_space`
|
|
||||||
(decompression) to one of these values will cause libjpeg-turbo to read the
|
|
||||||
red, green, and blue values from (or write them to) the appropriate position in
|
|
||||||
the pixel when compressing from/decompressing to an RGB buffer.
|
|
||||||
|
|
||||||
Your application can check for the existence of these extensions at compile
|
|
||||||
time with:
|
|
||||||
|
|
||||||
#ifdef JCS_EXTENSIONS
|
|
||||||
|
|
||||||
At run time, attempting to use these extensions with a libjpeg implementation
|
|
||||||
that does not support them will result in a "Bogus input colorspace" error.
|
|
||||||
Applications can trap this error in order to test whether run-time support is
|
|
||||||
available for the colorspace extensions.
|
|
||||||
|
|
||||||
When using the RGBX, BGRX, XBGR, and XRGB colorspaces during decompression, the
|
|
||||||
X byte is undefined, and in order to ensure the best performance, libjpeg-turbo
|
|
||||||
can set that byte to whatever value it wishes. If an application expects the X
|
|
||||||
byte to be used as an alpha channel, then it should specify `JCS_EXT_RGBA`,
|
|
||||||
`JCS_EXT_BGRA`, `JCS_EXT_ABGR`, or `JCS_EXT_ARGB`. When these colorspace
|
|
||||||
constants are used, the X byte is guaranteed to be 0xFF, which is interpreted
|
|
||||||
as opaque.
|
|
||||||
|
|
||||||
Your application can check for the existence of the alpha channel colorspace
|
|
||||||
extensions at compile time with:
|
|
||||||
|
|
||||||
#ifdef JCS_ALPHA_EXTENSIONS
|
|
||||||
|
|
||||||
[jcstest.c](jcstest.c), located in the libjpeg-turbo source tree, demonstrates
|
|
||||||
how to check for the existence of the colorspace extensions at compile time and
|
|
||||||
run time.
|
|
||||||
|
|
||||||
libjpeg v7 and v8 API/ABI Emulation
|
|
||||||
-----------------------------------
|
|
||||||
|
|
||||||
With libjpeg v7 and v8, new features were added that necessitated extending the
|
|
||||||
compression and decompression structures. Unfortunately, due to the exposed
|
|
||||||
nature of those structures, extending them also necessitated breaking backward
|
|
||||||
ABI compatibility with previous libjpeg releases. Thus, programs that were
|
|
||||||
built to use libjpeg v7 or v8 did not work with libjpeg-turbo, since it is
|
|
||||||
based on the libjpeg v6b code base. Although libjpeg v7 and v8 are not
|
|
||||||
as widely used as v6b, enough programs (including a few Linux distros) made
|
|
||||||
the switch that there was a demand to emulate the libjpeg v7 and v8 ABIs
|
|
||||||
in libjpeg-turbo. It should be noted, however, that this feature was added
|
|
||||||
primarily so that applications that had already been compiled to use libjpeg
|
|
||||||
v7+ could take advantage of accelerated baseline JPEG encoding/decoding
|
|
||||||
without recompiling. libjpeg-turbo does not claim to support all of the
|
|
||||||
libjpeg v7+ features, nor to produce identical output to libjpeg v7+ in all
|
|
||||||
cases (see below.)
|
|
||||||
|
|
||||||
By passing an argument of `--with-jpeg7` or `--with-jpeg8` to `configure`, or
|
|
||||||
an argument of `-DWITH_JPEG7=1` or `-DWITH_JPEG8=1` to `cmake`, you can build a
|
|
||||||
version of libjpeg-turbo that emulates the libjpeg v7 or v8 ABI, so that
|
|
||||||
programs that are built against libjpeg v7 or v8 can be run with libjpeg-turbo.
|
|
||||||
The following section describes which libjpeg v7+ features are supported and
|
|
||||||
which aren't.
|
|
||||||
|
|
||||||
### Support for libjpeg v7 and v8 Features
|
|
||||||
|
|
||||||
#### Fully supported
|
|
||||||
|
|
||||||
- **libjpeg: IDCT scaling extensions in decompressor**<br>
|
|
||||||
libjpeg-turbo supports IDCT scaling with scaling factors of 1/8, 1/4, 3/8,
|
|
||||||
1/2, 5/8, 3/4, 7/8, 9/8, 5/4, 11/8, 3/2, 13/8, 7/4, 15/8, and 2/1 (only 1/4
|
|
||||||
and 1/2 are SIMD-accelerated.)
|
|
||||||
|
|
||||||
- **libjpeg: Arithmetic coding**
|
|
||||||
|
|
||||||
- **libjpeg: In-memory source and destination managers**<br>
|
|
||||||
See notes below.
|
|
||||||
|
|
||||||
- **cjpeg: Separate quality settings for luminance and chrominance**<br>
|
|
||||||
Note that the libpjeg v7+ API was extended to accommodate this feature only
|
|
||||||
for convenience purposes. It has always been possible to implement this
|
|
||||||
feature with libjpeg v6b (see rdswitch.c for an example.)
|
|
||||||
|
|
||||||
- **cjpeg: 32-bit BMP support**
|
|
||||||
|
|
||||||
- **cjpeg: `-rgb` option**
|
|
||||||
|
|
||||||
- **jpegtran: Lossless cropping**
|
|
||||||
|
|
||||||
- **jpegtran: `-perfect` option**
|
|
||||||
|
|
||||||
- **jpegtran: Forcing width/height when performing lossless crop**
|
|
||||||
|
|
||||||
- **rdjpgcom: `-raw` option**
|
|
||||||
|
|
||||||
- **rdjpgcom: Locale awareness**
|
|
||||||
|
|
||||||
|
|
||||||
#### Not supported
|
|
||||||
|
|
||||||
NOTE: As of this writing, extensive research has been conducted into the
|
|
||||||
usefulness of DCT scaling as a means of data reduction and SmartScale as a
|
|
||||||
means of quality improvement. The reader is invited to peruse the research at
|
|
||||||
<http://www.libjpeg-turbo.org/About/SmartScale> and draw his/her own conclusions,
|
|
||||||
but it is the general belief of our project that these features have not
|
|
||||||
demonstrated sufficient usefulness to justify inclusion in libjpeg-turbo.
|
|
||||||
|
|
||||||
- **libjpeg: DCT scaling in compressor**<br>
|
|
||||||
`cinfo.scale_num` and `cinfo.scale_denom` are silently ignored.
|
|
||||||
There is no technical reason why DCT scaling could not be supported when
|
|
||||||
emulating the libjpeg v7+ API/ABI, but without the SmartScale extension (see
|
|
||||||
below), only scaling factors of 1/2, 8/15, 4/7, 8/13, 2/3, 8/11, 4/5, and
|
|
||||||
8/9 would be available, which is of limited usefulness.
|
|
||||||
|
|
||||||
- **libjpeg: SmartScale**<br>
|
|
||||||
`cinfo.block_size` is silently ignored.
|
|
||||||
SmartScale is an extension to the JPEG format that allows for DCT block
|
|
||||||
sizes other than 8x8. Providing support for this new format would be
|
|
||||||
feasible (particularly without full acceleration.) However, until/unless
|
|
||||||
the format becomes either an official industry standard or, at minimum, an
|
|
||||||
accepted solution in the community, we are hesitant to implement it, as
|
|
||||||
there is no sense of whether or how it might change in the future. It is
|
|
||||||
our belief that SmartScale has not demonstrated sufficient usefulness as a
|
|
||||||
lossless format nor as a means of quality enhancement, and thus our primary
|
|
||||||
interest in providing this feature would be as a means of supporting
|
|
||||||
additional DCT scaling factors.
|
|
||||||
|
|
||||||
- **libjpeg: Fancy downsampling in compressor**<br>
|
|
||||||
`cinfo.do_fancy_downsampling` is silently ignored.
|
|
||||||
This requires the DCT scaling feature, which is not supported.
|
|
||||||
|
|
||||||
- **jpegtran: Scaling**<br>
|
|
||||||
This requires both the DCT scaling and SmartScale features, which are not
|
|
||||||
supported.
|
|
||||||
|
|
||||||
- **Lossless RGB JPEG files**<br>
|
|
||||||
This requires the SmartScale feature, which is not supported.
|
|
||||||
|
|
||||||
### What About libjpeg v9?
|
|
||||||
|
|
||||||
libjpeg v9 introduced yet another field to the JPEG compression structure
|
|
||||||
(`color_transform`), thus making the ABI backward incompatible with that of
|
|
||||||
libjpeg v8. This new field was introduced solely for the purpose of supporting
|
|
||||||
lossless SmartScale encoding. Furthermore, there was actually no reason to
|
|
||||||
extend the API in this manner, as the color transform could have just as easily
|
|
||||||
been activated by way of a new JPEG colorspace constant, thus preserving
|
|
||||||
backward ABI compatibility.
|
|
||||||
|
|
||||||
Our research (see link above) has shown that lossless SmartScale does not
|
|
||||||
generally accomplish anything that can't already be accomplished better with
|
|
||||||
existing, standard lossless formats. Therefore, at this time it is our belief
|
|
||||||
that there is not sufficient technical justification for software projects to
|
|
||||||
upgrade from libjpeg v8 to libjpeg v9, and thus there is not sufficient
|
|
||||||
technical justification for us to emulate the libjpeg v9 ABI.
|
|
||||||
|
|
||||||
In-Memory Source/Destination Managers
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
By default, libjpeg-turbo 1.3 and later includes the `jpeg_mem_src()` and
|
|
||||||
`jpeg_mem_dest()` functions, even when not emulating the libjpeg v8 API/ABI.
|
|
||||||
Previously, it was necessary to build libjpeg-turbo from source with libjpeg v8
|
|
||||||
API/ABI emulation in order to use the in-memory source/destination managers,
|
|
||||||
but several projects requested that those functions be included when emulating
|
|
||||||
the libjpeg v6b API/ABI as well. This allows the use of those functions by
|
|
||||||
programs that need them, without breaking ABI compatibility for programs that
|
|
||||||
don't, and it allows those functions to be provided in the "official"
|
|
||||||
libjpeg-turbo binaries.
|
|
||||||
|
|
||||||
Those who are concerned about maintaining strict conformance with the libjpeg
|
|
||||||
v6b or v7 API can pass an argument of `--without-mem-srcdst` to `configure` or
|
|
||||||
an argument of `-DWITH_MEM_SRCDST=0` to `cmake` prior to building
|
|
||||||
libjpeg-turbo. This will restore the pre-1.3 behavior, in which
|
|
||||||
`jpeg_mem_src()` and `jpeg_mem_dest()` are only included when emulating the
|
|
||||||
libjpeg v8 API/ABI.
|
|
||||||
|
|
||||||
On Un*x systems, including the in-memory source/destination managers changes
|
|
||||||
the dynamic library version from 62.1.0 to 62.2.0 if using libjpeg v6b API/ABI
|
|
||||||
emulation and from 7.1.0 to 7.2.0 if using libjpeg v7 API/ABI emulation.
|
|
||||||
|
|
||||||
Note that, on most Un*x systems, the dynamic linker will not look for a
|
|
||||||
function in a library until that function is actually used. Thus, if a program
|
|
||||||
is built against libjpeg-turbo 1.3+ and uses `jpeg_mem_src()` or
|
|
||||||
`jpeg_mem_dest()`, that program will not fail if run against an older version
|
|
||||||
of libjpeg-turbo or against libjpeg v7- until the program actually tries to
|
|
||||||
call `jpeg_mem_src()` or `jpeg_mem_dest()`. Such is not the case on Windows.
|
|
||||||
If a program is built against the libjpeg-turbo 1.3+ DLL and uses
|
|
||||||
`jpeg_mem_src()` or `jpeg_mem_dest()`, then it must use the libjpeg-turbo 1.3+
|
|
||||||
DLL at run time.
|
|
||||||
|
|
||||||
Both cjpeg and djpeg have been extended to allow testing the in-memory
|
|
||||||
source/destination manager functions. See their respective man pages for more
|
|
||||||
details.
|
|
||||||
|
|
||||||
|
|
||||||
Mathematical Compatibility
|
|
||||||
==========================
|
|
||||||
|
|
||||||
For the most part, libjpeg-turbo should produce identical output to libjpeg
|
|
||||||
v6b. The one exception to this is when using the floating point DCT/IDCT, in
|
|
||||||
which case the outputs of libjpeg v6b and libjpeg-turbo can differ for the
|
|
||||||
following reasons:
|
|
||||||
|
|
||||||
- The SSE/SSE2 floating point DCT implementation in libjpeg-turbo is ever so
|
|
||||||
slightly more accurate than the implementation in libjpeg v6b, but not by
|
|
||||||
any amount perceptible to human vision (generally in the range of 0.01 to
|
|
||||||
0.08 dB gain in PNSR.)
|
|
||||||
|
|
||||||
- When not using the SIMD extensions, libjpeg-turbo uses the more accurate
|
|
||||||
(and slightly faster) floating point IDCT algorithm introduced in libjpeg
|
|
||||||
v8a as opposed to the algorithm used in libjpeg v6b. It should be noted,
|
|
||||||
however, that this algorithm basically brings the accuracy of the floating
|
|
||||||
point IDCT in line with the accuracy of the slow integer IDCT. The floating
|
|
||||||
point DCT/IDCT algorithms are mainly a legacy feature, and they do not
|
|
||||||
produce significantly more accuracy than the slow integer algorithms (to put
|
|
||||||
numbers on this, the typical difference in PNSR between the two algorithms
|
|
||||||
is less than 0.10 dB, whereas changing the quality level by 1 in the upper
|
|
||||||
range of the quality scale is typically more like a 1.0 dB difference.)
|
|
||||||
|
|
||||||
- If the floating point algorithms in libjpeg-turbo are not implemented using
|
|
||||||
SIMD instructions on a particular platform, then the accuracy of the
|
|
||||||
floating point DCT/IDCT can depend on the compiler settings.
|
|
||||||
|
|
||||||
While libjpeg-turbo does emulate the libjpeg v8 API/ABI, under the hood it is
|
|
||||||
still using the same algorithms as libjpeg v6b, so there are several specific
|
|
||||||
cases in which libjpeg-turbo cannot be expected to produce the same output as
|
|
||||||
libjpeg v8:
|
|
||||||
|
|
||||||
- When decompressing using scaling factors of 1/2 and 1/4, because libjpeg v8
|
|
||||||
implements those scaling algorithms differently than libjpeg v6b does, and
|
|
||||||
libjpeg-turbo's SIMD extensions are based on the libjpeg v6b behavior.
|
|
||||||
|
|
||||||
- When using chrominance subsampling, because libjpeg v8 implements this
|
|
||||||
with its DCT/IDCT scaling algorithms rather than with a separate
|
|
||||||
downsampling/upsampling algorithm. In our testing, the subsampled/upsampled
|
|
||||||
output of libjpeg v8 is less accurate than that of libjpeg v6b for this
|
|
||||||
reason.
|
|
||||||
|
|
||||||
- When decompressing using a scaling factor > 1 and merged (AKA "non-fancy" or
|
|
||||||
"non-smooth") chrominance upsampling, because libjpeg v8 does not support
|
|
||||||
merged upsampling with scaling factors > 1.
|
|
||||||
|
|
||||||
|
|
||||||
Performance Pitfalls
|
|
||||||
====================
|
|
||||||
|
|
||||||
Restart Markers
|
|
||||||
---------------
|
|
||||||
|
|
||||||
The optimized Huffman decoder in libjpeg-turbo does not handle restart markers
|
|
||||||
in a way that makes the rest of the libjpeg infrastructure happy, so it is
|
|
||||||
necessary to use the slow Huffman decoder when decompressing a JPEG image that
|
|
||||||
has restart markers. This can cause the decompression performance to drop by
|
|
||||||
as much as 20%, but the performance will still be much greater than that of
|
|
||||||
libjpeg. Many consumer packages, such as PhotoShop, use restart markers when
|
|
||||||
generating JPEG images, so images generated by those programs will experience
|
|
||||||
this issue.
|
|
||||||
|
|
||||||
Fast Integer Forward DCT at High Quality Levels
|
|
||||||
-----------------------------------------------
|
|
||||||
|
|
||||||
The algorithm used by the SIMD-accelerated quantization function cannot produce
|
|
||||||
correct results whenever the fast integer forward DCT is used along with a JPEG
|
|
||||||
quality of 98-100. Thus, libjpeg-turbo must use the non-SIMD quantization
|
|
||||||
function in those cases. This causes performance to drop by as much as 40%.
|
|
||||||
It is therefore strongly advised that you use the slow integer forward DCT
|
|
||||||
whenever encoding images with a JPEG quality of 98 or higher.
|
|
||||||
|
|||||||
93
appveyor.yml
93
appveyor.yml
@@ -1,57 +1,62 @@
|
|||||||
|
image: Visual Studio 2017
|
||||||
|
configuration: Release
|
||||||
|
platform:
|
||||||
|
- Win32
|
||||||
|
- x64
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cmd: >-
|
- if %PLATFORM% == Win32 (set ARCH=x86)
|
||||||
mkdir c:\installers
|
- if %PLATFORM% == x64 (set ARCH=x64)
|
||||||
|
## Set up nasm
|
||||||
|
- choco install nasm
|
||||||
|
- set PATH=%PATH%;C:\Program Files\NASM
|
||||||
|
## Set up libpng
|
||||||
|
- cd C:\Tools\vcpkg
|
||||||
|
- vcpkg install libpng:%ARCH%-windows
|
||||||
|
- vcpkg install libpng:%ARCH%-windows-static
|
||||||
|
|
||||||
mkdir c:\temp
|
before_build:
|
||||||
|
- cd %APPVEYOR_BUILD_FOLDER%
|
||||||
curl -fSL -o c:\installers\nasm-2.10.01-win32.zip http://www.nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip
|
- nasm -v
|
||||||
|
- cmake --version
|
||||||
7z x c:\installers\nasm-2.10.01-win32.zip -oc:\ > c:\installers\nasm.install.log
|
- git describe --always --tags --dirty
|
||||||
|
- FOR /F %%a in ('git describe --always --tags --dirty') do set GIT_VERSION=%%a
|
||||||
set INCLUDE=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\include
|
|
||||||
|
|
||||||
set LIB=c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\lib\x64
|
|
||||||
|
|
||||||
set PATH=c:\nasm-2.10.01;c:\Program Files (x86)\NSIS;c:\msys64\mingw32\bin;c:\msys64\usr\bin;c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin\x64;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin;%PATH%
|
|
||||||
|
|
||||||
set MSYSTEM=MINGW32
|
|
||||||
|
|
||||||
bash -c "pacman --noconfirm -S zip"
|
|
||||||
|
|
||||||
mklink /d "%ProgramData%\Oracle\Java32" "c:\Program Files (x86)\Java\jdk1.6.0"
|
|
||||||
|
|
||||||
git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b %APPVEYOR_REPO_BRANCH% c:/buildscripts
|
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: >-
|
## Build shared
|
||||||
for /f %%i in ('"cygpath %CD%"') do set MINGWPATH=%%i
|
- cmake -B shared -A %PLATFORM%
|
||||||
|
-DENABLE_SHARED=1 -DENABLE_STATIC=0
|
||||||
|
-DREQUIRE_SIMD=1
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||||
|
|
||||||
bash c:/buildscripts/buildljt -d %MINGWPATH% -b /c/ljt.nightly -v
|
- cmake --build shared --config Release
|
||||||
|
|
||||||
move c:\ljt.nightly\files\*.tar.gz .
|
## Build static
|
||||||
|
- cmake -B static -A %PLATFORM%
|
||||||
|
-DENABLE_SHARED=0 -DENABLE_STATIC=1
|
||||||
|
-DREQUIRE_SIMD=1
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||||
|
-DVCPKG_TARGET_TRIPLET=%ARCH%-windows-static
|
||||||
|
|
||||||
move c:\ljt.nightly\files\*.exe .
|
- cmake --build static --config Release
|
||||||
|
|
||||||
move c:\ljt.nightly\files\*.zip .
|
after_build:
|
||||||
|
- 7z a mozjpeg-%GIT_VERSION%-win-%ARCH%.zip shared/Release static/Release
|
||||||
move c:\ljt.nightly\log-windows.txt .
|
|
||||||
|
|
||||||
artifacts:
|
artifacts:
|
||||||
- path: '*.tar.gz'
|
|
||||||
name: Source tarball
|
|
||||||
|
|
||||||
- path: '*-gcc*.exe'
|
|
||||||
name: SDK for MinGW
|
|
||||||
|
|
||||||
- path: '*-vc*.exe'
|
|
||||||
name: SDK for Visual C++
|
|
||||||
|
|
||||||
- path: '*.zip'
|
- path: '*.zip'
|
||||||
name: Windows JNI JARs
|
|
||||||
|
|
||||||
- path: 'log-windows.txt'
|
cache:
|
||||||
name: Build log
|
- C:\ProgramData\chocolatey\bin
|
||||||
|
- C:\ProgramData\chocolatey\lib
|
||||||
|
- C:\Program Files\NASM
|
||||||
|
- C:\tools\vcpkg\installed
|
||||||
|
|
||||||
test: off
|
deploy:
|
||||||
|
description: 'Automated build using Appveyor'
|
||||||
deploy: off
|
provider: GitHub
|
||||||
|
auth_token:
|
||||||
|
secure: 2Jj47Q5HnaPob9U4yX2t4q4TYTw4JWU6cS56mM12aoRLgfYkZ4gRZPySIzfmTPqC
|
||||||
|
artifact: /.*\.zip/
|
||||||
|
on:
|
||||||
|
APPVEYOR_REPO_TAG: true # deploy on tag push only
|
||||||
|
|||||||
16
cderror.h
16
cderror.h
@@ -2,7 +2,7 @@
|
|||||||
* cderror.h
|
* cderror.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||||
* Modified 2009 by Guido Vollbeding.
|
* Modified 2009-2017 by Guido Vollbeding.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
@@ -49,6 +49,7 @@ JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
|
|||||||
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
|
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
|
||||||
JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
|
JMESSAGE(JERR_BMP_EMPTY, "Empty BMP image")
|
||||||
JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
|
JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
|
||||||
|
JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
|
||||||
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
|
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image")
|
||||||
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
|
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
|
||||||
JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")
|
JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image")
|
||||||
@@ -75,8 +76,8 @@ JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
|
|||||||
#ifdef PPM_SUPPORTED
|
#ifdef PPM_SUPPORTED
|
||||||
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
|
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
|
||||||
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
|
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
|
||||||
JMESSAGE(JERR_PPM_TOOLARGE, "Integer value too large in PPM file")
|
|
||||||
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
|
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
|
||||||
|
JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
|
||||||
JMESSAGE(JTRC_PGM, "%ux%u PGM image")
|
JMESSAGE(JTRC_PGM, "%ux%u PGM image")
|
||||||
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
|
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
|
||||||
JMESSAGE(JTRC_PPM, "%ux%u PPM image")
|
JMESSAGE(JTRC_PPM, "%ux%u PPM image")
|
||||||
@@ -116,14 +117,19 @@ JMESSAGE(JERR_BAD_CMAP_FILE,
|
|||||||
JMESSAGE(JERR_TOO_MANY_COLORS,
|
JMESSAGE(JERR_TOO_MANY_COLORS,
|
||||||
"Output file format cannot handle %d colormap entries")
|
"Output file format cannot handle %d colormap entries")
|
||||||
JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")
|
JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed")
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef PNG_SUPPORTED
|
||||||
JMESSAGE(JERR_UNKNOWN_FORMAT,
|
JMESSAGE(JERR_UNKNOWN_FORMAT,
|
||||||
"Unrecognized input file format --- perhaps you need -targa")
|
"MozJPEG can't read the image (JPEG, PNG and old BMP and Targa are supported)")
|
||||||
#else
|
#else
|
||||||
JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format")
|
JMESSAGE(JERR_UNKNOWN_FORMAT, "MozJPEG can't read the image (PNG support is disabled in this build)")
|
||||||
#endif
|
#endif
|
||||||
JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
|
JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format")
|
||||||
|
|
||||||
|
#ifdef PNG_SUPPORTED
|
||||||
|
JMESSAGE(JERR_PNG_ERROR, "Unable to read PNG file: %s")
|
||||||
|
JMESSAGE(JERR_PNG_PROFILETOOLARGE, "Embedded profile was too large for this tool - dropped.")
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef JMAKE_ENUM_LIST
|
#ifdef JMAKE_ENUM_LIST
|
||||||
|
|
||||||
JMSG_LASTADDONCODE
|
JMSG_LASTADDONCODE
|
||||||
|
|||||||
21
cdjpeg.h
21
cdjpeg.h
@@ -5,8 +5,9 @@
|
|||||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2017, D. R. Commander.
|
* Copyright (C) 2017, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README.ijg file.
|
||||||
*
|
*
|
||||||
* This file contains common declarations for the sample applications
|
* This file contains common declarations for the sample applications
|
||||||
* cjpeg and djpeg. It is NOT used by the core JPEG library.
|
* cjpeg and djpeg. It is NOT used by the core JPEG library.
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
#include "jerror.h" /* get library error codes too */
|
#include "jerror.h" /* get library error codes too */
|
||||||
#include "cderror.h" /* get application-specific error codes */
|
#include "cderror.h" /* get application-specific error codes */
|
||||||
|
|
||||||
|
#define JPEG_RAW_READER 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Object interface for cjpeg's source file decoding modules
|
* Object interface for cjpeg's source file decoding modules
|
||||||
@@ -35,6 +37,13 @@ struct cjpeg_source_struct {
|
|||||||
|
|
||||||
JSAMPARRAY buffer;
|
JSAMPARRAY buffer;
|
||||||
JDIMENSION buffer_height;
|
JDIMENSION buffer_height;
|
||||||
|
|
||||||
|
#if JPEG_RAW_READER
|
||||||
|
// For reading JPEG
|
||||||
|
JSAMPARRAY plane_pointer[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
jpeg_saved_marker_ptr marker_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -96,6 +105,8 @@ typedef struct cdjpeg_progress_mgr *cd_progress_ptr;
|
|||||||
|
|
||||||
/* Module selection routines for I/O modules. */
|
/* Module selection routines for I/O modules. */
|
||||||
|
|
||||||
|
EXTERN(cjpeg_source_ptr) jinit_read_jpeg (j_compress_ptr cinfo);
|
||||||
|
EXTERN(cjpeg_source_ptr) jinit_read_png (j_compress_ptr cinfo);
|
||||||
EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
|
EXTERN(cjpeg_source_ptr) jinit_read_bmp(j_compress_ptr cinfo,
|
||||||
boolean use_inversion_array);
|
boolean use_inversion_array);
|
||||||
EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
|
EXTERN(djpeg_dest_ptr) jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
|
||||||
@@ -112,10 +123,10 @@ EXTERN(djpeg_dest_ptr) jinit_write_targa(j_decompress_ptr cinfo);
|
|||||||
/* cjpeg support routines (in rdswitch.c) */
|
/* cjpeg support routines (in rdswitch.c) */
|
||||||
|
|
||||||
EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
|
EXTERN(boolean) read_quant_tables(j_compress_ptr cinfo, char *filename,
|
||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
|
EXTERN(boolean) read_scan_script(j_compress_ptr cinfo, char *filename);
|
||||||
EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
|
EXTERN(boolean) set_quality_ratings(j_compress_ptr cinfo, char *arg,
|
||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
|
EXTERN(boolean) set_quant_slots(j_compress_ptr cinfo, char *arg);
|
||||||
EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
|
EXTERN(boolean) set_sample_factors(j_compress_ptr cinfo, char *arg);
|
||||||
|
|
||||||
@@ -127,7 +138,7 @@ EXTERN(void) read_color_map(j_decompress_ptr cinfo, FILE *infile);
|
|||||||
|
|
||||||
EXTERN(void) enable_signal_catcher(j_common_ptr cinfo);
|
EXTERN(void) enable_signal_catcher(j_common_ptr cinfo);
|
||||||
EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
|
EXTERN(void) start_progress_monitor(j_common_ptr cinfo,
|
||||||
cd_progress_ptr progress);
|
cd_progress_ptr progress);
|
||||||
EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
|
EXTERN(void) end_progress_monitor(j_common_ptr cinfo);
|
||||||
EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
|
EXTERN(boolean) keymatch(char *arg, const char *keyword, int minchars);
|
||||||
EXTERN(FILE *) read_stdin(void);
|
EXTERN(FILE *) read_stdin(void);
|
||||||
|
|||||||
BIN
ci/keys.enc
BIN
ci/keys.enc
Binary file not shown.
239
cjpeg.c
239
cjpeg.c
@@ -6,8 +6,9 @@
|
|||||||
* Modified 2003-2011 by Guido Vollbeding.
|
* Modified 2003-2011 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2013-2014, 2017, D. R. Commander.
|
* Copyright (C) 2010, 2013-2014, 2017, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains a command-line user interface for the JPEG compressor.
|
* This file contains a command-line user interface for the JPEG compressor.
|
||||||
* It should work on any system with Unix- or MS-DOS-style command lines.
|
* It should work on any system with Unix- or MS-DOS-style command lines.
|
||||||
@@ -84,7 +85,8 @@ static const char * const cdjpeg_message_table[] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static boolean is_targa; /* records user -targa switch */
|
static boolean is_targa; /* records user -targa switch */
|
||||||
|
static boolean is_jpeg;
|
||||||
|
static boolean copy_markers;
|
||||||
|
|
||||||
LOCAL(cjpeg_source_ptr)
|
LOCAL(cjpeg_source_ptr)
|
||||||
select_file_type(j_compress_ptr cinfo, FILE *infile)
|
select_file_type(j_compress_ptr cinfo, FILE *infile)
|
||||||
@@ -117,6 +119,11 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
|
|||||||
case 'P':
|
case 'P':
|
||||||
return jinit_read_ppm(cinfo);
|
return jinit_read_ppm(cinfo);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PNG_SUPPORTED
|
||||||
|
case 0x89:
|
||||||
|
copy_markers = TRUE;
|
||||||
|
return jinit_read_png(cinfo);
|
||||||
|
#endif
|
||||||
#ifdef RLE_SUPPORTED
|
#ifdef RLE_SUPPORTED
|
||||||
case 'R':
|
case 'R':
|
||||||
return jinit_read_rle(cinfo);
|
return jinit_read_rle(cinfo);
|
||||||
@@ -125,6 +132,10 @@ select_file_type(j_compress_ptr cinfo, FILE *infile)
|
|||||||
case 0x00:
|
case 0x00:
|
||||||
return jinit_read_targa(cinfo);
|
return jinit_read_targa(cinfo);
|
||||||
#endif
|
#endif
|
||||||
|
case 0xff:
|
||||||
|
is_jpeg = TRUE;
|
||||||
|
copy_markers = TRUE;
|
||||||
|
return jinit_read_jpeg(cinfo);
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
|
ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
|
||||||
break;
|
break;
|
||||||
@@ -166,15 +177,32 @@ usage(void)
|
|||||||
fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
|
fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
|
||||||
fprintf(stderr, " -rgb Create RGB JPEG file\n");
|
fprintf(stderr, " -rgb Create RGB JPEG file\n");
|
||||||
#ifdef ENTROPY_OPT_SUPPORTED
|
#ifdef ENTROPY_OPT_SUPPORTED
|
||||||
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
|
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression, enabled by default)\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
fprintf(stderr, " -progressive Create progressive JPEG file\n");
|
fprintf(stderr, " -progressive Create progressive JPEG file (enabled by default)\n");
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, " -baseline Create baseline JPEG file (disable progressive coding)\n");
|
||||||
#ifdef TARGA_SUPPORTED
|
#ifdef TARGA_SUPPORTED
|
||||||
fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
|
fprintf(stderr, " -targa Input file is Targa format (usually not needed)\n");
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, " -revert Revert to standard defaults (instead of mozjpeg defaults)\n");
|
||||||
|
fprintf(stderr, " -fastcrush Disable progressive scan optimization\n");
|
||||||
|
fprintf(stderr, " -dc-scan-opt DC scan optimization mode\n");
|
||||||
|
fprintf(stderr, " - 0 One scan for all components\n");
|
||||||
|
fprintf(stderr, " - 1 One scan per component (default)\n");
|
||||||
|
fprintf(stderr, " - 2 Optimize between one scan for all components and one scan for 1st component\n");
|
||||||
|
fprintf(stderr, " plus one scan for remaining components\n");
|
||||||
|
fprintf(stderr, " -notrellis Disable trellis optimization\n");
|
||||||
|
fprintf(stderr, " -trellis-dc Enable trellis optimization of DC coefficients (default)\n");
|
||||||
|
fprintf(stderr, " -notrellis-dc Disable trellis optimization of DC coefficients\n");
|
||||||
|
fprintf(stderr, " -tune-psnr Tune trellis optimization for PSNR\n");
|
||||||
|
fprintf(stderr, " -tune-hvs-psnr Tune trellis optimization for PSNR-HVS (default)\n");
|
||||||
|
fprintf(stderr, " -tune-ssim Tune trellis optimization for SSIM\n");
|
||||||
|
fprintf(stderr, " -tune-ms-ssim Tune trellis optimization for MS-SSIM\n");
|
||||||
fprintf(stderr, "Switches for advanced users:\n");
|
fprintf(stderr, "Switches for advanced users:\n");
|
||||||
|
fprintf(stderr, " -noovershoot Disable black-on-white deringing via overshoot\n");
|
||||||
|
fprintf(stderr, " -nojfif Do not write JFIF (reduces size by 18 bytes but breaks standards; no known problems in Web browsers)\n");
|
||||||
#ifdef C_ARITH_CODING_SUPPORTED
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
fprintf(stderr, " -arithmetic Use arithmetic coding\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -190,6 +218,14 @@ usage(void)
|
|||||||
fprintf(stderr, " -dct float Use floating-point DCT method%s\n",
|
fprintf(stderr, " -dct float Use floating-point DCT method%s\n",
|
||||||
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
|
(JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, " -quant-baseline Use 8-bit quantization table entries for baseline JPEG compatibility\n");
|
||||||
|
fprintf(stderr, " -quant-table N Use predefined quantization table N:\n");
|
||||||
|
fprintf(stderr, " - 0 JPEG Annex K\n");
|
||||||
|
fprintf(stderr, " - 1 Flat\n");
|
||||||
|
fprintf(stderr, " - 2 Custom, tuned for MS-SSIM\n");
|
||||||
|
fprintf(stderr, " - 3 ImageMagick table by N. Robidoux\n");
|
||||||
|
fprintf(stderr, " - 4 Custom, tuned for PSNR-HVS\n");
|
||||||
|
fprintf(stderr, " - 5 Table from paper by Klein, Silverstein and Carney\n");
|
||||||
fprintf(stderr, " -icc FILE Embed ICC profile contained in FILE\n");
|
fprintf(stderr, " -icc FILE Embed ICC profile contained in FILE\n");
|
||||||
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
|
fprintf(stderr, " -restart N Set restart interval in rows, or in blocks with B\n");
|
||||||
#ifdef INPUT_SMOOTHING_SUPPORTED
|
#ifdef INPUT_SMOOTHING_SUPPORTED
|
||||||
@@ -203,7 +239,6 @@ usage(void)
|
|||||||
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
fprintf(stderr, " -verbose or -debug Emit debug output\n");
|
||||||
fprintf(stderr, " -version Print version information and exit\n");
|
fprintf(stderr, " -version Print version information and exit\n");
|
||||||
fprintf(stderr, "Switches for wizards:\n");
|
fprintf(stderr, "Switches for wizards:\n");
|
||||||
fprintf(stderr, " -baseline Force baseline quantization tables\n");
|
|
||||||
fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
|
fprintf(stderr, " -qtables FILE Use quantization tables given in FILE\n");
|
||||||
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
fprintf(stderr, " -qslots N[,...] Set component quantization tables\n");
|
||||||
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
|
fprintf(stderr, " -sample HxV[,...] Set component sampling factors\n");
|
||||||
@@ -216,7 +251,7 @@ usage(void)
|
|||||||
|
|
||||||
LOCAL(int)
|
LOCAL(int)
|
||||||
parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
||||||
int last_file_arg_seen, boolean for_real)
|
int last_file_arg_seen, boolean for_real)
|
||||||
/* Parse optional switches.
|
/* Parse optional switches.
|
||||||
* Returns argv[] index of first file-name argument (== argc if none).
|
* Returns argv[] index of first file-name argument (== argc if none).
|
||||||
* Any file names with indexes <= last_file_arg_seen are ignored;
|
* Any file names with indexes <= last_file_arg_seen are ignored;
|
||||||
@@ -239,7 +274,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Set up default JPEG parameters. */
|
/* Set up default JPEG parameters. */
|
||||||
|
|
||||||
force_baseline = FALSE; /* by default, allow 16-bit quantizers */
|
force_baseline = FALSE; /* by default, allow 16-bit quantizers */
|
||||||
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
|
simple_progressive = cinfo->num_scans == 0 ? FALSE : TRUE;
|
||||||
|
#else
|
||||||
simple_progressive = FALSE;
|
simple_progressive = FALSE;
|
||||||
|
#endif
|
||||||
is_targa = FALSE;
|
is_targa = FALSE;
|
||||||
icc_filename = NULL;
|
icc_filename = NULL;
|
||||||
outfilename = NULL;
|
outfilename = NULL;
|
||||||
@@ -264,6 +303,9 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Use arithmetic coding. */
|
/* Use arithmetic coding. */
|
||||||
#ifdef C_ARITH_CODING_SUPPORTED
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
cinfo->arith_code = TRUE;
|
cinfo->arith_code = TRUE;
|
||||||
|
|
||||||
|
/* No table optimization required for AC */
|
||||||
|
cinfo->optimize_coding = FALSE;
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
|
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
|
||||||
progname);
|
progname);
|
||||||
@@ -273,19 +315,27 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
} else if (keymatch(arg, "baseline", 1)) {
|
} else if (keymatch(arg, "baseline", 1)) {
|
||||||
/* Force baseline-compatible output (8-bit quantizer values). */
|
/* Force baseline-compatible output (8-bit quantizer values). */
|
||||||
force_baseline = TRUE;
|
force_baseline = TRUE;
|
||||||
|
/* Disable multiple scans */
|
||||||
|
simple_progressive = FALSE;
|
||||||
|
cinfo->num_scans = 0;
|
||||||
|
cinfo->scan_info = NULL;
|
||||||
|
|
||||||
} else if (keymatch(arg, "dct", 2)) {
|
} else if (keymatch(arg, "dct", 2)) {
|
||||||
/* Select DCT algorithm. */
|
/* Select DCT algorithm. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for dct\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
if (keymatch(argv[argn], "int", 1)) {
|
if (keymatch(argv[argn], "int", 1)) {
|
||||||
cinfo->dct_method = JDCT_ISLOW;
|
cinfo->dct_method = JDCT_ISLOW;
|
||||||
} else if (keymatch(argv[argn], "fast", 2)) {
|
} else if (keymatch(argv[argn], "fast", 2)) {
|
||||||
cinfo->dct_method = JDCT_IFAST;
|
cinfo->dct_method = JDCT_IFAST;
|
||||||
} else if (keymatch(argv[argn], "float", 2)) {
|
} else if (keymatch(argv[argn], "float", 2)) {
|
||||||
cinfo->dct_method = JDCT_FLOAT;
|
cinfo->dct_method = JDCT_FLOAT;
|
||||||
} else
|
} else {
|
||||||
|
fprintf(stderr, "%s: invalid argument for dct\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
||||||
/* Enable debug printouts. */
|
/* Enable debug printouts. */
|
||||||
@@ -307,8 +357,10 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
PACKAGE_NAME, VERSION, BUILD);
|
PACKAGE_NAME, VERSION, BUILD);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
} else if (keymatch(arg, "grayscale", 2) ||
|
} else if (keymatch(arg, "fastcrush", 4)) {
|
||||||
keymatch(arg, "greyscale", 2)) {
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OPTIMIZE_SCANS, FALSE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
||||||
/* Force a monochrome JPEG file to be generated. */
|
/* Force a monochrome JPEG file to be generated. */
|
||||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||||
|
|
||||||
@@ -316,6 +368,18 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Force an RGB JPEG file to be generated. */
|
/* Force an RGB JPEG file to be generated. */
|
||||||
jpeg_set_colorspace(cinfo, JCS_RGB);
|
jpeg_set_colorspace(cinfo, JCS_RGB);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "lambda1", 7)) {
|
||||||
|
if (++argn >= argc) /* advance to next argument */
|
||||||
|
usage();
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1,
|
||||||
|
atof(argv[argn]));
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "lambda2", 7)) {
|
||||||
|
if (++argn >= argc) /* advance to next argument */
|
||||||
|
usage();
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2,
|
||||||
|
atof(argv[argn]));
|
||||||
|
|
||||||
} else if (keymatch(arg, "icc", 1)) {
|
} else if (keymatch(arg, "icc", 1)) {
|
||||||
/* Set ICC filename. */
|
/* Set ICC filename. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
@@ -335,6 +399,13 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
lval *= 1000L;
|
lval *= 1000L;
|
||||||
cinfo->mem->max_memory_to_use = lval * 1000L;
|
cinfo->mem->max_memory_to_use = lval * 1000L;
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "dc-scan-opt", 3)) {
|
||||||
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for dc-scan-opt\n", progname);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_DC_SCAN_OPT_MODE, atoi(argv[argn]));
|
||||||
|
|
||||||
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
||||||
/* Enable entropy parm optimization. */
|
/* Enable entropy parm optimization. */
|
||||||
#ifdef ENTROPY_OPT_SUPPORTED
|
#ifdef ENTROPY_OPT_SUPPORTED
|
||||||
@@ -347,8 +418,10 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "outfile", 4)) {
|
} else if (keymatch(arg, "outfile", 4)) {
|
||||||
/* Set output file name. */
|
/* Set output file name. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for outfile\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
outfilename = argv[argn]; /* save it away for later use */
|
outfilename = argv[argn]; /* save it away for later use */
|
||||||
|
|
||||||
} else if (keymatch(arg, "progressive", 1)) {
|
} else if (keymatch(arg, "progressive", 1)) {
|
||||||
@@ -374,8 +447,10 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "quality", 1)) {
|
} else if (keymatch(arg, "quality", 1)) {
|
||||||
/* Quality ratings (quantization table scaling factors). */
|
/* Quality ratings (quantization table scaling factors). */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for quality\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
qualityarg = argv[argn];
|
qualityarg = argv[argn];
|
||||||
|
|
||||||
} else if (keymatch(arg, "qslots", 2)) {
|
} else if (keymatch(arg, "qslots", 2)) {
|
||||||
@@ -395,6 +470,22 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
qtablefile = argv[argn];
|
qtablefile = argv[argn];
|
||||||
/* We postpone actually reading the file in case -quality comes later. */
|
/* We postpone actually reading the file in case -quality comes later. */
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "quant-table", 7)) {
|
||||||
|
int val;
|
||||||
|
if (++argn >= argc) /* advance to next argument */
|
||||||
|
usage();
|
||||||
|
val = atoi(argv[argn]);
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, val);
|
||||||
|
if (jpeg_c_get_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX) != val) {
|
||||||
|
fprintf(stderr, "%s: %d is invalid argument for quant-table\n", progname, val);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "quant-baseline", 7)) {
|
||||||
|
/* Force quantization table to meet baseline requirements */
|
||||||
|
force_baseline = TRUE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "restart", 1)) {
|
} else if (keymatch(arg, "restart", 1)) {
|
||||||
/* Restart interval in MCU rows (or in MCUs with 'b'). */
|
/* Restart interval in MCU rows (or in MCUs with 'b'). */
|
||||||
long lval;
|
long lval;
|
||||||
@@ -414,6 +505,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* restart_interval will be computed during startup */
|
/* restart_interval will be computed during startup */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "revert", 3)) {
|
||||||
|
/* revert to old JPEG default */
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
|
||||||
|
jpeg_set_defaults(cinfo);
|
||||||
|
|
||||||
} else if (keymatch(arg, "sample", 2)) {
|
} else if (keymatch(arg, "sample", 2)) {
|
||||||
/* Set sampling factors. */
|
/* Set sampling factors. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
@@ -453,7 +549,60 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Input file is Targa format. */
|
/* Input file is Targa format. */
|
||||||
is_targa = TRUE;
|
is_targa = TRUE;
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "notrellis-dc", 11)) {
|
||||||
|
/* disable trellis quantization */
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT_DC, FALSE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "notrellis", 1)) {
|
||||||
|
/* disable trellis quantization */
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT, FALSE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "trellis-dc-ver-weight", 12)) {
|
||||||
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for trellis-dc-ver-weight\n", progname);
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_TRELLIS_DELTA_DC_WEIGHT, atof(argv[argn]));
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "trellis-dc", 9)) {
|
||||||
|
/* enable DC trellis quantization */
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_TRELLIS_QUANT_DC, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "tune-psnr", 6)) {
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 1);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 9.0);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 0.0);
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, FALSE);
|
||||||
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "tune-ssim", 6)) {
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 1);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 11.5);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 12.75);
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, FALSE);
|
||||||
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "tune-ms-ssim", 6)) {
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 3);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 12.0);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 13.0);
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
|
||||||
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "tune-hvs-psnr", 6)) {
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_BASE_QUANT_TBL_IDX, 3);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE1, 14.75);
|
||||||
|
jpeg_c_set_float_param(cinfo, JFLOAT_LAMBDA_LOG_SCALE2, 16.5);
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_USE_LAMBDA_WEIGHT_TBL, TRUE);
|
||||||
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "noovershoot", 11)) {
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OVERSHOOT_DERINGING, FALSE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "nojfif", 6)) {
|
||||||
|
cinfo->write_JFIF_header = 0;
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(stderr, "%s: unknown option '%s'\n", progname, arg);
|
||||||
usage(); /* bogus switch */
|
usage(); /* bogus switch */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,20 +614,28 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Set quantization tables for selected quality. */
|
/* Set quantization tables for selected quality. */
|
||||||
/* Some or all may be overridden if -qtables is present. */
|
/* Some or all may be overridden if -qtables is present. */
|
||||||
if (qualityarg != NULL) /* process -quality if it was present */
|
if (qualityarg != NULL) /* process -quality if it was present */
|
||||||
if (!set_quality_ratings(cinfo, qualityarg, force_baseline))
|
if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {
|
||||||
|
fprintf(stderr, "%s: can't set quality ratings\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if (qtablefile != NULL) /* process -qtables if it was present */
|
if (qtablefile != NULL) /* process -qtables if it was present */
|
||||||
if (!read_quant_tables(cinfo, qtablefile, force_baseline))
|
if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {
|
||||||
|
fprintf(stderr, "%s: can't read qtable file\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if (qslotsarg != NULL) /* process -qslots if it was present */
|
if (qslotsarg != NULL) /* process -qslots if it was present */
|
||||||
if (!set_quant_slots(cinfo, qslotsarg))
|
if (!set_quant_slots(cinfo, qslotsarg))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
/* set_quality_ratings sets default subsampling, so the explicit
|
||||||
|
subsampling must be set after it */
|
||||||
if (samplearg != NULL) /* process -sample if it was present */
|
if (samplearg != NULL) /* process -sample if it was present */
|
||||||
if (!set_sample_factors(cinfo, samplearg))
|
if (! set_sample_factors(cinfo, samplearg)) {
|
||||||
|
fprintf(stderr, "%s: can't set sample factors\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
if (simple_progressive) /* process -progressive; -scans can override */
|
if (simple_progressive) /* process -progressive; -scans can override */
|
||||||
@@ -640,6 +797,9 @@ main(int argc, char **argv)
|
|||||||
(*src_mgr->start_input) (&cinfo, src_mgr);
|
(*src_mgr->start_input) (&cinfo, src_mgr);
|
||||||
|
|
||||||
/* Now that we know input colorspace, fix colorspace-dependent defaults */
|
/* Now that we know input colorspace, fix colorspace-dependent defaults */
|
||||||
|
#if JPEG_RAW_READER
|
||||||
|
if (!is_jpeg)
|
||||||
|
#endif
|
||||||
jpeg_default_colorspace(&cinfo);
|
jpeg_default_colorspace(&cinfo);
|
||||||
|
|
||||||
/* Adjust default compression parameters by re-parsing the options */
|
/* Adjust default compression parameters by re-parsing the options */
|
||||||
@@ -656,13 +816,50 @@ main(int argc, char **argv)
|
|||||||
/* Start compressor */
|
/* Start compressor */
|
||||||
jpeg_start_compress(&cinfo, TRUE);
|
jpeg_start_compress(&cinfo, TRUE);
|
||||||
|
|
||||||
|
/* Copy metadata */
|
||||||
|
if (copy_markers) {
|
||||||
|
jpeg_saved_marker_ptr marker;
|
||||||
|
|
||||||
|
/* In the current implementation, we don't actually need to examine the
|
||||||
|
* option flag here; we just copy everything that got saved.
|
||||||
|
* But to avoid confusion, we do not output JFIF and Adobe APP14 markers
|
||||||
|
* if the encoder library already wrote one.
|
||||||
|
*/
|
||||||
|
for (marker = src_mgr->marker_list; marker != NULL; marker = marker->next) {
|
||||||
|
if (cinfo.write_JFIF_header &&
|
||||||
|
marker->marker == JPEG_APP0 &&
|
||||||
|
marker->data_length >= 5 &&
|
||||||
|
GETJOCTET(marker->data[0]) == 0x4A &&
|
||||||
|
GETJOCTET(marker->data[1]) == 0x46 &&
|
||||||
|
GETJOCTET(marker->data[2]) == 0x49 &&
|
||||||
|
GETJOCTET(marker->data[3]) == 0x46 &&
|
||||||
|
GETJOCTET(marker->data[4]) == 0)
|
||||||
|
continue; /* reject duplicate JFIF */
|
||||||
|
if (cinfo.write_Adobe_marker &&
|
||||||
|
marker->marker == JPEG_APP0+14 &&
|
||||||
|
marker->data_length >= 5 &&
|
||||||
|
GETJOCTET(marker->data[0]) == 0x41 &&
|
||||||
|
GETJOCTET(marker->data[1]) == 0x64 &&
|
||||||
|
GETJOCTET(marker->data[2]) == 0x6F &&
|
||||||
|
GETJOCTET(marker->data[3]) == 0x62 &&
|
||||||
|
GETJOCTET(marker->data[4]) == 0x65)
|
||||||
|
continue; /* reject duplicate Adobe */
|
||||||
|
jpeg_write_marker(&cinfo, marker->marker, marker->data,
|
||||||
|
marker->data_length);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (icc_profile != NULL)
|
if (icc_profile != NULL)
|
||||||
jpeg_write_icc_profile(&cinfo, icc_profile, (unsigned int)icc_len);
|
jpeg_write_icc_profile(&cinfo, icc_profile, (unsigned int)icc_len);
|
||||||
|
|
||||||
/* Process data */
|
/* Process data */
|
||||||
while (cinfo.next_scanline < cinfo.image_height) {
|
while (cinfo.next_scanline < cinfo.image_height) {
|
||||||
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
|
num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
|
||||||
(void)jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
|
#if JPEG_RAW_READER
|
||||||
|
if (is_jpeg)
|
||||||
|
(void) jpeg_write_raw_data(&cinfo, src_mgr->plane_pointer, num_scanlines);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
(void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish compression and release memory */
|
/* Finish compression and release memory */
|
||||||
@@ -682,12 +879,10 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (memdst) {
|
if (memdst) {
|
||||||
fprintf(stderr, "Compressed size: %lu bytes\n", outsize);
|
fprintf(stderr, "Compressed size: %lu bytes\n", outsize);
|
||||||
if (outbuffer != NULL)
|
free(outbuffer);
|
||||||
free(outbuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icc_profile != NULL)
|
free(icc_profile);
|
||||||
free(icc_profile);
|
|
||||||
|
|
||||||
/* All done. */
|
/* All done. */
|
||||||
exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
|
exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ endif()
|
|||||||
if(BITS EQUAL 64)
|
if(BITS EQUAL 64)
|
||||||
set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
|
set(INST_PLATFORM "${INST_PLATFORM} 64-bit")
|
||||||
set(INST_NAME ${INST_NAME}64)
|
set(INST_NAME ${INST_NAME}64)
|
||||||
set(INST_REG_NAME ${INST_DIR}64)
|
set(INST_REG_NAME ${INST_REG_NAME}64)
|
||||||
set(INST_DEFS ${INST_DEFS} -DWIN64)
|
set(INST_DEFS ${INST_DEFS} -DWIN64)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -145,6 +145,11 @@ set(DEFAULT_IOS_ARMV8_BUILD ${CMAKE_SOURCE_DIR}/iosarmv8)
|
|||||||
set(IOS_ARMV8_BUILD ${DEFAULT_IOS_ARMV8_BUILD} CACHE PATH
|
set(IOS_ARMV8_BUILD ${DEFAULT_IOS_ARMV8_BUILD} CACHE PATH
|
||||||
"Directory containing ARMv8 iOS build to include in universal binaries (default: ${DEFAULT_IOS_ARMV8_BUILD})")
|
"Directory containing ARMv8 iOS build to include in universal binaries (default: ${DEFAULT_IOS_ARMV8_BUILD})")
|
||||||
|
|
||||||
|
set(OSX_APP_CERT_NAME "" CACHE STRING
|
||||||
|
"Name of the Developer ID Application certificate (in the macOS keychain) that should be used to sign the libjpeg-turbo DMG. Leave this blank to generate an unsigned DMG.")
|
||||||
|
set(OSX_INST_CERT_NAME "" CACHE STRING
|
||||||
|
"Name of the Developer ID Installer certificate (in the macOS keychain) that should be used to sign the libjpeg-turbo installer package. Leave this blank to generate an unsigned package.")
|
||||||
|
|
||||||
configure_file(release/makemacpkg.in pkgscripts/makemacpkg)
|
configure_file(release/makemacpkg.in pkgscripts/makemacpkg)
|
||||||
configure_file(release/Distribution.xml.in pkgscripts/Distribution.xml)
|
configure_file(release/Distribution.xml.in pkgscripts/Distribution.xml)
|
||||||
configure_file(release/uninstall.in pkgscripts/uninstall)
|
configure_file(release/uninstall.in pkgscripts/uninstall)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
# absolute paths where necessary, using the same logic.
|
# absolute paths where necessary, using the same logic.
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Copyright 2016 D. R. Commander
|
# Copyright 2016, 2019 D. R. Commander
|
||||||
# Copyright 2016 Dmitry Marakasov
|
# Copyright 2016 Dmitry Marakasov
|
||||||
# Copyright 2016 Roger Leigh
|
# Copyright 2016 Roger Leigh
|
||||||
# Copyright 2015 Alex Turbov
|
# Copyright 2015 Alex Turbov
|
||||||
@@ -184,7 +184,7 @@ macro(GNUInstallDirs_set_install_dir var docstring)
|
|||||||
"${docstring} (Default: ${CMAKE_INSTALL_DEFAULT_${var}})"
|
"${docstring} (Default: ${CMAKE_INSTALL_DEFAULT_${var}})"
|
||||||
${_GNUInstallDirs_CMAKE_INSTALL_FORCE_${var}})
|
${_GNUInstallDirs_CMAKE_INSTALL_FORCE_${var}})
|
||||||
|
|
||||||
if(NOT "${CMAKE_INSTALL_${var}}" STREQUAL "${CMAKE_INSTALL_DEFAULT_${var}}")
|
if(NOT CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_DEFAULT_${var})
|
||||||
unset(_GNUInstallDirs_CMAKE_INSTALL_DEFAULT_${var} CACHE)
|
unset(_GNUInstallDirs_CMAKE_INSTALL_DEFAULT_${var} CACHE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
4
djpeg.c
4
djpeg.c
@@ -516,7 +516,9 @@ main(int argc, char **argv)
|
|||||||
FILE *input_file;
|
FILE *input_file;
|
||||||
FILE *output_file;
|
FILE *output_file;
|
||||||
unsigned char *inbuffer = NULL;
|
unsigned char *inbuffer = NULL;
|
||||||
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
unsigned long insize = 0;
|
unsigned long insize = 0;
|
||||||
|
#endif
|
||||||
JDIMENSION num_scanlines;
|
JDIMENSION num_scanlines;
|
||||||
|
|
||||||
/* On Mac, fetch a command line. */
|
/* On Mac, fetch a command line. */
|
||||||
@@ -811,7 +813,7 @@ main(int argc, char **argv)
|
|||||||
end_progress_monitor((j_common_ptr)&cinfo);
|
end_progress_monitor((j_common_ptr)&cinfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (memsrc && inbuffer != NULL)
|
if (memsrc)
|
||||||
free(inbuffer);
|
free(inbuffer);
|
||||||
|
|
||||||
/* All done. */
|
/* All done. */
|
||||||
|
|||||||
@@ -2078,7 +2078,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#gaec627dd4c5f30b7a775a7aea3bec5d83" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
<p>You should always use this function to free JPEG destination buffer(s) that were automatically (re)allocated by the compression and transform functions or that were manually allocated using <a class="el" href="group___turbo_j_p_e_g.html#gaec627dd4c5f30b7a775a7aea3bec5d83" title="Allocate an image buffer for use with TurboJPEG.">tjAlloc()</a>.</p>
|
||||||
<dl class="params"><dt>Parameters</dt><dd>
|
<dl class="params"><dt>Parameters</dt><dd>
|
||||||
<table class="params">
|
<table class="params">
|
||||||
<tr><td class="paramname">buffer</td><td>address of the buffer to free</td></tr>
|
<tr><td class="paramname">buffer</td><td>address of the buffer to free. If the address is NULL, then this function has no effect.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@@ -2129,7 +2129,7 @@ If you choose option 1, <code>*jpegSize</code> should be set to the size of your
|
|||||||
<p>Returns a descriptive error message explaining why the last command failed. </p>
|
<p>Returns a descriptive error message explaining why the last command failed. </p>
|
||||||
<dl class="params"><dt>Parameters</dt><dd>
|
<dl class="params"><dt>Parameters</dt><dd>
|
||||||
<table class="params">
|
<table class="params">
|
||||||
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor, decompressor, or transformer instance, or NULL if the error was generated by a global function (but note that retrieving the error message for a global function is not thread-safe.)</td></tr>
|
<tr><td class="paramname">handle</td><td>a handle to a TurboJPEG compressor, decompressor, or transformer instance, or NULL if the error was generated by a global function (but note that retrieving the error message for a global function is thread-safe only on platforms that support thread-local storage.)</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
47
example.txt
47
example.txt
@@ -288,12 +288,14 @@ my_error_exit(j_common_ptr cinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
METHODDEF(int) do_read_JPEG_file(struct jpeg_decompress_struct *cinfo,
|
||||||
|
char *filename);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sample routine for JPEG decompression. We assume that the source file name
|
* Sample routine for JPEG decompression. We assume that the source file name
|
||||||
* is passed in. We want to return 1 on success, 0 on error.
|
* is passed in. We want to return 1 on success, 0 on error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(int)
|
GLOBAL(int)
|
||||||
read_JPEG_file(char *filename)
|
read_JPEG_file(char *filename)
|
||||||
{
|
{
|
||||||
@@ -301,6 +303,21 @@ read_JPEG_file(char *filename)
|
|||||||
* working space (which is allocated as needed by the JPEG library).
|
* working space (which is allocated as needed by the JPEG library).
|
||||||
*/
|
*/
|
||||||
struct jpeg_decompress_struct cinfo;
|
struct jpeg_decompress_struct cinfo;
|
||||||
|
|
||||||
|
return do_read_JPEG_file(&cinfo, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We call the libjpeg API from within a separate function, because modifying
|
||||||
|
* the local non-volatile jpeg_decompress_struct instance below the setjmp()
|
||||||
|
* return point and then accessing the instance after setjmp() returns would
|
||||||
|
* return in undefined behavior that may potentially overwrite all or part of
|
||||||
|
* the structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(int)
|
||||||
|
do_read_JPEG_file(struct jpeg_decompress_struct *cinfo, char *filename)
|
||||||
|
{
|
||||||
/* We use our private extension JPEG error handler.
|
/* We use our private extension JPEG error handler.
|
||||||
* Note that this struct must live as long as the main JPEG parameter
|
* Note that this struct must live as long as the main JPEG parameter
|
||||||
* struct, to avoid dangling-pointer problems.
|
* struct, to avoid dangling-pointer problems.
|
||||||
@@ -325,27 +342,27 @@ read_JPEG_file(char *filename)
|
|||||||
/* Step 1: allocate and initialize JPEG decompression object */
|
/* Step 1: allocate and initialize JPEG decompression object */
|
||||||
|
|
||||||
/* We set up the normal JPEG error routines, then override error_exit. */
|
/* We set up the normal JPEG error routines, then override error_exit. */
|
||||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
cinfo->err = jpeg_std_error(&jerr.pub);
|
||||||
jerr.pub.error_exit = my_error_exit;
|
jerr.pub.error_exit = my_error_exit;
|
||||||
/* Establish the setjmp return context for my_error_exit to use. */
|
/* Establish the setjmp return context for my_error_exit to use. */
|
||||||
if (setjmp(jerr.setjmp_buffer)) {
|
if (setjmp(jerr.setjmp_buffer)) {
|
||||||
/* If we get here, the JPEG code has signaled an error.
|
/* If we get here, the JPEG code has signaled an error.
|
||||||
* We need to clean up the JPEG object, close the input file, and return.
|
* We need to clean up the JPEG object, close the input file, and return.
|
||||||
*/
|
*/
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(cinfo);
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Now we can initialize the JPEG decompression object. */
|
/* Now we can initialize the JPEG decompression object. */
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(cinfo);
|
||||||
|
|
||||||
/* Step 2: specify data source (eg, a file) */
|
/* Step 2: specify data source (eg, a file) */
|
||||||
|
|
||||||
jpeg_stdio_src(&cinfo, infile);
|
jpeg_stdio_src(cinfo, infile);
|
||||||
|
|
||||||
/* Step 3: read file parameters with jpeg_read_header() */
|
/* Step 3: read file parameters with jpeg_read_header() */
|
||||||
|
|
||||||
(void)jpeg_read_header(&cinfo, TRUE);
|
(void)jpeg_read_header(cinfo, TRUE);
|
||||||
/* We can ignore the return value from jpeg_read_header since
|
/* We can ignore the return value from jpeg_read_header since
|
||||||
* (a) suspension is not possible with the stdio data source, and
|
* (a) suspension is not possible with the stdio data source, and
|
||||||
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
|
* (b) we passed TRUE to reject a tables-only JPEG file as an error.
|
||||||
@@ -360,7 +377,7 @@ read_JPEG_file(char *filename)
|
|||||||
|
|
||||||
/* Step 5: Start decompressor */
|
/* Step 5: Start decompressor */
|
||||||
|
|
||||||
(void)jpeg_start_decompress(&cinfo);
|
(void)jpeg_start_decompress(cinfo);
|
||||||
/* We can ignore the return value since suspension is not possible
|
/* We can ignore the return value since suspension is not possible
|
||||||
* with the stdio data source.
|
* with the stdio data source.
|
||||||
*/
|
*/
|
||||||
@@ -372,30 +389,30 @@ read_JPEG_file(char *filename)
|
|||||||
* In this example, we need to make an output work buffer of the right size.
|
* In this example, we need to make an output work buffer of the right size.
|
||||||
*/
|
*/
|
||||||
/* JSAMPLEs per row in output buffer */
|
/* JSAMPLEs per row in output buffer */
|
||||||
row_stride = cinfo.output_width * cinfo.output_components;
|
row_stride = cinfo->output_width * cinfo->output_components;
|
||||||
/* Make a one-row-high sample array that will go away when done with image */
|
/* Make a one-row-high sample array that will go away when done with image */
|
||||||
buffer = (*cinfo.mem->alloc_sarray)
|
buffer = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
|
((j_common_ptr)cinfo, JPOOL_IMAGE, row_stride, 1);
|
||||||
|
|
||||||
/* Step 6: while (scan lines remain to be read) */
|
/* Step 6: while (scan lines remain to be read) */
|
||||||
/* jpeg_read_scanlines(...); */
|
/* jpeg_read_scanlines(...); */
|
||||||
|
|
||||||
/* Here we use the library's state variable cinfo.output_scanline as the
|
/* Here we use the library's state variable cinfo->output_scanline as the
|
||||||
* loop counter, so that we don't have to keep track ourselves.
|
* loop counter, so that we don't have to keep track ourselves.
|
||||||
*/
|
*/
|
||||||
while (cinfo.output_scanline < cinfo.output_height) {
|
while (cinfo->output_scanline < cinfo->output_height) {
|
||||||
/* jpeg_read_scanlines expects an array of pointers to scanlines.
|
/* jpeg_read_scanlines expects an array of pointers to scanlines.
|
||||||
* Here the array is only one element long, but you could ask for
|
* Here the array is only one element long, but you could ask for
|
||||||
* more than one scanline at a time if that's more convenient.
|
* more than one scanline at a time if that's more convenient.
|
||||||
*/
|
*/
|
||||||
(void)jpeg_read_scanlines(&cinfo, buffer, 1);
|
(void)jpeg_read_scanlines(cinfo, buffer, 1);
|
||||||
/* Assume put_scanline_someplace wants a pointer and sample count. */
|
/* Assume put_scanline_someplace wants a pointer and sample count. */
|
||||||
put_scanline_someplace(buffer[0], row_stride);
|
put_scanline_someplace(buffer[0], row_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Step 7: Finish decompression */
|
/* Step 7: Finish decompression */
|
||||||
|
|
||||||
(void)jpeg_finish_decompress(&cinfo);
|
(void)jpeg_finish_decompress(cinfo);
|
||||||
/* We can ignore the return value since suspension is not possible
|
/* We can ignore the return value since suspension is not possible
|
||||||
* with the stdio data source.
|
* with the stdio data source.
|
||||||
*/
|
*/
|
||||||
@@ -403,7 +420,7 @@ read_JPEG_file(char *filename)
|
|||||||
/* Step 8: Release JPEG decompression object */
|
/* Step 8: Release JPEG decompression object */
|
||||||
|
|
||||||
/* This is an important step since it will release a good deal of memory. */
|
/* This is an important step since it will release a good deal of memory. */
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(cinfo);
|
||||||
|
|
||||||
/* After finish_decompress, we can close the input file.
|
/* After finish_decompress, we can close the input file.
|
||||||
* Here we postpone it until after no more JPEG errors are possible,
|
* Here we postpone it until after no more JPEG errors are possible,
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Developed 1997-2009 by Guido Vollbeding.
|
* Developed 1997-2009 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* This file contains probability estimation tables for common use in
|
* This file contains probability estimation tables for common use in
|
||||||
* arithmetic entropy encoding and decoding routines.
|
* arithmetic entropy encoding and decoding routines.
|
||||||
*
|
*
|
||||||
* This data represents Table D.2 in the JPEG spec (ISO/IEC IS 10918-1
|
* This data represents Table D.2 in
|
||||||
* and CCITT Recommendation ITU-T T.81) and Table 24 in the JBIG spec
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 and Table 24 in
|
||||||
* (ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82).
|
* Recommendation ITU-T T.82 (1993) | ISO/IEC 11544:1993.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if(WIN32)
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
||||||
else()
|
else()
|
||||||
configure_file(org/libjpegturbo/turbojpeg/TJLoader-unix.java.in
|
configure_file(org/libjpegturbo/turbojpeg/TJLoader-unix.java.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
||||||
endif()
|
endif()
|
||||||
set(JAVA_SOURCES ${JAVA_SOURCES}
|
set(JAVA_SOURCES ${JAVA_SOURCES}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
${CMAKE_CURRENT_BINARY_DIR}/org/libjpegturbo/turbojpeg/TJLoader.java)
|
||||||
@@ -58,11 +58,21 @@ endif()
|
|||||||
add_custom_target(javadoc COMMAND
|
add_custom_target(javadoc COMMAND
|
||||||
javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
|
javadoc -notimestamp -d ${CMAKE_CURRENT_SOURCE_DIR}/doc -sourcepath ${CMAKE_CURRENT_SOURCE_DIR} org.libjpegturbo.turbojpeg)
|
||||||
set(JAVACLASSPATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/turbojpeg-java.dir)
|
set(JAVACLASSPATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/turbojpeg-java.dir)
|
||||||
add_custom_target(javah
|
if(Java_VERSION_MAJOR GREATER 9)
|
||||||
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
|
add_custom_target(javah
|
||||||
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
|
COMMAND javac -h ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH}
|
||||||
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
|
-d ${CMAKE_CURRENT_BINARY_DIR}/__unused
|
||||||
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
|
${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJ.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJCompressor.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJDecompressor.java
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/org/libjpegturbo/turbojpeg/TJTransformer.java)
|
||||||
|
else()
|
||||||
|
add_custom_target(javah
|
||||||
|
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJ
|
||||||
|
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJCompressor
|
||||||
|
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJDecompressor
|
||||||
|
COMMAND javah -d ${CMAKE_CURRENT_SOURCE_DIR} -classpath ${JAVACLASSPATH} org.libjpegturbo.turbojpeg.TJTransformer)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR)
|
if(NOT DEFINED CMAKE_INSTALL_DEFAULT_JAVADIR)
|
||||||
set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/java")
|
set(CMAKE_INSTALL_DEFAULT_JAVADIR "<CMAKE_INSTALL_DATAROOTDIR>/java")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2009-2014, 2016-2017 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2009-2014, 2016-2019 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -32,51 +32,53 @@ import javax.imageio.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.libjpegturbo.turbojpeg.*;
|
import org.libjpegturbo.turbojpeg.*;
|
||||||
|
|
||||||
class TJBench {
|
final class TJBench {
|
||||||
|
|
||||||
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvPad = 1;
|
private TJBench() {}
|
||||||
static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
|
||||||
|
|
||||||
static final String[] pixFormatStr = {
|
private static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvPad = 1;
|
||||||
|
private static boolean compOnly, decompOnly, doTile, doYUV, write = true;
|
||||||
|
|
||||||
|
static final String[] PIXFORMATSTR = {
|
||||||
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
|
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
|
||||||
};
|
};
|
||||||
|
|
||||||
static final String[] subNameLong = {
|
static final String[] SUBNAME_LONG = {
|
||||||
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
|
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
|
||||||
};
|
};
|
||||||
|
|
||||||
static final String[] subName = {
|
static final String[] SUBNAME = {
|
||||||
"444", "422", "420", "GRAY", "440", "411"
|
"444", "422", "420", "GRAY", "440", "411"
|
||||||
};
|
};
|
||||||
|
|
||||||
static final String[] csName = {
|
static final String[] CSNAME = {
|
||||||
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
|
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
|
||||||
};
|
};
|
||||||
|
|
||||||
static TJScalingFactor sf;
|
private static TJScalingFactor sf;
|
||||||
static int xformOp = TJTransform.OP_NONE, xformOpt = 0;
|
private static int xformOp = TJTransform.OP_NONE, xformOpt = 0;
|
||||||
static double benchTime = 5.0, warmup = 1.0;
|
private static double benchTime = 5.0, warmup = 1.0;
|
||||||
|
|
||||||
|
|
||||||
static final double getTime() {
|
static double getTime() {
|
||||||
return (double)System.nanoTime() / 1.0e9;
|
return (double)System.nanoTime() / 1.0e9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String tjErrorMsg;
|
private static String tjErrorMsg;
|
||||||
static int tjErrorCode = -1;
|
private static int tjErrorCode = -1;
|
||||||
|
|
||||||
static void handleTJException(TJException e) throws TJException {
|
static void handleTJException(TJException e) throws TJException {
|
||||||
String _tjErrorMsg = e.getMessage();
|
String errorMsg = e.getMessage();
|
||||||
int _tjErrorCode = e.getErrorCode();
|
int errorCode = e.getErrorCode();
|
||||||
|
|
||||||
if ((flags & TJ.FLAG_STOPONWARNING) == 0 &&
|
if ((flags & TJ.FLAG_STOPONWARNING) == 0 &&
|
||||||
_tjErrorCode == TJ.ERR_WARNING) {
|
errorCode == TJ.ERR_WARNING) {
|
||||||
if (tjErrorMsg == null || !tjErrorMsg.equals(_tjErrorMsg) ||
|
if (tjErrorMsg == null || !tjErrorMsg.equals(errorMsg) ||
|
||||||
tjErrorCode != _tjErrorCode) {
|
tjErrorCode != errorCode) {
|
||||||
tjErrorMsg = _tjErrorMsg;
|
tjErrorMsg = errorMsg;
|
||||||
tjErrorCode = _tjErrorCode;
|
tjErrorCode = errorCode;
|
||||||
System.out.println("WARNING: " + _tjErrorMsg);
|
System.out.println("WARNING: " + errorMsg);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
throw e;
|
throw e;
|
||||||
@@ -85,11 +87,11 @@ class TJBench {
|
|||||||
|
|
||||||
static String formatName(int subsamp, int cs) {
|
static String formatName(int subsamp, int cs) {
|
||||||
if (cs == TJ.CS_YCbCr)
|
if (cs == TJ.CS_YCbCr)
|
||||||
return subNameLong[subsamp];
|
return SUBNAME_LONG[subsamp];
|
||||||
else if (cs == TJ.CS_YCCK)
|
else if (cs == TJ.CS_YCCK)
|
||||||
return csName[cs] + " " + subNameLong[subsamp];
|
return CSNAME[cs] + " " + SUBNAME_LONG[subsamp];
|
||||||
else
|
else
|
||||||
return csName[cs];
|
return CSNAME[cs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,6 +121,8 @@ class TJBench {
|
|||||||
int rindex = TJ.getRedOffset(pixelFormat);
|
int rindex = TJ.getRedOffset(pixelFormat);
|
||||||
int gindex = TJ.getGreenOffset(pixelFormat);
|
int gindex = TJ.getGreenOffset(pixelFormat);
|
||||||
int bindex = TJ.getBlueOffset(pixelFormat);
|
int bindex = TJ.getBlueOffset(pixelFormat);
|
||||||
|
if ((long)w[0] * (long)h[0] * (long)ps > (long)Integer.MAX_VALUE)
|
||||||
|
throw new Exception("Image is too large");
|
||||||
byte[] dstBuf = new byte[w[0] * h[0] * ps];
|
byte[] dstBuf = new byte[w[0] * h[0] * ps];
|
||||||
int pixels = w[0] * h[0], dstPtr = 0, rgbPtr = 0;
|
int pixels = w[0] * h[0], dstPtr = 0, rgbPtr = 0;
|
||||||
|
|
||||||
@@ -173,8 +177,11 @@ class TJBench {
|
|||||||
|
|
||||||
tjd = new TJDecompressor();
|
tjd = new TJDecompressor();
|
||||||
|
|
||||||
if (dstBuf == null)
|
if (dstBuf == null) {
|
||||||
|
if ((long)pitch * (long)scaledh > (long)Integer.MAX_VALUE)
|
||||||
|
throw new Exception("Image is too large");
|
||||||
dstBuf = new byte[pitch * scaledh];
|
dstBuf = new byte[pitch * scaledh];
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the destination buffer to gray so we know whether the decompressor
|
/* Set the destination buffer to gray so we know whether the decompressor
|
||||||
attempted to write to it */
|
attempted to write to it */
|
||||||
@@ -200,7 +207,9 @@ class TJBench {
|
|||||||
int width = doTile ? Math.min(tilew, w - x) : scaledw;
|
int width = doTile ? Math.min(tilew, w - x) : scaledw;
|
||||||
int height = doTile ? Math.min(tileh, h - y) : scaledh;
|
int height = doTile ? Math.min(tileh, h - y) : scaledh;
|
||||||
|
|
||||||
tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
|
try {
|
||||||
|
tjd.setSourceImage(jpegBuf[tile], jpegSize[tile]);
|
||||||
|
} catch (TJException e) { handleTJException(e); }
|
||||||
if (doYUV) {
|
if (doYUV) {
|
||||||
yuvImage.setBuf(yuvImage.getBuf(), width, yuvPad, height, subsamp);
|
yuvImage.setBuf(yuvImage.getBuf(), width, yuvPad, height, subsamp);
|
||||||
try {
|
try {
|
||||||
@@ -276,7 +285,7 @@ class TJBench {
|
|||||||
if (decompOnly)
|
if (decompOnly)
|
||||||
tempStr = new String(fileName + "_" + sizeStr + ".bmp");
|
tempStr = new String(fileName + "_" + sizeStr + ".bmp");
|
||||||
else
|
else
|
||||||
tempStr = new String(fileName + "_" + subName[subsamp] + qualStr +
|
tempStr = new String(fileName + "_" + SUBNAME[subsamp] + qualStr +
|
||||||
"_" + sizeStr + ".bmp");
|
"_" + sizeStr + ".bmp");
|
||||||
|
|
||||||
saveImage(tempStr, dstBuf, scaledw, scaledh, pf);
|
saveImage(tempStr, dstBuf, scaledw, scaledh, pf);
|
||||||
@@ -324,16 +333,18 @@ class TJBench {
|
|||||||
int totalJpegSize = 0, tilew, tileh, i, iter;
|
int totalJpegSize = 0, tilew, tileh, i, iter;
|
||||||
int ps = TJ.getPixelSize(pf);
|
int ps = TJ.getPixelSize(pf);
|
||||||
int ntilesw = 1, ntilesh = 1, pitch = w * ps;
|
int ntilesw = 1, ntilesh = 1, pitch = w * ps;
|
||||||
String pfStr = pixFormatStr[pf];
|
String pfStr = PIXFORMATSTR[pf];
|
||||||
YUVImage yuvImage = null;
|
YUVImage yuvImage = null;
|
||||||
|
|
||||||
|
if ((long)pitch * (long)h > (long)Integer.MAX_VALUE)
|
||||||
|
throw new Exception("Image is too large");
|
||||||
tmpBuf = new byte[pitch * h];
|
tmpBuf = new byte[pitch * h];
|
||||||
|
|
||||||
if (quiet == 0)
|
if (quiet == 0)
|
||||||
System.out.format(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pfStr,
|
System.out.format(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pfStr,
|
||||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
||||||
"Bottom-up" : "Top-down",
|
"Bottom-up" : "Top-down",
|
||||||
subNameLong[subsamp], jpegQual);
|
SUBNAME_LONG[subsamp], jpegQual);
|
||||||
|
|
||||||
tjc = new TJCompressor();
|
tjc = new TJCompressor();
|
||||||
|
|
||||||
@@ -353,7 +364,7 @@ class TJBench {
|
|||||||
if (quiet == 1)
|
if (quiet == 1)
|
||||||
System.out.format("%-4s (%s) %-5s %-3d ", pfStr,
|
System.out.format("%-4s (%s) %-5s %-3d ", pfStr,
|
||||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
|
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
|
||||||
subNameLong[subsamp], jpegQual);
|
SUBNAME_LONG[subsamp], jpegQual);
|
||||||
for (i = 0; i < h; i++)
|
for (i = 0; i < h; i++)
|
||||||
System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps);
|
System.arraycopy(srcBuf, w * ps * i, tmpBuf, pitch * i, w * ps);
|
||||||
tjc.setJPEGQuality(jpegQual);
|
tjc.setJPEGQuality(jpegQual);
|
||||||
@@ -453,7 +464,7 @@ class TJBench {
|
|||||||
(double)iter / elapsed);
|
(double)iter / elapsed);
|
||||||
}
|
}
|
||||||
if (tilew == w && tileh == h && write) {
|
if (tilew == w && tileh == h && write) {
|
||||||
String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" +
|
String tempStr = fileName + "_" + SUBNAME[subsamp] + "_" + "Q" +
|
||||||
jpegQual + ".jpg";
|
jpegQual + ".jpg";
|
||||||
FileOutputStream fos = new FileOutputStream(tempStr);
|
FileOutputStream fos = new FileOutputStream(tempStr);
|
||||||
|
|
||||||
@@ -467,6 +478,8 @@ class TJBench {
|
|||||||
if (!compOnly)
|
if (!compOnly)
|
||||||
decomp(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual,
|
decomp(srcBuf, jpegBuf, jpegSize, tmpBuf, w, h, subsamp, jpegQual,
|
||||||
fileName, tilew, tileh);
|
fileName, tilew, tileh);
|
||||||
|
else if (quiet == 1)
|
||||||
|
System.out.println("N/A");
|
||||||
|
|
||||||
if (tilew == w && tileh == h) break;
|
if (tilew == w && tileh == h) break;
|
||||||
}
|
}
|
||||||
@@ -479,13 +492,16 @@ class TJBench {
|
|||||||
byte[] srcBuf;
|
byte[] srcBuf;
|
||||||
int[] jpegSize = null;
|
int[] jpegSize = null;
|
||||||
int totalJpegSize;
|
int totalJpegSize;
|
||||||
int w = 0, h = 0, subsamp = -1, cs = -1, _w, _h, _tilew, _tileh,
|
|
||||||
_ntilesw, _ntilesh, _subsamp, x, y, iter;
|
|
||||||
int ntilesw = 1, ntilesh = 1;
|
|
||||||
double start, elapsed;
|
double start, elapsed;
|
||||||
int ps = TJ.getPixelSize(pf), tile;
|
int ps = TJ.getPixelSize(pf), tile, x, y, iter;
|
||||||
|
// Original image
|
||||||
|
int w = 0, h = 0, ntilesw = 1, ntilesh = 1, subsamp = -1, cs = -1;
|
||||||
|
// Transformed image
|
||||||
|
int tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(fileName);
|
FileInputStream fis = new FileInputStream(fileName);
|
||||||
|
if (fis.getChannel().size() > (long)Integer.MAX_VALUE)
|
||||||
|
throw new Exception("Image is too large");
|
||||||
int srcSize = (int)fis.getChannel().size();
|
int srcSize = (int)fis.getChannel().size();
|
||||||
srcBuf = new byte[srcSize];
|
srcBuf = new byte[srcSize];
|
||||||
fis.read(srcBuf, 0, srcSize);
|
fis.read(srcBuf, 0, srcSize);
|
||||||
@@ -497,7 +513,9 @@ class TJBench {
|
|||||||
|
|
||||||
tjt = new TJTransformer();
|
tjt = new TJTransformer();
|
||||||
|
|
||||||
tjt.setSourceImage(srcBuf, srcSize);
|
try {
|
||||||
|
tjt.setSourceImage(srcBuf, srcSize);
|
||||||
|
} catch (TJException e) { handleTJException(e); }
|
||||||
w = tjt.getWidth();
|
w = tjt.getWidth();
|
||||||
h = tjt.getHeight();
|
h = tjt.getHeight();
|
||||||
subsamp = tjt.getSubsamp();
|
subsamp = tjt.getSubsamp();
|
||||||
@@ -517,7 +535,7 @@ class TJBench {
|
|||||||
System.out.println("\n");
|
System.out.println("\n");
|
||||||
} else if (quiet == 0)
|
} else if (quiet == 0)
|
||||||
System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n",
|
System.out.format(">>>>> JPEG %s --> %s (%s) <<<<<\n",
|
||||||
formatName(subsamp, cs), pixFormatStr[pf],
|
formatName(subsamp, cs), PIXFORMATSTR[pf],
|
||||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
||||||
"Bottom-up" : "Top-down");
|
"Bottom-up" : "Top-down");
|
||||||
|
|
||||||
@@ -530,66 +548,66 @@ class TJBench {
|
|||||||
ntilesw = (w + tilew - 1) / tilew;
|
ntilesw = (w + tilew - 1) / tilew;
|
||||||
ntilesh = (h + tileh - 1) / tileh;
|
ntilesh = (h + tileh - 1) / tileh;
|
||||||
|
|
||||||
_w = w; _h = h; _tilew = tilew; _tileh = tileh;
|
tw = w; th = h; ttilew = tilew; ttileh = tileh;
|
||||||
if (quiet == 0) {
|
if (quiet == 0) {
|
||||||
System.out.format("\n%s size: %d x %d", (doTile ? "Tile" : "Image"),
|
System.out.format("\n%s size: %d x %d", (doTile ? "Tile" : "Image"),
|
||||||
_tilew, _tileh);
|
ttilew, ttileh);
|
||||||
if (sf.getNum() != 1 || sf.getDenom() != 1)
|
if (sf.getNum() != 1 || sf.getDenom() != 1)
|
||||||
System.out.format(" --> %d x %d", sf.getScaled(_w),
|
System.out.format(" --> %d x %d", sf.getScaled(tw),
|
||||||
sf.getScaled(_h));
|
sf.getScaled(th));
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
} else if (quiet == 1) {
|
} else if (quiet == 1) {
|
||||||
System.out.format("%-4s (%s) %-5s %-5s ", pixFormatStr[pf],
|
System.out.format("%-4s (%s) %-5s %-5s ", PIXFORMATSTR[pf],
|
||||||
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
|
(flags & TJ.FLAG_BOTTOMUP) != 0 ? "BU" : "TD",
|
||||||
csName[cs], subNameLong[subsamp]);
|
CSNAME[cs], SUBNAME_LONG[subsamp]);
|
||||||
System.out.format("%-5d %-5d ", tilew, tileh);
|
System.out.format("%-5d %-5d ", tilew, tileh);
|
||||||
}
|
}
|
||||||
|
|
||||||
_subsamp = subsamp;
|
tsubsamp = subsamp;
|
||||||
if (doTile || xformOp != TJTransform.OP_NONE || xformOpt != 0) {
|
if (doTile || xformOp != TJTransform.OP_NONE || xformOpt != 0) {
|
||||||
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
||||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||||
xformOp == TJTransform.OP_ROT90 ||
|
xformOp == TJTransform.OP_ROT90 ||
|
||||||
xformOp == TJTransform.OP_ROT270) {
|
xformOp == TJTransform.OP_ROT270) {
|
||||||
_w = h; _h = w; _tilew = tileh; _tileh = tilew;
|
tw = h; th = w; ttilew = tileh; ttileh = tilew;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((xformOpt & TJTransform.OPT_GRAY) != 0)
|
if ((xformOpt & TJTransform.OPT_GRAY) != 0)
|
||||||
_subsamp = TJ.SAMP_GRAY;
|
tsubsamp = TJ.SAMP_GRAY;
|
||||||
if (xformOp == TJTransform.OP_HFLIP ||
|
if (xformOp == TJTransform.OP_HFLIP ||
|
||||||
xformOp == TJTransform.OP_ROT180)
|
xformOp == TJTransform.OP_ROT180)
|
||||||
_w = _w - (_w % TJ.getMCUWidth(_subsamp));
|
tw = tw - (tw % TJ.getMCUWidth(tsubsamp));
|
||||||
if (xformOp == TJTransform.OP_VFLIP ||
|
if (xformOp == TJTransform.OP_VFLIP ||
|
||||||
xformOp == TJTransform.OP_ROT180)
|
xformOp == TJTransform.OP_ROT180)
|
||||||
_h = _h - (_h % TJ.getMCUHeight(_subsamp));
|
th = th - (th % TJ.getMCUHeight(tsubsamp));
|
||||||
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
||||||
xformOp == TJTransform.OP_ROT90)
|
xformOp == TJTransform.OP_ROT90)
|
||||||
_w = _w - (_w % TJ.getMCUHeight(_subsamp));
|
tw = tw - (tw % TJ.getMCUHeight(tsubsamp));
|
||||||
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
||||||
xformOp == TJTransform.OP_ROT270)
|
xformOp == TJTransform.OP_ROT270)
|
||||||
_h = _h - (_h % TJ.getMCUWidth(_subsamp));
|
th = th - (th % TJ.getMCUWidth(tsubsamp));
|
||||||
_ntilesw = (_w + _tilew - 1) / _tilew;
|
tntilesw = (tw + ttilew - 1) / ttilew;
|
||||||
_ntilesh = (_h + _tileh - 1) / _tileh;
|
tntilesh = (th + ttileh - 1) / ttileh;
|
||||||
|
|
||||||
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
||||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||||
xformOp == TJTransform.OP_ROT90 ||
|
xformOp == TJTransform.OP_ROT90 ||
|
||||||
xformOp == TJTransform.OP_ROT270) {
|
xformOp == TJTransform.OP_ROT270) {
|
||||||
if (_subsamp == TJ.SAMP_422)
|
if (tsubsamp == TJ.SAMP_422)
|
||||||
_subsamp = TJ.SAMP_440;
|
tsubsamp = TJ.SAMP_440;
|
||||||
else if (_subsamp == TJ.SAMP_440)
|
else if (tsubsamp == TJ.SAMP_440)
|
||||||
_subsamp = TJ.SAMP_422;
|
tsubsamp = TJ.SAMP_422;
|
||||||
}
|
}
|
||||||
|
|
||||||
TJTransform[] t = new TJTransform[_ntilesw * _ntilesh];
|
TJTransform[] t = new TJTransform[tntilesw * tntilesh];
|
||||||
jpegBuf =
|
jpegBuf =
|
||||||
new byte[_ntilesw * _ntilesh][TJ.bufSize(_tilew, _tileh, subsamp)];
|
new byte[tntilesw * tntilesh][TJ.bufSize(ttilew, ttileh, subsamp)];
|
||||||
|
|
||||||
for (y = 0, tile = 0; y < _h; y += _tileh) {
|
for (y = 0, tile = 0; y < th; y += ttileh) {
|
||||||
for (x = 0; x < _w; x += _tilew, tile++) {
|
for (x = 0; x < tw; x += ttilew, tile++) {
|
||||||
t[tile] = new TJTransform();
|
t[tile] = new TJTransform();
|
||||||
t[tile].width = Math.min(_tilew, _w - x);
|
t[tile].width = Math.min(ttilew, tw - x);
|
||||||
t[tile].height = Math.min(_tileh, _h - y);
|
t[tile].height = Math.min(ttileh, th - y);
|
||||||
t[tile].x = x;
|
t[tile].x = x;
|
||||||
t[tile].y = y;
|
t[tile].y = y;
|
||||||
t[tile].op = xformOp;
|
t[tile].op = xformOp;
|
||||||
@@ -604,7 +622,9 @@ class TJBench {
|
|||||||
elapsed = 0.;
|
elapsed = 0.;
|
||||||
while (true) {
|
while (true) {
|
||||||
start = getTime();
|
start = getTime();
|
||||||
tjt.transform(jpegBuf, t, flags);
|
try {
|
||||||
|
tjt.transform(jpegBuf, t, flags);
|
||||||
|
} catch (TJException e) { handleTJException(e); }
|
||||||
jpegSize = tjt.getTransformedSizes();
|
jpegSize = tjt.getTransformedSizes();
|
||||||
elapsed += getTime() - start;
|
elapsed += getTime() - start;
|
||||||
if (iter >= 0) {
|
if (iter >= 0) {
|
||||||
@@ -618,7 +638,7 @@ class TJBench {
|
|||||||
}
|
}
|
||||||
t = null;
|
t = null;
|
||||||
|
|
||||||
for (tile = 0, totalJpegSize = 0; tile < _ntilesw * _ntilesh; tile++)
|
for (tile = 0, totalJpegSize = 0; tile < tntilesw * tntilesh; tile++)
|
||||||
totalJpegSize += jpegSize[tile];
|
totalJpegSize += jpegSize[tile];
|
||||||
|
|
||||||
if (quiet != 0) {
|
if (quiet != 0) {
|
||||||
@@ -643,19 +663,19 @@ class TJBench {
|
|||||||
} else {
|
} else {
|
||||||
if (quiet == 1)
|
if (quiet == 1)
|
||||||
System.out.print("N/A N/A ");
|
System.out.print("N/A N/A ");
|
||||||
jpegBuf = new byte[1][TJ.bufSize(_tilew, _tileh, subsamp)];
|
jpegBuf = new byte[1][TJ.bufSize(ttilew, ttileh, subsamp)];
|
||||||
jpegSize = new int[1];
|
jpegSize = new int[1];
|
||||||
jpegBuf[0] = srcBuf;
|
jpegBuf[0] = srcBuf;
|
||||||
jpegSize[0] = srcSize;
|
jpegSize[0] = srcSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w == tilew)
|
if (w == tilew)
|
||||||
_tilew = _w;
|
ttilew = tw;
|
||||||
if (h == tileh)
|
if (h == tileh)
|
||||||
_tileh = _h;
|
ttileh = th;
|
||||||
if ((xformOpt & TJTransform.OPT_NOOUTPUT) == 0)
|
if ((xformOpt & TJTransform.OPT_NOOUTPUT) == 0)
|
||||||
decomp(null, jpegBuf, jpegSize, null, _w, _h, _subsamp, 0,
|
decomp(null, jpegBuf, jpegSize, null, tw, th, tsubsamp, 0,
|
||||||
fileName, _tilew, _tileh);
|
fileName, ttilew, ttileh);
|
||||||
else if (quiet == 1)
|
else if (quiet == 1)
|
||||||
System.out.println("N/A");
|
System.out.println("N/A");
|
||||||
|
|
||||||
@@ -702,7 +722,7 @@ class TJBench {
|
|||||||
System.out.println(" bytes to which each row of each plane in the intermediate YUV image is");
|
System.out.println(" bytes to which each row of each plane in the intermediate YUV image is");
|
||||||
System.out.println(" padded (default = 1)");
|
System.out.println(" padded (default = 1)");
|
||||||
System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a");
|
System.out.println("-scale M/N = Scale down the width/height of the decompressed JPEG image by a");
|
||||||
System.out.print (" factor of M/N (M/N = ");
|
System.out.print(" factor of M/N (M/N = ");
|
||||||
for (i = 0; i < nsf; i++) {
|
for (i = 0; i < nsf; i++) {
|
||||||
System.out.format("%d/%d", scalingFactors[i].getNum(),
|
System.out.format("%d/%d", scalingFactors[i].getNum(),
|
||||||
scalingFactors[i].getDenom());
|
scalingFactors[i].getDenom());
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
|
* Copyright (C)2011-2012, 2014-2015, 2017-2018 D. R. Commander.
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -41,25 +41,28 @@ import javax.swing.*;
|
|||||||
import org.libjpegturbo.turbojpeg.*;
|
import org.libjpegturbo.turbojpeg.*;
|
||||||
|
|
||||||
|
|
||||||
public class TJExample implements TJCustomFilter {
|
@SuppressWarnings("checkstyle:JavadocType")
|
||||||
|
class TJExample implements TJCustomFilter {
|
||||||
|
|
||||||
private static final String classname = new TJExample().getClass().getName();
|
static final String CLASS_NAME =
|
||||||
|
new TJExample().getClass().getName();
|
||||||
|
|
||||||
private static final int DEFAULT_SUBSAMP = TJ.SAMP_444;
|
static final int DEFAULT_SUBSAMP = TJ.SAMP_444;
|
||||||
private static final int DEFAULT_QUALITY = 95;
|
static final int DEFAULT_QUALITY = 95;
|
||||||
|
|
||||||
|
|
||||||
private static final String[] subsampName = {
|
static final String[] SUBSAMP_NAME = {
|
||||||
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1"
|
"4:4:4", "4:2:2", "4:2:0", "Grayscale", "4:4:0", "4:1:1"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] colorspaceName = {
|
static final String[] COLORSPACE_NAME = {
|
||||||
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
|
"RGB", "YCbCr", "GRAY", "CMYK", "YCCK"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* DCT filter example. This produces a negative of the image. */
|
/* DCT filter example. This produces a negative of the image. */
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public void customFilter(ShortBuffer coeffBuffer, Rectangle bufferRegion,
|
public void customFilter(ShortBuffer coeffBuffer, Rectangle bufferRegion,
|
||||||
Rectangle planeRegion, int componentIndex,
|
Rectangle planeRegion, int componentIndex,
|
||||||
int transformIndex, TJTransform transform)
|
int transformIndex, TJTransform transform)
|
||||||
@@ -70,8 +73,8 @@ public class TJExample implements TJCustomFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void usage() throws Exception {
|
static void usage() throws Exception {
|
||||||
System.out.println("\nUSAGE: java [Java options] " + classname +
|
System.out.println("\nUSAGE: java [Java options] " + CLASS_NAME +
|
||||||
" <Input image> <Output image> [options]\n");
|
" <Input image> <Output image> [options]\n");
|
||||||
|
|
||||||
System.out.println("Input and output images can be in any image format that the Java Image I/O");
|
System.out.println("Input and output images can be in any image format that the Java Image I/O");
|
||||||
@@ -85,7 +88,9 @@ public class TJExample implements TJCustomFilter {
|
|||||||
System.out.println(" compressing the output image. The default is to use the same level of");
|
System.out.println(" compressing the output image. The default is to use the same level of");
|
||||||
System.out.println(" subsampling as in the input image, if the input image is also a JPEG");
|
System.out.println(" subsampling as in the input image, if the input image is also a JPEG");
|
||||||
System.out.println(" image, or to use grayscale if the input image is a grayscale non-JPEG");
|
System.out.println(" image, or to use grayscale if the input image is a grayscale non-JPEG");
|
||||||
System.out.println(" image, or to use " + subsampName[DEFAULT_SUBSAMP] + " subsampling otherwise.\n");
|
System.out.println(" image, or to use " +
|
||||||
|
SUBSAMP_NAME[DEFAULT_SUBSAMP] +
|
||||||
|
" subsampling otherwise.\n");
|
||||||
|
|
||||||
System.out.println("-q <1-100> = Compress the output image with this JPEG quality level");
|
System.out.println("-q <1-100> = Compress the output image with this JPEG quality level");
|
||||||
System.out.println(" (default = " + DEFAULT_QUALITY + ").\n");
|
System.out.println(" (default = " + DEFAULT_QUALITY + ").\n");
|
||||||
@@ -95,15 +100,15 @@ public class TJExample implements TJCustomFilter {
|
|||||||
|
|
||||||
System.out.println("-scale M/N = Scale the input image by a factor of M/N when decompressing it.");
|
System.out.println("-scale M/N = Scale the input image by a factor of M/N when decompressing it.");
|
||||||
System.out.print("(M/N = ");
|
System.out.print("(M/N = ");
|
||||||
for (int i = 0; i < scalingFactors.length; i++) {
|
for (int i = 0; i < SCALING_FACTORS.length; i++) {
|
||||||
System.out.print(scalingFactors[i].getNum() + "/" +
|
System.out.print(SCALING_FACTORS[i].getNum() + "/" +
|
||||||
scalingFactors[i].getDenom());
|
SCALING_FACTORS[i].getDenom());
|
||||||
if (scalingFactors.length == 2 && i != scalingFactors.length - 1)
|
if (SCALING_FACTORS.length == 2 && i != SCALING_FACTORS.length - 1)
|
||||||
System.out.print(" or ");
|
System.out.print(" or ");
|
||||||
else if (scalingFactors.length > 2) {
|
else if (SCALING_FACTORS.length > 2) {
|
||||||
if (i != scalingFactors.length - 1)
|
if (i != SCALING_FACTORS.length - 1)
|
||||||
System.out.print(", ");
|
System.out.print(", ");
|
||||||
if (i == scalingFactors.length - 2)
|
if (i == SCALING_FACTORS.length - 2)
|
||||||
System.out.print("or ");
|
System.out.print("or ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,9 +182,9 @@ public class TJExample implements TJCustomFilter {
|
|||||||
TJScalingFactor tempsf =
|
TJScalingFactor tempsf =
|
||||||
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
|
new TJScalingFactor(Integer.parseInt(scaleArg[0]),
|
||||||
Integer.parseInt(scaleArg[1]));
|
Integer.parseInt(scaleArg[1]));
|
||||||
for (int j = 0; j < scalingFactors.length; j++) {
|
for (int j = 0; j < SCALING_FACTORS.length; j++) {
|
||||||
if (tempsf.equals(scalingFactors[j])) {
|
if (tempsf.equals(SCALING_FACTORS[j])) {
|
||||||
scalingFactor = scalingFactors[j];
|
scalingFactor = SCALING_FACTORS[j];
|
||||||
match = 1;
|
match = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -302,8 +307,8 @@ public class TJExample implements TJCustomFilter {
|
|||||||
|
|
||||||
System.out.println((doTransform ? "Transformed" : "Input") +
|
System.out.println((doTransform ? "Transformed" : "Input") +
|
||||||
" Image (jpg): " + width + " x " + height +
|
" Image (jpg): " + width + " x " + height +
|
||||||
" pixels, " + subsampName[inSubsamp] +
|
" pixels, " + SUBSAMP_NAME[inSubsamp] +
|
||||||
" subsampling, " + colorspaceName[inColorspace]);
|
" subsampling, " + COLORSPACE_NAME[inColorspace]);
|
||||||
|
|
||||||
if (outFormat.equalsIgnoreCase("jpg") && doTransform &&
|
if (outFormat.equalsIgnoreCase("jpg") && doTransform &&
|
||||||
scalingFactor.isOne() && outSubsamp < 0 && outQual < 0) {
|
scalingFactor.isOne() && outSubsamp < 0 && outQual < 0) {
|
||||||
@@ -362,7 +367,7 @@ public class TJExample implements TJCustomFilter {
|
|||||||
/* Output image format is JPEG. Compress the uncompressed image. */
|
/* Output image format is JPEG. Compress the uncompressed image. */
|
||||||
if (outQual < 0)
|
if (outQual < 0)
|
||||||
outQual = DEFAULT_QUALITY;
|
outQual = DEFAULT_QUALITY;
|
||||||
System.out.println(", " + subsampName[outSubsamp] +
|
System.out.println(", " + SUBSAMP_NAME[outSubsamp] +
|
||||||
" subsampling, quality = " + outQual);
|
" subsampling, quality = " + outQual);
|
||||||
|
|
||||||
TJCompressor tjc = new TJCompressor();
|
TJCompressor tjc = new TJCompressor();
|
||||||
@@ -395,5 +400,6 @@ public class TJExample implements TJCustomFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final TJScalingFactor[] scalingFactors = TJ.getScalingFactors();
|
static final TJScalingFactor[] SCALING_FACTORS =
|
||||||
|
TJ.getScalingFactors();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2017 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2018 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -37,13 +37,16 @@ import javax.imageio.*;
|
|||||||
import java.nio.*;
|
import java.nio.*;
|
||||||
import org.libjpegturbo.turbojpeg.*;
|
import org.libjpegturbo.turbojpeg.*;
|
||||||
|
|
||||||
public class TJUnitTest {
|
@SuppressWarnings("checkstyle:JavadocType")
|
||||||
|
final class TJUnitTest {
|
||||||
|
|
||||||
private static final String classname =
|
private TJUnitTest() {}
|
||||||
|
|
||||||
|
static final String CLASS_NAME =
|
||||||
new TJUnitTest().getClass().getName();
|
new TJUnitTest().getClass().getName();
|
||||||
|
|
||||||
private static void usage() {
|
static void usage() {
|
||||||
System.out.println("\nUSAGE: java " + classname + " [options]\n");
|
System.out.println("\nUSAGE: java " + CLASS_NAME + " [options]\n");
|
||||||
System.out.println("Options:");
|
System.out.println("Options:");
|
||||||
System.out.println("-yuv = test YUV encoding/decoding support");
|
System.out.println("-yuv = test YUV encoding/decoding support");
|
||||||
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest");
|
System.out.println("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest");
|
||||||
@@ -52,39 +55,39 @@ public class TJUnitTest {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] subNameLong = {
|
static final String[] SUBNAME_LONG = {
|
||||||
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
|
"4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
|
||||||
};
|
};
|
||||||
private static final String[] subName = {
|
static final String[] SUBNAME = {
|
||||||
"444", "422", "420", "GRAY", "440", "411"
|
"444", "422", "420", "GRAY", "440", "411"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] pixFormatStr = {
|
static final String[] PIXFORMATSTR = {
|
||||||
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
|
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
|
||||||
"RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
|
"RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final int[] _3byteFormats = {
|
static final int[] FORMATS_3BYTE = {
|
||||||
TJ.PF_RGB, TJ.PF_BGR
|
TJ.PF_RGB, TJ.PF_BGR
|
||||||
};
|
};
|
||||||
private static final int[] _3byteFormatsBI = {
|
static final int[] FORMATS_3BYTEBI = {
|
||||||
BufferedImage.TYPE_3BYTE_BGR
|
BufferedImage.TYPE_3BYTE_BGR
|
||||||
};
|
};
|
||||||
private static final int[] _4byteFormats = {
|
static final int[] FORMATS_4BYTE = {
|
||||||
TJ.PF_RGBX, TJ.PF_BGRX, TJ.PF_XBGR, TJ.PF_XRGB, TJ.PF_CMYK
|
TJ.PF_RGBX, TJ.PF_BGRX, TJ.PF_XBGR, TJ.PF_XRGB, TJ.PF_CMYK
|
||||||
};
|
};
|
||||||
private static final int[] _4byteFormatsBI = {
|
static final int[] FORMATS_4BYTEBI = {
|
||||||
BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_INT_RGB,
|
BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_INT_RGB,
|
||||||
BufferedImage.TYPE_4BYTE_ABGR, BufferedImage.TYPE_4BYTE_ABGR_PRE,
|
BufferedImage.TYPE_4BYTE_ABGR, BufferedImage.TYPE_4BYTE_ABGR_PRE,
|
||||||
BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE
|
BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE
|
||||||
};
|
};
|
||||||
private static final int[] onlyGray = {
|
static final int[] FORMATS_GRAY = {
|
||||||
TJ.PF_GRAY
|
TJ.PF_GRAY
|
||||||
};
|
};
|
||||||
private static final int[] onlyGrayBI = {
|
static final int[] FORMATS_GRAYBI = {
|
||||||
BufferedImage.TYPE_BYTE_GRAY
|
BufferedImage.TYPE_BYTE_GRAY
|
||||||
};
|
};
|
||||||
private static final int[] onlyRGB = {
|
static final int[] FORMATS_RGB = {
|
||||||
TJ.PF_RGB
|
TJ.PF_RGB
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +97,7 @@ public class TJUnitTest {
|
|||||||
|
|
||||||
private static int exitStatus = 0;
|
private static int exitStatus = 0;
|
||||||
|
|
||||||
private static int biTypePF(int biType) {
|
static int biTypePF(int biType) {
|
||||||
ByteOrder byteOrder = ByteOrder.nativeOrder();
|
ByteOrder byteOrder = ByteOrder.nativeOrder();
|
||||||
switch (biType) {
|
switch (biType) {
|
||||||
case BufferedImage.TYPE_3BYTE_BGR:
|
case BufferedImage.TYPE_3BYTE_BGR:
|
||||||
@@ -111,11 +114,12 @@ public class TJUnitTest {
|
|||||||
case BufferedImage.TYPE_INT_ARGB:
|
case BufferedImage.TYPE_INT_ARGB:
|
||||||
case BufferedImage.TYPE_INT_ARGB_PRE:
|
case BufferedImage.TYPE_INT_ARGB_PRE:
|
||||||
return TJ.PF_BGRA;
|
return TJ.PF_BGRA;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String biTypeStr(int biType) {
|
static String biTypeStr(int biType) {
|
||||||
switch (biType) {
|
switch (biType) {
|
||||||
case BufferedImage.TYPE_3BYTE_BGR:
|
case BufferedImage.TYPE_3BYTE_BGR:
|
||||||
return "3BYTE_BGR";
|
return "3BYTE_BGR";
|
||||||
@@ -133,12 +137,13 @@ public class TJUnitTest {
|
|||||||
return "INT_ARGB";
|
return "INT_ARGB";
|
||||||
case BufferedImage.TYPE_INT_ARGB_PRE:
|
case BufferedImage.TYPE_INT_ARGB_PRE:
|
||||||
return "INT_ARGB_PRE";
|
return "INT_ARGB_PRE";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
}
|
}
|
||||||
return "Unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initBuf(byte[] buf, int w, int pitch, int h, int pf,
|
static void initBuf(byte[] buf, int w, int pitch, int h, int pf, int flags)
|
||||||
int flags) throws Exception {
|
throws Exception {
|
||||||
int roffset = TJ.getRedOffset(pf);
|
int roffset = TJ.getRedOffset(pf);
|
||||||
int goffset = TJ.getGreenOffset(pf);
|
int goffset = TJ.getGreenOffset(pf);
|
||||||
int boffset = TJ.getBlueOffset(pf);
|
int boffset = TJ.getBlueOffset(pf);
|
||||||
@@ -206,8 +211,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initIntBuf(int[] buf, int w, int pitch, int h, int pf,
|
static void initIntBuf(int[] buf, int w, int pitch, int h, int pf, int flags)
|
||||||
int flags) throws Exception {
|
throws Exception {
|
||||||
int rshift = TJ.getRedOffset(pf) * 8;
|
int rshift = TJ.getRedOffset(pf) * 8;
|
||||||
int gshift = TJ.getGreenOffset(pf) * 8;
|
int gshift = TJ.getGreenOffset(pf) * 8;
|
||||||
int bshift = TJ.getBlueOffset(pf) * 8;
|
int bshift = TJ.getBlueOffset(pf) * 8;
|
||||||
@@ -238,8 +243,7 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initImg(BufferedImage img, int pf, int flags)
|
static void initImg(BufferedImage img, int pf, int flags) throws Exception {
|
||||||
throws Exception {
|
|
||||||
WritableRaster wr = img.getRaster();
|
WritableRaster wr = img.getRaster();
|
||||||
int imgType = img.getType();
|
int imgType = img.getType();
|
||||||
|
|
||||||
@@ -262,8 +266,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkVal(int row, int col, int v, String vname, int cv)
|
static void checkVal(int row, int col, int v, String vname, int cv)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
v = (v < 0) ? v + 256 : v;
|
v = (v < 0) ? v + 256 : v;
|
||||||
if (v < cv - 1 || v > cv + 1) {
|
if (v < cv - 1 || v > cv + 1) {
|
||||||
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
||||||
@@ -271,8 +275,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkVal0(int row, int col, int v, String vname)
|
static void checkVal0(int row, int col, int v, String vname)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
v = (v < 0) ? v + 256 : v;
|
v = (v < 0) ? v + 256 : v;
|
||||||
if (v > 1) {
|
if (v > 1) {
|
||||||
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
||||||
@@ -280,8 +284,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkVal255(int row, int col, int v, String vname)
|
static void checkVal255(int row, int col, int v, String vname)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
v = (v < 0) ? v + 256 : v;
|
v = (v < 0) ? v + 256 : v;
|
||||||
if (v < 254) {
|
if (v < 254) {
|
||||||
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
throw new Exception("Comp. " + vname + " at " + row + "," + col +
|
||||||
@@ -289,9 +293,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkBuf(byte[] buf, int w, int pitch, int h, int pf,
|
static int checkBuf(byte[] buf, int w, int pitch, int h, int pf, int subsamp,
|
||||||
int subsamp, TJScalingFactor sf, int flags)
|
TJScalingFactor sf, int flags) throws Exception {
|
||||||
throws Exception {
|
|
||||||
int roffset = TJ.getRedOffset(pf);
|
int roffset = TJ.getRedOffset(pf);
|
||||||
int goffset = TJ.getGreenOffset(pf);
|
int goffset = TJ.getGreenOffset(pf);
|
||||||
int boffset = TJ.getBlueOffset(pf);
|
int boffset = TJ.getBlueOffset(pf);
|
||||||
@@ -416,9 +419,9 @@ public class TJUnitTest {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkIntBuf(int[] buf, int w, int pitch, int h, int pf,
|
static int checkIntBuf(int[] buf, int w, int pitch, int h, int pf,
|
||||||
int subsamp, TJScalingFactor sf, int flags)
|
int subsamp, TJScalingFactor sf, int flags)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
int rshift = TJ.getRedOffset(pf) * 8;
|
int rshift = TJ.getRedOffset(pf) * 8;
|
||||||
int gshift = TJ.getGreenOffset(pf) * 8;
|
int gshift = TJ.getGreenOffset(pf) * 8;
|
||||||
int bshift = TJ.getBlueOffset(pf) * 8;
|
int bshift = TJ.getBlueOffset(pf) * 8;
|
||||||
@@ -494,8 +497,8 @@ public class TJUnitTest {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkImg(BufferedImage img, int pf, int subsamp,
|
static int checkImg(BufferedImage img, int pf, int subsamp,
|
||||||
TJScalingFactor sf, int flags) throws Exception {
|
TJScalingFactor sf, int flags) throws Exception {
|
||||||
WritableRaster wr = img.getRaster();
|
WritableRaster wr = img.getRaster();
|
||||||
int imgType = img.getType();
|
int imgType = img.getType();
|
||||||
if (imgType == BufferedImage.TYPE_INT_RGB ||
|
if (imgType == BufferedImage.TYPE_INT_RGB ||
|
||||||
@@ -519,18 +522,17 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int PAD(int v, int p) {
|
static int pad(int v, int p) {
|
||||||
return ((v + (p) - 1) & (~((p) - 1)));
|
return ((v + (p) - 1) & (~((p) - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int checkBufYUV(byte[] buf, int size, int w, int h,
|
static int checkBufYUV(byte[] buf, int size, int w, int h, int subsamp,
|
||||||
int subsamp, TJScalingFactor sf)
|
TJScalingFactor sf) throws Exception {
|
||||||
throws Exception {
|
|
||||||
int row, col;
|
int row, col;
|
||||||
int hsf = TJ.getMCUWidth(subsamp) / 8, vsf = TJ.getMCUHeight(subsamp) / 8;
|
int hsf = TJ.getMCUWidth(subsamp) / 8, vsf = TJ.getMCUHeight(subsamp) / 8;
|
||||||
int pw = PAD(w, hsf), ph = PAD(h, vsf);
|
int pw = pad(w, hsf), ph = pad(h, vsf);
|
||||||
int cw = pw / hsf, ch = ph / vsf;
|
int cw = pw / hsf, ch = ph / vsf;
|
||||||
int ypitch = PAD(pw, pad), uvpitch = PAD(cw, pad);
|
int ypitch = pad(pw, pad), uvpitch = pad(cw, pad);
|
||||||
int retval = 1;
|
int retval = 1;
|
||||||
int correctsize = ypitch * ph +
|
int correctsize = ypitch * ph +
|
||||||
(subsamp == TJ.SAMP_GRAY ? 0 : uvpitch * ch * 2);
|
(subsamp == TJ.SAMP_GRAY ? 0 : uvpitch * ch * 2);
|
||||||
@@ -616,17 +618,17 @@ public class TJUnitTest {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeJPEG(byte[] jpegBuf, int jpegBufSize,
|
static void writeJPEG(byte[] jpegBuf, int jpegBufSize, String filename)
|
||||||
String filename) throws Exception {
|
throws Exception {
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
fos.write(jpegBuf, 0, jpegBufSize);
|
fos.write(jpegBuf, 0, jpegBufSize);
|
||||||
fos.close();
|
fos.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int compTest(TJCompressor tjc, byte[] dstBuf, int w,
|
static int compTest(TJCompressor tjc, byte[] dstBuf, int w, int h, int pf,
|
||||||
int h, int pf, String baseName, int subsamp,
|
String baseName, int subsamp, int jpegQual, int flags)
|
||||||
int jpegQual, int flags) throws Exception {
|
throws Exception {
|
||||||
String tempStr;
|
String tempStr;
|
||||||
byte[] srcBuf = null;
|
byte[] srcBuf = null;
|
||||||
BufferedImage img = null;
|
BufferedImage img = null;
|
||||||
@@ -639,9 +641,9 @@ public class TJUnitTest {
|
|||||||
if (bi) {
|
if (bi) {
|
||||||
pf = biTypePF(imgType);
|
pf = biTypePF(imgType);
|
||||||
pfStr = biTypeStr(imgType);
|
pfStr = biTypeStr(imgType);
|
||||||
pfStrLong = pfStr + " (" + pixFormatStr[pf] + ")";
|
pfStrLong = pfStr + " (" + PIXFORMATSTR[pf] + ")";
|
||||||
} else {
|
} else {
|
||||||
pfStr = pixFormatStr[pf];
|
pfStr = PIXFORMATSTR[pf];
|
||||||
pfStrLong = pfStr;
|
pfStrLong = pfStr;
|
||||||
}
|
}
|
||||||
ps = TJ.getPixelSize(pf);
|
ps = TJ.getPixelSize(pf);
|
||||||
@@ -650,7 +652,7 @@ public class TJUnitTest {
|
|||||||
img = new BufferedImage(w, h, imgType);
|
img = new BufferedImage(w, h, imgType);
|
||||||
initImg(img, pf, flags);
|
initImg(img, pf, flags);
|
||||||
tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" +
|
tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" +
|
||||||
subName[subsamp] + "_Q" + jpegQual + ".png";
|
SUBNAME[subsamp] + "_Q" + jpegQual + ".png";
|
||||||
File file = new File(tempStr);
|
File file = new File(tempStr);
|
||||||
ImageIO.write(img, "png", file);
|
ImageIO.write(img, "png", file);
|
||||||
tjc.setSourceImage(img, 0, 0, 0, 0);
|
tjc.setSourceImage(img, 0, 0, 0, 0);
|
||||||
@@ -665,7 +667,7 @@ public class TJUnitTest {
|
|||||||
tjc.setJPEGQuality(jpegQual);
|
tjc.setJPEGQuality(jpegQual);
|
||||||
if (doYUV) {
|
if (doYUV) {
|
||||||
System.out.format("%s %s -> YUV %s ... ", pfStrLong, buStrLong,
|
System.out.format("%s %s -> YUV %s ... ", pfStrLong, buStrLong,
|
||||||
subNameLong[subsamp]);
|
SUBNAME_LONG[subsamp]);
|
||||||
YUVImage yuvImage = tjc.encodeYUV(pad, flags);
|
YUVImage yuvImage = tjc.encodeYUV(pad, flags);
|
||||||
if (checkBufYUV(yuvImage.getBuf(), yuvImage.getSize(), w, h, subsamp,
|
if (checkBufYUV(yuvImage.getBuf(), yuvImage.getSize(), w, h, subsamp,
|
||||||
new TJScalingFactor(1, 1)) == 1)
|
new TJScalingFactor(1, 1)) == 1)
|
||||||
@@ -675,28 +677,27 @@ public class TJUnitTest {
|
|||||||
exitStatus = -1;
|
exitStatus = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.format("YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp],
|
System.out.format("YUV %s %s -> JPEG Q%d ... ", SUBNAME_LONG[subsamp],
|
||||||
buStrLong, jpegQual);
|
buStrLong, jpegQual);
|
||||||
tjc.setSourceImage(yuvImage);
|
tjc.setSourceImage(yuvImage);
|
||||||
} else {
|
} else {
|
||||||
System.out.format("%s %s -> %s Q%d ... ", pfStrLong, buStrLong,
|
System.out.format("%s %s -> %s Q%d ... ", pfStrLong, buStrLong,
|
||||||
subNameLong[subsamp], jpegQual);
|
SUBNAME_LONG[subsamp], jpegQual);
|
||||||
}
|
}
|
||||||
tjc.compress(dstBuf, flags);
|
tjc.compress(dstBuf, flags);
|
||||||
size = tjc.getCompressedSize();
|
size = tjc.getCompressedSize();
|
||||||
|
|
||||||
tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" +
|
tempStr = baseName + "_enc_" + pfStr + "_" + buStr + "_" +
|
||||||
subName[subsamp] + "_Q" + jpegQual + ".jpg";
|
SUBNAME[subsamp] + "_Q" + jpegQual + ".jpg";
|
||||||
writeJPEG(dstBuf, size, tempStr);
|
writeJPEG(dstBuf, size, tempStr);
|
||||||
System.out.println("Done.\n Result in " + tempStr);
|
System.out.println("Done.\n Result in " + tempStr);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void decompTest(TJDecompressor tjd, byte[] jpegBuf,
|
static void decompTest(TJDecompressor tjd, byte[] jpegBuf, int jpegSize,
|
||||||
int jpegSize, int w, int h, int pf,
|
int w, int h, int pf, String baseName, int subsamp,
|
||||||
String baseName, int subsamp, int flags,
|
int flags, TJScalingFactor sf) throws Exception {
|
||||||
TJScalingFactor sf) throws Exception {
|
|
||||||
String pfStr, pfStrLong, tempStr;
|
String pfStr, pfStrLong, tempStr;
|
||||||
String buStrLong = (flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
String buStrLong = (flags & TJ.FLAG_BOTTOMUP) != 0 ?
|
||||||
"Bottom-Up" : "Top-Down ";
|
"Bottom-Up" : "Top-Down ";
|
||||||
@@ -709,9 +710,9 @@ public class TJUnitTest {
|
|||||||
if (bi) {
|
if (bi) {
|
||||||
pf = biTypePF(imgType);
|
pf = biTypePF(imgType);
|
||||||
pfStr = biTypeStr(imgType);
|
pfStr = biTypeStr(imgType);
|
||||||
pfStrLong = pfStr + " (" + pixFormatStr[pf] + ")";
|
pfStrLong = pfStr + " (" + PIXFORMATSTR[pf] + ")";
|
||||||
} else {
|
} else {
|
||||||
pfStr = pixFormatStr[pf];
|
pfStr = PIXFORMATSTR[pf];
|
||||||
pfStrLong = pfStr;
|
pfStrLong = pfStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,7 +729,7 @@ public class TJUnitTest {
|
|||||||
throw new Exception("Scaled size mismatch");
|
throw new Exception("Scaled size mismatch");
|
||||||
|
|
||||||
if (doYUV) {
|
if (doYUV) {
|
||||||
System.out.format("JPEG -> YUV %s ", subNameLong[subsamp]);
|
System.out.format("JPEG -> YUV %s ", SUBNAME_LONG[subsamp]);
|
||||||
if (!sf.isOne())
|
if (!sf.isOne())
|
||||||
System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom());
|
System.out.format("%d/%d ... ", sf.getNum(), sf.getDenom());
|
||||||
else System.out.print("... ");
|
else System.out.print("... ");
|
||||||
@@ -741,7 +742,7 @@ public class TJUnitTest {
|
|||||||
System.out.print("FAILED!\n"); exitStatus = -1;
|
System.out.print("FAILED!\n"); exitStatus = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.format("YUV %s -> %s %s ... ", subNameLong[subsamp],
|
System.out.format("YUV %s -> %s %s ... ", SUBNAME_LONG[subsamp],
|
||||||
pfStrLong, buStrLong);
|
pfStrLong, buStrLong);
|
||||||
tjd.setSourceImage(yuvImage);
|
tjd.setSourceImage(yuvImage);
|
||||||
} else {
|
} else {
|
||||||
@@ -758,7 +759,7 @@ public class TJUnitTest {
|
|||||||
if (bi) {
|
if (bi) {
|
||||||
tempStr = baseName + "_dec_" + pfStr + "_" +
|
tempStr = baseName + "_dec_" + pfStr + "_" +
|
||||||
(((flags & TJ.FLAG_BOTTOMUP) != 0) ? "BU" : "TD") + "_" +
|
(((flags & TJ.FLAG_BOTTOMUP) != 0) ? "BU" : "TD") + "_" +
|
||||||
subName[subsamp] + "_" +
|
SUBNAME[subsamp] + "_" +
|
||||||
(double)sf.getNum() / (double)sf.getDenom() + "x" + ".png";
|
(double)sf.getNum() / (double)sf.getDenom() + "x" + ".png";
|
||||||
File file = new File(tempStr);
|
File file = new File(tempStr);
|
||||||
ImageIO.write(img, "png", file);
|
ImageIO.write(img, "png", file);
|
||||||
@@ -775,10 +776,9 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void decompTest(TJDecompressor tjd, byte[] jpegBuf,
|
static void decompTest(TJDecompressor tjd, byte[] jpegBuf, int jpegSize,
|
||||||
int jpegSize, int w, int h, int pf,
|
int w, int h, int pf, String baseName, int subsamp,
|
||||||
String baseName, int subsamp,
|
int flags) throws Exception {
|
||||||
int flags) throws Exception {
|
|
||||||
int i;
|
int i;
|
||||||
TJScalingFactor[] sf = TJ.getScalingFactors();
|
TJScalingFactor[] sf = TJ.getScalingFactors();
|
||||||
for (i = 0; i < sf.length; i++) {
|
for (i = 0; i < sf.length; i++) {
|
||||||
@@ -794,8 +794,8 @@ public class TJUnitTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void doTest(int w, int h, int[] formats, int subsamp,
|
static void doTest(int w, int h, int[] formats, int subsamp, String baseName)
|
||||||
String baseName) throws Exception {
|
throws Exception {
|
||||||
TJCompressor tjc = null;
|
TJCompressor tjc = null;
|
||||||
TJDecompressor tjd = null;
|
TJDecompressor tjd = null;
|
||||||
int size;
|
int size;
|
||||||
@@ -837,7 +837,7 @@ public class TJUnitTest {
|
|||||||
if (tjd != null) tjd.close();
|
if (tjd != null) tjd.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bufSizeTest() throws Exception {
|
static void bufSizeTest() throws Exception {
|
||||||
int w, h, i, subsamp;
|
int w, h, i, subsamp;
|
||||||
byte[] srcBuf, dstBuf = null;
|
byte[] srcBuf, dstBuf = null;
|
||||||
YUVImage dstImage = null;
|
YUVImage dstImage = null;
|
||||||
@@ -911,44 +911,45 @@ public class TJUnitTest {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
if (doYUV)
|
if (doYUV)
|
||||||
_4byteFormats[4] = -1;
|
FORMATS_4BYTE[4] = -1;
|
||||||
doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_444,
|
doTest(35, 39, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_444,
|
||||||
testName);
|
testName);
|
||||||
doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_444,
|
doTest(39, 41, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_444,
|
||||||
testName);
|
testName);
|
||||||
doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_422,
|
doTest(41, 35, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_422,
|
||||||
testName);
|
testName);
|
||||||
doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_422,
|
doTest(35, 39, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_422,
|
||||||
testName);
|
testName);
|
||||||
doTest(39, 41, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_420,
|
doTest(39, 41, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_420,
|
||||||
testName);
|
testName);
|
||||||
doTest(41, 35, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_420,
|
doTest(41, 35, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_420,
|
||||||
testName);
|
testName);
|
||||||
doTest(35, 39, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_440,
|
doTest(35, 39, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_440,
|
||||||
testName);
|
testName);
|
||||||
doTest(39, 41, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_440,
|
doTest(39, 41, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_440,
|
||||||
testName);
|
testName);
|
||||||
doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_411,
|
doTest(41, 35, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_411,
|
||||||
testName);
|
testName);
|
||||||
doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_411,
|
doTest(35, 39, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_411,
|
||||||
testName);
|
testName);
|
||||||
doTest(39, 41, bi ? onlyGrayBI : onlyGray, TJ.SAMP_GRAY, testName);
|
doTest(39, 41, bi ? FORMATS_GRAYBI : FORMATS_GRAY, TJ.SAMP_GRAY,
|
||||||
doTest(41, 35, bi ? _3byteFormatsBI : _3byteFormats, TJ.SAMP_GRAY,
|
|
||||||
testName);
|
testName);
|
||||||
_4byteFormats[4] = -1;
|
doTest(41, 35, bi ? FORMATS_3BYTEBI : FORMATS_3BYTE, TJ.SAMP_GRAY,
|
||||||
doTest(35, 39, bi ? _4byteFormatsBI : _4byteFormats, TJ.SAMP_GRAY,
|
testName);
|
||||||
|
FORMATS_4BYTE[4] = -1;
|
||||||
|
doTest(35, 39, bi ? FORMATS_4BYTEBI : FORMATS_4BYTE, TJ.SAMP_GRAY,
|
||||||
testName);
|
testName);
|
||||||
if (!bi)
|
if (!bi)
|
||||||
bufSizeTest();
|
bufSizeTest();
|
||||||
if (doYUV && !bi) {
|
if (doYUV && !bi) {
|
||||||
System.out.print("\n--------------------\n\n");
|
System.out.print("\n--------------------\n\n");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_444, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_444, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_422, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_422, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_420, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_420, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_440, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_440, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_411, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_411, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyRGB, TJ.SAMP_GRAY, "javatest_yuv0");
|
doTest(48, 48, FORMATS_RGB, TJ.SAMP_GRAY, "javatest_yuv0");
|
||||||
doTest(48, 48, onlyGray, TJ.SAMP_GRAY, "javatest_yuv0");
|
doTest(48, 48, FORMATS_GRAY, TJ.SAMP_GRAY, "javatest_yuv0");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -810,8 +810,6 @@
|
|||||||
<dd>
|
<dd>
|
||||||
<div class="block">TurboJPEG utility class (cannot be instantiated)</div>
|
<div class="block">TurboJPEG utility class (cannot be instantiated)</div>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJ.html#TJ()">TJ()</a></span> - Constructor for class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJ.html" title="class in org.libjpegturbo.turbojpeg">TJ</a></dt>
|
|
||||||
<dd> </dd>
|
|
||||||
<dt><a href="./org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a> - Class in <a href="./org/libjpegturbo/turbojpeg/package-summary.html">org.libjpegturbo.turbojpeg</a></dt>
|
<dt><a href="./org/libjpegturbo/turbojpeg/TJCompressor.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJCompressor</span></a> - Class in <a href="./org/libjpegturbo/turbojpeg/package-summary.html">org.libjpegturbo.turbojpeg</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="block">TurboJPEG compressor</div>
|
<div class="block">TurboJPEG compressor</div>
|
||||||
@@ -885,7 +883,9 @@
|
|||||||
<div class="block">Fractional scaling factor</div>
|
<div class="block">Fractional scaling factor</div>
|
||||||
</dd>
|
</dd>
|
||||||
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJScalingFactor.html#TJScalingFactor(int,%20int)">TJScalingFactor(int, int)</a></span> - Constructor for class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a></dt>
|
<dt><span class="strong"><a href="./org/libjpegturbo/turbojpeg/TJScalingFactor.html#TJScalingFactor(int,%20int)">TJScalingFactor(int, int)</a></span> - Constructor for class org.libjpegturbo.turbojpeg.<a href="./org/libjpegturbo/turbojpeg/TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a></dt>
|
||||||
<dd> </dd>
|
<dd>
|
||||||
|
<div class="block">Create a TurboJPEG scaling factor instance.</div>
|
||||||
|
</dd>
|
||||||
<dt><a href="./org/libjpegturbo/turbojpeg/TJTransform.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJTransform</span></a> - Class in <a href="./org/libjpegturbo/turbojpeg/package-summary.html">org.libjpegturbo.turbojpeg</a></dt>
|
<dt><a href="./org/libjpegturbo/turbojpeg/TJTransform.html" title="class in org.libjpegturbo.turbojpeg"><span class="strong">TJTransform</span></a> - Class in <a href="./org/libjpegturbo/turbojpeg/package-summary.html">org.libjpegturbo.turbojpeg</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<div class="block">Lossless transform parameters</div>
|
<div class="block">Lossless transform parameters</div>
|
||||||
|
|||||||
@@ -63,13 +63,13 @@
|
|||||||
<li>Summary: </li>
|
<li>Summary: </li>
|
||||||
<li>Nested | </li>
|
<li>Nested | </li>
|
||||||
<li><a href="#field_summary">Field</a> | </li>
|
<li><a href="#field_summary">Field</a> | </li>
|
||||||
<li><a href="#constructor_summary">Constr</a> | </li>
|
<li>Constr | </li>
|
||||||
<li><a href="#method_summary">Method</a></li>
|
<li><a href="#method_summary">Method</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="subNavList">
|
<ul class="subNavList">
|
||||||
<li>Detail: </li>
|
<li>Detail: </li>
|
||||||
<li><a href="#field_detail">Field</a> | </li>
|
<li><a href="#field_detail">Field</a> | </li>
|
||||||
<li><a href="#constructor_detail">Constr</a> | </li>
|
<li>Constr | </li>
|
||||||
<li><a href="#method_detail">Method</a></li>
|
<li><a href="#method_detail">Method</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -361,23 +361,6 @@ extends java.lang.Object</pre>
|
|||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
||||||
<ul class="blockList">
|
|
||||||
<li class="blockList"><a name="constructor_summary">
|
|
||||||
<!-- -->
|
|
||||||
</a>
|
|
||||||
<h3>Constructor Summary</h3>
|
|
||||||
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
|
|
||||||
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
|
|
||||||
<tr>
|
|
||||||
<th class="colOne" scope="col">Constructor and Description</th>
|
|
||||||
</tr>
|
|
||||||
<tr class="altColor">
|
|
||||||
<td class="colOne"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJ.html#TJ()">TJ</a></strong>()</code> </td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<!-- ========== METHOD SUMMARY =========== -->
|
<!-- ========== METHOD SUMMARY =========== -->
|
||||||
<ul class="blockList">
|
<ul class="blockList">
|
||||||
<li class="blockList"><a name="method_summary">
|
<li class="blockList"><a name="method_summary">
|
||||||
@@ -1070,23 +1053,6 @@ public static final int FLAG_FORCESSE3</pre>
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
||||||
<ul class="blockList">
|
|
||||||
<li class="blockList"><a name="constructor_detail">
|
|
||||||
<!-- -->
|
|
||||||
</a>
|
|
||||||
<h3>Constructor Detail</h3>
|
|
||||||
<a name="TJ()">
|
|
||||||
<!-- -->
|
|
||||||
</a>
|
|
||||||
<ul class="blockListLast">
|
|
||||||
<li class="blockList">
|
|
||||||
<h4>TJ</h4>
|
|
||||||
<pre>public TJ()</pre>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<!-- ============ METHOD DETAIL ========== -->
|
<!-- ============ METHOD DETAIL ========== -->
|
||||||
<ul class="blockList">
|
<ul class="blockList">
|
||||||
<li class="blockList"><a name="method_detail">
|
<li class="blockList"><a name="method_detail">
|
||||||
@@ -1372,13 +1338,13 @@ public static int bufSizeYUV(int width,
|
|||||||
<li>Summary: </li>
|
<li>Summary: </li>
|
||||||
<li>Nested | </li>
|
<li>Nested | </li>
|
||||||
<li><a href="#field_summary">Field</a> | </li>
|
<li><a href="#field_summary">Field</a> | </li>
|
||||||
<li><a href="#constructor_summary">Constr</a> | </li>
|
<li>Constr | </li>
|
||||||
<li><a href="#method_summary">Method</a></li>
|
<li><a href="#method_summary">Method</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="subNavList">
|
<ul class="subNavList">
|
||||||
<li>Detail: </li>
|
<li>Detail: </li>
|
||||||
<li><a href="#field_detail">Field</a> | </li>
|
<li><a href="#field_detail">Field</a> | </li>
|
||||||
<li><a href="#constructor_detail">Constr</a> | </li>
|
<li>Constr | </li>
|
||||||
<li><a href="#method_detail">Method</a></li>
|
<li><a href="#method_detail">Method</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -579,8 +579,8 @@ public void setSourceImage(byte[] srcImage,
|
|||||||
<p>
|
<p>
|
||||||
NOTE: This method has no effect when compressing a JPEG image from a YUV
|
NOTE: This method has no effect when compressing a JPEG image from a YUV
|
||||||
planar source. In that case, the level of chrominance subsampling in
|
planar source. In that case, the level of chrominance subsampling in
|
||||||
the JPEG image is determined by the source. Further, this method has no
|
the JPEG image is determined by the source. Furthermore, this method has
|
||||||
effect when encoding to a pre-allocated <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance. In
|
no effect when encoding to a pre-allocated <a href="../../../org/libjpegturbo/turbojpeg/YUVImage.html" title="class in org.libjpegturbo.turbojpeg"><code>YUVImage</code></a> instance. In
|
||||||
that case, the level of chrominance subsampling is determined by the
|
that case, the level of chrominance subsampling is determined by the
|
||||||
destination.</div>
|
destination.</div>
|
||||||
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>newSubsamp</code> - the level of chrominance subsampling to use in
|
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>newSubsamp</code> - the level of chrominance subsampling to use in
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ extends java.lang.Object</pre>
|
|||||||
</tr>
|
</tr>
|
||||||
<tr class="altColor">
|
<tr class="altColor">
|
||||||
<td class="colOne"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#TJScalingFactor(int,%20int)">TJScalingFactor</a></strong>(int num,
|
<td class="colOne"><code><strong><a href="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html#TJScalingFactor(int,%20int)">TJScalingFactor</a></strong>(int num,
|
||||||
int denom)</code> </td>
|
int denom)</code>
|
||||||
|
<div class="block">Create a TurboJPEG scaling factor instance.</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
@@ -197,6 +199,8 @@ extends java.lang.Object</pre>
|
|||||||
<h4>TJScalingFactor</h4>
|
<h4>TJScalingFactor</h4>
|
||||||
<pre>public TJScalingFactor(int num,
|
<pre>public TJScalingFactor(int num,
|
||||||
int denom)</pre>
|
int denom)</pre>
|
||||||
|
<div class="block">Create a TurboJPEG scaling factor instance.</div>
|
||||||
|
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>num</code> - numerator</dd><dd><code>denom</code> - denominator</dd></dl>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@@ -239,7 +243,8 @@ extends java.lang.Object</pre>
|
|||||||
<div class="block">Returns the scaled value of <code>dimension</code>. This function
|
<div class="block">Returns the scaled value of <code>dimension</code>. This function
|
||||||
performs the integer equivalent of
|
performs the integer equivalent of
|
||||||
<code>ceil(dimension * scalingFactor)</code>.</div>
|
<code>ceil(dimension * scalingFactor)</code>.</div>
|
||||||
<dl><dt><span class="strong">Returns:</span></dt><dd>the scaled value of <code>dimension</code>.</dd></dl>
|
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>dimension</code> - width or height to multiply by this scaling factor</dd>
|
||||||
|
<dt><span class="strong">Returns:</span></dt><dd>the scaled value of <code>dimension</code>.</dd></dl>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<a name="equals(org.libjpegturbo.turbojpeg.TJScalingFactor)">
|
<a name="equals(org.libjpegturbo.turbojpeg.TJScalingFactor)">
|
||||||
@@ -251,7 +256,8 @@ extends java.lang.Object</pre>
|
|||||||
<pre>public boolean equals(<a href="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a> other)</pre>
|
<pre>public boolean equals(<a href="../../../org/libjpegturbo/turbojpeg/TJScalingFactor.html" title="class in org.libjpegturbo.turbojpeg">TJScalingFactor</a> other)</pre>
|
||||||
<div class="block">Returns true or false, depending on whether this instance and
|
<div class="block">Returns true or false, depending on whether this instance and
|
||||||
<code>other</code> have the same numerator and denominator.</div>
|
<code>other</code> have the same numerator and denominator.</div>
|
||||||
<dl><dt><span class="strong">Returns:</span></dt><dd>true or false, depending on whether this instance and
|
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>other</code> - the scaling factor against which to compare this one</dd>
|
||||||
|
<dt><span class="strong">Returns:</span></dt><dd>true or false, depending on whether this instance and
|
||||||
<code>other</code> have the same numerator and denominator.</dd></dl>
|
<code>other</code> have the same numerator and denominator.</dd></dl>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2013, 2017 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2013, 2017-2018 D. R. Commander. All Rights Reserved.
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,6 +34,8 @@ package org.libjpegturbo.turbojpeg;
|
|||||||
*/
|
*/
|
||||||
public final class TJ {
|
public final class TJ {
|
||||||
|
|
||||||
|
private TJ() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of chrominance subsampling options
|
* The number of chrominance subsampling options
|
||||||
*/
|
*/
|
||||||
@@ -89,10 +91,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getMCUWidth(int subsamp) {
|
public static int getMCUWidth(int subsamp) {
|
||||||
checkSubsampling(subsamp);
|
checkSubsampling(subsamp);
|
||||||
return mcuWidth[subsamp];
|
return MCU_WIDTH[subsamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] mcuWidth = {
|
private static final int[] MCU_WIDTH = {
|
||||||
8, 16, 16, 8, 8, 32
|
8, 16, 16, 8, 8, 32
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,10 +111,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getMCUHeight(int subsamp) {
|
public static int getMCUHeight(int subsamp) {
|
||||||
checkSubsampling(subsamp);
|
checkSubsampling(subsamp);
|
||||||
return mcuHeight[subsamp];
|
return MCU_HEIGHT[subsamp];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] mcuHeight = {
|
private static final int[] MCU_HEIGHT = {
|
||||||
8, 8, 16, 8, 16, 8
|
8, 8, 16, 8, 16, 8
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -217,10 +219,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getPixelSize(int pixelFormat) {
|
public static int getPixelSize(int pixelFormat) {
|
||||||
checkPixelFormat(pixelFormat);
|
checkPixelFormat(pixelFormat);
|
||||||
return pixelSize[pixelFormat];
|
return PIXEL_SIZE[pixelFormat];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] pixelSize = {
|
private static final int[] PIXEL_SIZE = {
|
||||||
3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
|
3, 3, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -239,10 +241,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getRedOffset(int pixelFormat) {
|
public static int getRedOffset(int pixelFormat) {
|
||||||
checkPixelFormat(pixelFormat);
|
checkPixelFormat(pixelFormat);
|
||||||
return redOffset[pixelFormat];
|
return RED_OFFSET[pixelFormat];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] redOffset = {
|
private static final int[] RED_OFFSET = {
|
||||||
0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
|
0, 2, 0, 2, 3, 1, -1, 0, 2, 3, 1, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -261,10 +263,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getGreenOffset(int pixelFormat) {
|
public static int getGreenOffset(int pixelFormat) {
|
||||||
checkPixelFormat(pixelFormat);
|
checkPixelFormat(pixelFormat);
|
||||||
return greenOffset[pixelFormat];
|
return GREEN_OFFSET[pixelFormat];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] greenOffset = {
|
private static final int[] GREEN_OFFSET = {
|
||||||
1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
|
1, 1, 1, 1, 2, 2, -1, 1, 1, 2, 2, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -283,10 +285,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getBlueOffset(int pixelFormat) {
|
public static int getBlueOffset(int pixelFormat) {
|
||||||
checkPixelFormat(pixelFormat);
|
checkPixelFormat(pixelFormat);
|
||||||
return blueOffset[pixelFormat];
|
return BLUE_OFFSET[pixelFormat];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] blueOffset = {
|
private static final int[] BLUE_OFFSET = {
|
||||||
2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
|
2, 0, 2, 0, 1, 3, -1, 2, 0, 1, 3, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -305,10 +307,10 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static int getAlphaOffset(int pixelFormat) {
|
public static int getAlphaOffset(int pixelFormat) {
|
||||||
checkPixelFormat(pixelFormat);
|
checkPixelFormat(pixelFormat);
|
||||||
return alphaOffset[pixelFormat];
|
return ALPHA_OFFSET[pixelFormat];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int[] alphaOffset = {
|
private static final int[] ALPHA_OFFSET = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -340,6 +342,7 @@ public final class TJ {
|
|||||||
* can be compressed from and decompressed to any of the extended RGB pixel
|
* can be compressed from and decompressed to any of the extended RGB pixel
|
||||||
* formats or grayscale, or they can be decompressed to YUV planar images.
|
* formats or grayscale, or they can be decompressed to YUV planar images.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:ConstantName")
|
||||||
public static final int CS_YCbCr = 1;
|
public static final int CS_YCbCr = 1;
|
||||||
/**
|
/**
|
||||||
* Grayscale colorspace. The JPEG image retains only the luminance data (Y
|
* Grayscale colorspace. The JPEG image retains only the luminance data (Y
|
||||||
@@ -374,12 +377,16 @@ public final class TJ {
|
|||||||
*/
|
*/
|
||||||
public static final int FLAG_BOTTOMUP = 2;
|
public static final int FLAG_BOTTOMUP = 2;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocVariable")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int FLAG_FORCEMMX = 8;
|
public static final int FLAG_FORCEMMX = 8;
|
||||||
|
@SuppressWarnings("checkstyle:JavadocVariable")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int FLAG_FORCESSE = 16;
|
public static final int FLAG_FORCESSE = 16;
|
||||||
|
@SuppressWarnings("checkstyle:JavadocVariable")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int FLAG_FORCESSE2 = 32;
|
public static final int FLAG_FORCESSE2 = 32;
|
||||||
|
@SuppressWarnings("checkstyle:JavadocVariable")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final int FLAG_FORCESSE3 = 128;
|
public static final int FLAG_FORCESSE3 = 128;
|
||||||
|
|
||||||
@@ -490,6 +497,7 @@ public final class TJ {
|
|||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #bufSizeYUV(int, int, int, int)} instead.
|
* @deprecated Use {@link #bufSizeYUV(int, int, int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static native int bufSizeYUV(int width, int height, int subsamp);
|
public static native int bufSizeYUV(int width, int height, int subsamp);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2015 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2015, 2018, 2020 D. R. Commander. All Rights Reserved.
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -77,6 +77,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* @deprecated Use
|
* @deprecated Use
|
||||||
* {@link #TJCompressor(byte[], int, int, int, int, int, int)} instead.
|
* {@link #TJCompressor(byte[], int, int, int, int, int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TJCompressor(byte[] srcImage, int width, int pitch, int height,
|
public TJCompressor(byte[] srcImage, int width, int pitch, int height,
|
||||||
int pixelFormat) throws TJException {
|
int pixelFormat) throws TJException {
|
||||||
@@ -164,6 +165,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* @deprecated Use
|
* @deprecated Use
|
||||||
* {@link #setSourceImage(byte[], int, int, int, int, int, int)} instead.
|
* {@link #setSourceImage(byte[], int, int, int, int, int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setSourceImage(byte[] srcImage, int width, int pitch,
|
public void setSourceImage(byte[] srcImage, int width, int pitch,
|
||||||
int height, int pixelFormat) throws TJException {
|
int height, int pixelFormat) throws TJException {
|
||||||
@@ -285,8 +287,8 @@ public class TJCompressor implements Closeable {
|
|||||||
* <p>
|
* <p>
|
||||||
* NOTE: This method has no effect when compressing a JPEG image from a YUV
|
* NOTE: This method has no effect when compressing a JPEG image from a YUV
|
||||||
* planar source. In that case, the level of chrominance subsampling in
|
* planar source. In that case, the level of chrominance subsampling in
|
||||||
* the JPEG image is determined by the source. Further, this method has no
|
* the JPEG image is determined by the source. Furthermore, this method has
|
||||||
* effect when encoding to a pre-allocated {@link YUVImage} instance. In
|
* no effect when encoding to a pre-allocated {@link YUVImage} instance. In
|
||||||
* that case, the level of chrominance subsampling is determined by the
|
* that case, the level of chrominance subsampling is determined by the
|
||||||
* destination.
|
* destination.
|
||||||
*
|
*
|
||||||
@@ -375,8 +377,15 @@ public class TJCompressor implements Closeable {
|
|||||||
* #getCompressedSize} to obtain the size of the JPEG image.
|
* #getCompressedSize} to obtain the size of the JPEG image.
|
||||||
*/
|
*/
|
||||||
public byte[] compress(int flags) throws TJException {
|
public byte[] compress(int flags) throws TJException {
|
||||||
checkSourceImage();
|
byte[] buf;
|
||||||
byte[] buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
|
if (srcYUVImage != null) {
|
||||||
|
buf = new byte[TJ.bufSize(srcYUVImage.getWidth(),
|
||||||
|
srcYUVImage.getHeight(),
|
||||||
|
srcYUVImage.getSubsamp())];
|
||||||
|
} else {
|
||||||
|
checkSourceImage();
|
||||||
|
buf = new byte[TJ.bufSize(srcWidth, srcHeight, subsamp)];
|
||||||
|
}
|
||||||
compress(buf, flags);
|
compress(buf, flags);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@@ -386,6 +395,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
||||||
* {@link #compress(byte[], int)} instead.
|
* {@link #compress(byte[], int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void compress(BufferedImage srcImage, byte[] dstBuf, int flags)
|
public void compress(BufferedImage srcImage, byte[] dstBuf, int flags)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
@@ -398,6 +408,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
||||||
* {@link #compress(int)} instead.
|
* {@link #compress(int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public byte[] compress(BufferedImage srcImage, int flags)
|
public byte[] compress(BufferedImage srcImage, int flags)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
@@ -445,14 +456,16 @@ public class TJCompressor implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #encodeYUV(YUVImage, int)} instead.
|
* @deprecated Use {@link #encodeYUV(YUVImage, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void encodeYUV(byte[] dstBuf, int flags) throws TJException {
|
public void encodeYUV(byte[] dstBuf, int flags) throws TJException {
|
||||||
if (dstBuf == null)
|
if (dstBuf == null)
|
||||||
throw new IllegalArgumentException("Invalid argument in encodeYUV()");
|
throw new IllegalArgumentException("Invalid argument in encodeYUV()");
|
||||||
checkSourceImage();
|
checkSourceImage();
|
||||||
checkSubsampling();
|
checkSubsampling();
|
||||||
YUVImage yuvImage = new YUVImage(dstBuf, srcWidth, 4, srcHeight, subsamp);
|
YUVImage dstYUVImage = new YUVImage(dstBuf, srcWidth, 4, srcHeight,
|
||||||
encodeYUV(yuvImage, flags);
|
subsamp);
|
||||||
|
encodeYUV(dstYUVImage, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,9 +490,9 @@ public class TJCompressor implements Closeable {
|
|||||||
checkSubsampling();
|
checkSubsampling();
|
||||||
if (pad < 1 || ((pad & (pad - 1)) != 0))
|
if (pad < 1 || ((pad & (pad - 1)) != 0))
|
||||||
throw new IllegalStateException("Invalid argument in encodeYUV()");
|
throw new IllegalStateException("Invalid argument in encodeYUV()");
|
||||||
YUVImage yuvImage = new YUVImage(srcWidth, pad, srcHeight, subsamp);
|
YUVImage dstYUVImage = new YUVImage(srcWidth, pad, srcHeight, subsamp);
|
||||||
encodeYUV(yuvImage, flags);
|
encodeYUV(dstYUVImage, flags);
|
||||||
return yuvImage;
|
return dstYUVImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -506,21 +519,22 @@ public class TJCompressor implements Closeable {
|
|||||||
public YUVImage encodeYUV(int[] strides, int flags) throws TJException {
|
public YUVImage encodeYUV(int[] strides, int flags) throws TJException {
|
||||||
checkSourceImage();
|
checkSourceImage();
|
||||||
checkSubsampling();
|
checkSubsampling();
|
||||||
YUVImage yuvImage = new YUVImage(srcWidth, strides, srcHeight, subsamp);
|
YUVImage dstYUVImage = new YUVImage(srcWidth, strides, srcHeight, subsamp);
|
||||||
encodeYUV(yuvImage, flags);
|
encodeYUV(dstYUVImage, flags);
|
||||||
return yuvImage;
|
return dstYUVImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #encodeYUV(int, int)} instead.
|
* @deprecated Use {@link #encodeYUV(int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public byte[] encodeYUV(int flags) throws TJException {
|
public byte[] encodeYUV(int flags) throws TJException {
|
||||||
checkSourceImage();
|
checkSourceImage();
|
||||||
checkSubsampling();
|
checkSubsampling();
|
||||||
YUVImage yuvImage = new YUVImage(srcWidth, 4, srcHeight, subsamp);
|
YUVImage dstYUVImage = new YUVImage(srcWidth, 4, srcHeight, subsamp);
|
||||||
encodeYUV(yuvImage, flags);
|
encodeYUV(dstYUVImage, flags);
|
||||||
return yuvImage.getBuf();
|
return dstYUVImage.getBuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -528,6 +542,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
||||||
* {@link #encodeYUV(byte[], int)} instead.
|
* {@link #encodeYUV(byte[], int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void encodeYUV(BufferedImage srcImage, byte[] dstBuf, int flags)
|
public void encodeYUV(BufferedImage srcImage, byte[] dstBuf, int flags)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
@@ -540,6 +555,7 @@ public class TJCompressor implements Closeable {
|
|||||||
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
* {@link #setSourceImage(BufferedImage, int, int, int, int)} and
|
||||||
* {@link #encodeYUV(int, int)} instead.
|
* {@link #encodeYUV(int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public byte[] encodeYUV(BufferedImage srcImage, int flags)
|
public byte[] encodeYUV(BufferedImage srcImage, int flags)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
@@ -567,6 +583,7 @@ public class TJCompressor implements Closeable {
|
|||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:DesignForExtension")
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
try {
|
try {
|
||||||
@@ -582,44 +599,53 @@ public class TJCompressor implements Closeable {
|
|||||||
private native void destroy() throws TJException;
|
private native void destroy() throws TJException;
|
||||||
|
|
||||||
// JPEG size in bytes is returned
|
// JPEG size in bytes is returned
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private native int compress(byte[] srcBuf, int width, int pitch,
|
private native int compress(byte[] srcBuf, int width, int pitch,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
int height, int pixelFormat, byte[] jpegBuf, int jpegSubsamp, int jpegQual,
|
||||||
int flags) throws TJException;
|
int flags) throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
private native int compress(byte[] srcBuf, int x, int y, int width,
|
private native int compress(byte[] srcBuf, int x, int y, int width,
|
||||||
int pitch, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
int pitch, int height, int pixelFormat, byte[] jpegBuf, int jpegSubsamp,
|
||||||
int jpegQual, int flags) throws TJException;
|
int jpegQual, int flags) throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private native int compress(int[] srcBuf, int width, int stride,
|
private native int compress(int[] srcBuf, int width, int stride,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp, int jpegQual,
|
int height, int pixelFormat, byte[] jpegBuf, int jpegSubsamp, int jpegQual,
|
||||||
int flags) throws TJException;
|
int flags) throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
private native int compress(int[] srcBuf, int x, int y, int width,
|
private native int compress(int[] srcBuf, int x, int y, int width,
|
||||||
int stride, int height, int pixelFormat, byte[] dstBuf, int jpegSubsamp,
|
int stride, int height, int pixelFormat, byte[] jpegBuf, int jpegSubsamp,
|
||||||
int jpegQual, int flags) throws TJException;
|
int jpegQual, int flags) throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
private native int compressFromYUV(byte[][] srcPlanes, int[] srcOffsets,
|
private native int compressFromYUV(byte[][] srcPlanes, int[] srcOffsets,
|
||||||
int width, int[] srcStrides, int height, int subsamp, byte[] dstBuf,
|
int width, int[] srcStrides, int height, int subsamp, byte[] jpegBuf,
|
||||||
int jpegQual, int flags)
|
int jpegQual, int flags)
|
||||||
throws TJException;
|
throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private native void encodeYUV(byte[] srcBuf, int width, int pitch,
|
private native void encodeYUV(byte[] srcBuf, int width, int pitch,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
||||||
throws TJException;
|
throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
private native void encodeYUV(byte[] srcBuf, int x, int y, int width,
|
private native void encodeYUV(byte[] srcBuf, int x, int y, int width,
|
||||||
int pitch, int height, int pixelFormat, byte[][] dstPlanes,
|
int pitch, int height, int pixelFormat, byte[][] dstPlanes,
|
||||||
int[] dstOffsets, int[] dstStrides, int subsamp, int flags)
|
int[] dstOffsets, int[] dstStrides, int subsamp, int flags)
|
||||||
throws TJException;
|
throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private native void encodeYUV(int[] srcBuf, int width, int stride,
|
private native void encodeYUV(int[] srcBuf, int width, int stride,
|
||||||
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
int height, int pixelFormat, byte[] dstBuf, int subsamp, int flags)
|
||||||
throws TJException;
|
throws TJException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
private native void encodeYUV(int[] srcBuf, int x, int y, int width,
|
private native void encodeYUV(int[] srcBuf, int x, int y, int width,
|
||||||
int srcStride, int height, int pixelFormat, byte[][] dstPlanes,
|
int srcStride, int height, int pixelFormat, byte[][] dstPlanes,
|
||||||
int[] dstOffsets, int[] dstStrides, int subsamp, int flags)
|
int[] dstOffsets, int[] dstStrides, int subsamp, int flags)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011-2015 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011-2015, 2018 D. R. Commander. All Rights Reserved.
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -82,6 +82,7 @@ public class TJDecompressor implements Closeable {
|
|||||||
* @param yuvImage {@link YUVImage} instance containing a YUV planar
|
* @param yuvImage {@link YUVImage} instance containing a YUV planar
|
||||||
* image to be decoded. This image is not modified.
|
* image to be decoded. This image is not modified.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
public TJDecompressor(YUVImage yuvImage) throws TJException {
|
public TJDecompressor(YUVImage yuvImage) throws TJException {
|
||||||
init();
|
init();
|
||||||
setSourceImage(yuvImage);
|
setSourceImage(yuvImage);
|
||||||
@@ -109,6 +110,7 @@ public class TJDecompressor implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #setSourceImage(byte[], int)} instead.
|
* @deprecated Use {@link #setSourceImage(byte[], int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setJPEGImage(byte[] jpegImage, int imageSize)
|
public void setJPEGImage(byte[] jpegImage, int imageSize)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
@@ -400,6 +402,7 @@ public class TJDecompressor implements Closeable {
|
|||||||
* @deprecated Use
|
* @deprecated Use
|
||||||
* {@link #decompress(byte[], int, int, int, int, int, int, int)} instead.
|
* {@link #decompress(byte[], int, int, int, int, int, int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void decompress(byte[] dstBuf, int desiredWidth, int pitch,
|
public void decompress(byte[] dstBuf, int desiredWidth, int pitch,
|
||||||
int desiredHeight, int pixelFormat, int flags)
|
int desiredHeight, int pixelFormat, int flags)
|
||||||
@@ -494,11 +497,12 @@ public class TJDecompressor implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #decompressToYUV(YUVImage, int)} instead.
|
* @deprecated Use {@link #decompressToYUV(YUVImage, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void decompressToYUV(byte[] dstBuf, int flags) throws TJException {
|
public void decompressToYUV(byte[] dstBuf, int flags) throws TJException {
|
||||||
YUVImage dstImage = new YUVImage(dstBuf, jpegWidth, 4, jpegHeight,
|
YUVImage dstYUVImage = new YUVImage(dstBuf, jpegWidth, 4, jpegHeight,
|
||||||
jpegSubsamp);
|
jpegSubsamp);
|
||||||
decompressToYUV(dstImage, flags);
|
decompressToYUV(dstYUVImage, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -553,10 +557,10 @@ public class TJDecompressor implements Closeable {
|
|||||||
|
|
||||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||||
YUVImage yuvImage = new YUVImage(scaledWidth, null, scaledHeight,
|
YUVImage dstYUVImage = new YUVImage(scaledWidth, null, scaledHeight,
|
||||||
jpegSubsamp);
|
jpegSubsamp);
|
||||||
decompressToYUV(yuvImage, flags);
|
decompressToYUV(dstYUVImage, flags);
|
||||||
return yuvImage;
|
return dstYUVImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -606,20 +610,21 @@ public class TJDecompressor implements Closeable {
|
|||||||
|
|
||||||
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
int scaledWidth = getScaledWidth(desiredWidth, desiredHeight);
|
||||||
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
int scaledHeight = getScaledHeight(desiredWidth, desiredHeight);
|
||||||
YUVImage yuvImage = new YUVImage(scaledWidth, pad, scaledHeight,
|
YUVImage dstYUVImage = new YUVImage(scaledWidth, pad, scaledHeight,
|
||||||
jpegSubsamp);
|
jpegSubsamp);
|
||||||
decompressToYUV(yuvImage, flags);
|
decompressToYUV(dstYUVImage, flags);
|
||||||
return yuvImage;
|
return dstYUVImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #decompressToYUV(int, int, int, int)} instead.
|
* @deprecated Use {@link #decompressToYUV(int, int, int, int)} instead.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public byte[] decompressToYUV(int flags) throws TJException {
|
public byte[] decompressToYUV(int flags) throws TJException {
|
||||||
YUVImage dstImage = new YUVImage(jpegWidth, 4, jpegHeight, jpegSubsamp);
|
YUVImage dstYUVImage = new YUVImage(jpegWidth, 4, jpegHeight, jpegSubsamp);
|
||||||
decompressToYUV(dstImage, flags);
|
decompressToYUV(dstYUVImage, flags);
|
||||||
return dstImage.getBuf();
|
return dstYUVImage.getBuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -858,6 +863,7 @@ public class TJDecompressor implements Closeable {
|
|||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:DesignForExtension")
|
||||||
@Override
|
@Override
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
* Copyright (C)2017 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2017-2018 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -31,28 +31,34 @@ package org.libjpegturbo.turbojpeg;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocType")
|
||||||
public class TJException extends IOException {
|
public class TJException extends IOException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public TJException() {
|
public TJException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public TJException(String message, Throwable cause) {
|
public TJException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public TJException(String message) {
|
public TJException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public TJException(String message, int code) {
|
public TJException(String message, int code) {
|
||||||
super(message);
|
super(message);
|
||||||
if (errorCode >= 0 && errorCode < TJ.NUMERR)
|
if (errorCode >= 0 && errorCode < TJ.NUMERR)
|
||||||
errorCode = code;
|
errorCode = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
public TJException(Throwable cause) {
|
public TJException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011, 2018 D. R. Commander. All Rights Reserved.
|
||||||
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
* Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,6 +34,13 @@ package org.libjpegturbo.turbojpeg;
|
|||||||
*/
|
*/
|
||||||
public class TJScalingFactor {
|
public class TJScalingFactor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a TurboJPEG scaling factor instance.
|
||||||
|
*
|
||||||
|
* @param num numerator
|
||||||
|
* @param denom denominator
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
public TJScalingFactor(int num, int denom) {
|
public TJScalingFactor(int num, int denom) {
|
||||||
if (num < 1 || denom < 1)
|
if (num < 1 || denom < 1)
|
||||||
throw new IllegalArgumentException("Numerator and denominator must be >= 1");
|
throw new IllegalArgumentException("Numerator and denominator must be >= 1");
|
||||||
@@ -64,6 +71,8 @@ public class TJScalingFactor {
|
|||||||
* performs the integer equivalent of
|
* performs the integer equivalent of
|
||||||
* <code>ceil(dimension * scalingFactor)</code>.
|
* <code>ceil(dimension * scalingFactor)</code>.
|
||||||
*
|
*
|
||||||
|
* @param dimension width or height to multiply by this scaling factor
|
||||||
|
*
|
||||||
* @return the scaled value of <code>dimension</code>.
|
* @return the scaled value of <code>dimension</code>.
|
||||||
*/
|
*/
|
||||||
public int getScaled(int dimension) {
|
public int getScaled(int dimension) {
|
||||||
@@ -74,6 +83,8 @@ public class TJScalingFactor {
|
|||||||
* Returns true or false, depending on whether this instance and
|
* Returns true or false, depending on whether this instance and
|
||||||
* <code>other</code> have the same numerator and denominator.
|
* <code>other</code> have the same numerator and denominator.
|
||||||
*
|
*
|
||||||
|
* @param other the scaling factor against which to compare this one
|
||||||
|
*
|
||||||
* @return true or false, depending on whether this instance and
|
* @return true or false, depending on whether this instance and
|
||||||
* <code>other</code> have the same numerator and denominator.
|
* <code>other</code> have the same numerator and denominator.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C)2011, 2013 D. R. Commander. All Rights Reserved.
|
* Copyright (C)2011, 2013, 2018 D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
@@ -173,6 +173,7 @@ public class TJTransform extends Rectangle {
|
|||||||
* @param cf an instance of an object that implements the {@link
|
* @param cf an instance of an object that implements the {@link
|
||||||
* TJCustomFilter} interface, or null if no custom filter is needed
|
* TJCustomFilter} interface, or null if no custom filter is needed
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
public TJTransform(int x, int y, int w, int h, int op, int options,
|
public TJTransform(int x, int y, int w, int h, int op, int options,
|
||||||
TJCustomFilter cf) {
|
TJCustomFilter cf) {
|
||||||
super(x, y, w, h);
|
super(x, y, w, h);
|
||||||
@@ -197,6 +198,7 @@ public class TJTransform extends Rectangle {
|
|||||||
* @param cf an instance of an object that implements the {@link
|
* @param cf an instance of an object that implements the {@link
|
||||||
* TJCustomFilter} interface, or null if no custom filter is needed
|
* TJCustomFilter} interface, or null if no custom filter is needed
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:HiddenField")
|
||||||
public TJTransform(Rectangle r, int op, int options,
|
public TJTransform(Rectangle r, int op, int options,
|
||||||
TJCustomFilter cf) {
|
TJCustomFilter cf) {
|
||||||
super(r);
|
super(r);
|
||||||
@@ -208,15 +210,18 @@ public class TJTransform extends Rectangle {
|
|||||||
/**
|
/**
|
||||||
* Transform operation (one of <code>OP_*</code>)
|
* Transform operation (one of <code>OP_*</code>)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:VisibilityModifier")
|
||||||
public int op = 0;
|
public int op = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform options (bitwise OR of one or more of <code>OPT_*</code>)
|
* Transform options (bitwise OR of one or more of <code>OPT_*</code>)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:VisibilityModifier")
|
||||||
public int options = 0;
|
public int options = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom filter instance
|
* Custom filter instance
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:VisibilityModifier")
|
||||||
public TJCustomFilter cf = null;
|
public TJCustomFilter cf = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,11 +111,11 @@ public class TJTransformer extends TJDecompressor {
|
|||||||
* which specifies the transform parameters and/or cropping region for the
|
* which specifies the transform parameters and/or cropping region for the
|
||||||
* corresponding transformed output image
|
* corresponding transformed output image
|
||||||
*
|
*
|
||||||
* @return an array of {@link TJDecompressor} instances, each of
|
|
||||||
* which has a transformed JPEG image associated with it.
|
|
||||||
*
|
|
||||||
* @param flags the bitwise OR of one or more of
|
* @param flags the bitwise OR of one or more of
|
||||||
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
|
* {@link TJ#FLAG_BOTTOMUP TJ.FLAG_*}
|
||||||
|
*
|
||||||
|
* @return an array of {@link TJDecompressor} instances, each of
|
||||||
|
* which has a transformed JPEG image associated with it.
|
||||||
*/
|
*/
|
||||||
public TJDecompressor[] transform(TJTransform[] transforms, int flags)
|
public TJDecompressor[] transform(TJTransform[] transforms, int flags)
|
||||||
throws TJException {
|
throws TJException {
|
||||||
|
|||||||
@@ -247,9 +247,11 @@ public class YUVImage {
|
|||||||
if (planes[i] == null || offsets[i] < 0)
|
if (planes[i] == null || offsets[i] < 0)
|
||||||
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
throw new IllegalArgumentException("Invalid argument in YUVImage::setBuf()");
|
||||||
if (strides[i] < 0 && offsets[i] - planeSize + pw < 0)
|
if (strides[i] < 0 && offsets[i] - planeSize + pw < 0)
|
||||||
throw new IllegalArgumentException("Stride for plane " + i + " would cause memory to be accessed below plane boundary");
|
throw new IllegalArgumentException("Stride for plane " + i +
|
||||||
|
" would cause memory to be accessed below plane boundary");
|
||||||
if (planes[i].length < offsets[i] + planeSize)
|
if (planes[i].length < offsets[i] + planeSize)
|
||||||
throw new IllegalArgumentException("Image plane " + i + " is not large enough");
|
throw new IllegalArgumentException("Image plane " + i +
|
||||||
|
" is not large enough");
|
||||||
}
|
}
|
||||||
|
|
||||||
yuvPlanes = planes;
|
yuvPlanes = planes;
|
||||||
@@ -294,9 +296,9 @@ public class YUVImage {
|
|||||||
int[] offsets = new int[nc];
|
int[] offsets = new int[nc];
|
||||||
|
|
||||||
planes[0] = yuvImage;
|
planes[0] = yuvImage;
|
||||||
strides[0] = PAD(TJ.planeWidth(0, width, subsamp), pad);
|
strides[0] = pad(TJ.planeWidth(0, width, subsamp), pad);
|
||||||
if (subsamp != TJ.SAMP_GRAY) {
|
if (subsamp != TJ.SAMP_GRAY) {
|
||||||
strides[1] = strides[2] = PAD(TJ.planeWidth(1, width, subsamp), pad);
|
strides[1] = strides[2] = pad(TJ.planeWidth(1, width, subsamp), pad);
|
||||||
planes[1] = planes[2] = yuvImage;
|
planes[1] = planes[2] = yuvImage;
|
||||||
offsets[1] = offsets[0] +
|
offsets[1] = offsets[0] +
|
||||||
strides[0] * TJ.planeHeight(0, height, subsamp);
|
strides[0] * TJ.planeHeight(0, height, subsamp);
|
||||||
@@ -428,7 +430,7 @@ public class YUVImage {
|
|||||||
return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
|
return TJ.bufSizeYUV(yuvWidth, yuvPad, yuvHeight, yuvSubsamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int PAD(int v, int p) {
|
private static int pad(int v, int p) {
|
||||||
return (v + p - 1) & (~(p - 1));
|
return (v + p - 1) & (~(p - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
jcapimin.c
19
jcapimin.c
@@ -4,10 +4,9 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2010 by Guido Vollbeding.
|
* Modified 2003-2010 by Guido Vollbeding.
|
||||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
* libjpeg-turbo Modifications:
|
||||||
* to libjpeg-turbo.
|
* Copyright (C) 2014, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* This file contains application interface code for the compression half
|
* This file contains application interface code for the compression half
|
||||||
* of the JPEG library. These are the "minimum" API routines that may be
|
* of the JPEG library. These are the "minimum" API routines that may be
|
||||||
@@ -23,6 +22,8 @@
|
|||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
|
#include "jmemsys.h"
|
||||||
|
#include "jcmaster.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -92,6 +93,16 @@ jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
|
|||||||
|
|
||||||
/* OK, I'm ready */
|
/* OK, I'm ready */
|
||||||
cinfo->global_state = CSTATE_START;
|
cinfo->global_state = CSTATE_START;
|
||||||
|
|
||||||
|
/* The master struct is used to store extension parameters, so we allocate it
|
||||||
|
* here. It is later reallocated by jinit_c_master_control().
|
||||||
|
*/
|
||||||
|
cinfo->master = (struct jpeg_comp_master *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
|
sizeof(my_comp_master));
|
||||||
|
MEMZERO(cinfo->master, sizeof(my_comp_master));
|
||||||
|
|
||||||
|
cinfo->master->compress_profile = JCP_MAX_COMPRESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
jcapistd.c
10
jcapistd.c
@@ -3,8 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains application interface code for the compression half
|
* This file contains application interface code for the compression half
|
||||||
* of the JPEG library. These are the "standard" API routines that are
|
* of the JPEG library. These are the "standard" API routines that are
|
||||||
@@ -44,6 +45,11 @@ jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
|
|||||||
if (write_all_tables)
|
if (write_all_tables)
|
||||||
jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
|
jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */
|
||||||
|
|
||||||
|
/* setting up scan optimisation pattern failed, disable scan optimisation */
|
||||||
|
if (cinfo->master->num_scans_luma == 0 || cinfo->scan_info == NULL ||
|
||||||
|
cinfo->num_scans == 0)
|
||||||
|
cinfo->master->optimize_scans = FALSE;
|
||||||
|
|
||||||
/* (Re)initialize error mgr and destination modules */
|
/* (Re)initialize error mgr and destination modules */
|
||||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
||||||
(*cinfo->dest->init_destination) (cinfo);
|
(*cinfo->dest->init_destination) (cinfo);
|
||||||
|
|||||||
81
jcarith.c
81
jcarith.c
@@ -4,22 +4,25 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Developed 1997-2009 by Guido Vollbeding.
|
* Developed 1997-2009 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* This file contains portable arithmetic entropy encoding routines for JPEG
|
* This file contains portable arithmetic entropy encoding routines for JPEG
|
||||||
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
|
* (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
|
||||||
*
|
*
|
||||||
* Both sequential and progressive modes are supported in this single module.
|
* Both sequential and progressive modes are supported in this single module.
|
||||||
*
|
*
|
||||||
* Suspension is not currently supported in this module.
|
* Suspension is not currently supported in this module.
|
||||||
|
*
|
||||||
|
* NOTE: All referenced figures are from
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/* Expanded entropy encoder object for arithmetic encoding. */
|
/* Expanded entropy encoder object for arithmetic encoding. */
|
||||||
|
|
||||||
@@ -63,8 +66,8 @@ typedef arith_entropy_encoder *arith_entropy_ptr;
|
|||||||
* in the lower bits (mask 0x7F).
|
* in the lower bits (mask 0x7F).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DC_STAT_BINS 64
|
#define DC_STAT_BINS 64
|
||||||
#define AC_STAT_BINS 256
|
#define AC_STAT_BINS 256
|
||||||
|
|
||||||
/* NOTE: Uncomment the following #define if you want to use the
|
/* NOTE: Uncomment the following #define if you want to use the
|
||||||
* given formula for calculating the AC conditioning parameter Kx
|
* given formula for calculating the AC conditioning parameter Kx
|
||||||
@@ -106,9 +109,9 @@ typedef arith_entropy_encoder *arith_entropy_ptr;
|
|||||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||||
#define ISHIFT_TEMPS int ishift_temp;
|
#define ISHIFT_TEMPS int ishift_temp;
|
||||||
#define IRIGHT_SHIFT(x, shft) \
|
#define IRIGHT_SHIFT(x, shft) \
|
||||||
((ishift_temp = (x)) < 0 ? \
|
((ishift_temp = (x)) < 0 ? \
|
||||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
||||||
(ishift_temp >> (shft)))
|
(ishift_temp >> (shft)))
|
||||||
#else
|
#else
|
||||||
#define ISHIFT_TEMPS
|
#define ISHIFT_TEMPS
|
||||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
||||||
@@ -121,7 +124,11 @@ emit_byte(int val, j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
struct jpeg_destination_mgr *dest = cinfo->dest;
|
struct jpeg_destination_mgr *dest = cinfo->dest;
|
||||||
|
|
||||||
*dest->next_output_byte++ = (JOCTET)val;
|
/* Do not emit bytes during trellis passes */
|
||||||
|
if (cinfo->master->trellis_passes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*dest->next_output_byte++ = (JOCTET) val;
|
||||||
if (--dest->free_in_buffer == 0)
|
if (--dest->free_in_buffer == 0)
|
||||||
if (!(*dest->empty_output_buffer) (cinfo))
|
if (!(*dest->empty_output_buffer) (cinfo))
|
||||||
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
||||||
@@ -142,13 +149,13 @@ finish_pass(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
/* Find the e->c in the coding interval with the largest
|
/* Find the e->c in the coding interval with the largest
|
||||||
* number of trailing zero bits */
|
* number of trailing zero bits */
|
||||||
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c)
|
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000UL) < e->c)
|
||||||
e->c = temp + 0x8000L;
|
e->c = temp + 0x8000L;
|
||||||
else
|
else
|
||||||
e->c = temp;
|
e->c = temp;
|
||||||
/* Send remaining bytes to output */
|
/* Send remaining bytes to output */
|
||||||
e->c <<= e->ct;
|
e->c <<= e->ct;
|
||||||
if (e->c & 0xF8000000L) {
|
if (e->c & 0xF8000000UL) {
|
||||||
/* One final overflow has to be handled */
|
/* One final overflow has to be handled */
|
||||||
if (e->buffer >= 0) {
|
if (e->buffer >= 0) {
|
||||||
if (e->zc)
|
if (e->zc)
|
||||||
@@ -231,8 +238,8 @@ arith_encode(j_compress_ptr cinfo, unsigned char *st, int val)
|
|||||||
*/
|
*/
|
||||||
sv = *st;
|
sv = *st;
|
||||||
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
|
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
|
||||||
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
|
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
|
||||||
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
|
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
|
||||||
|
|
||||||
/* Encode & estimation procedures per sections D.1.4 & D.1.5 */
|
/* Encode & estimation procedures per sections D.1.4 & D.1.5 */
|
||||||
e->a -= qe;
|
e->a -= qe;
|
||||||
@@ -510,7 +517,7 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||||
}
|
}
|
||||||
st += 2;
|
st += 2;
|
||||||
/* Figure F.8: Encoding the magnitude category of v */
|
/* Figure F.8: Encoding the magnitude category of v */
|
||||||
@@ -662,7 +669,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Encode EOB decision only if k <= cinfo->Se */
|
/* Encode EOB decision only if k <= cinfo->Se */
|
||||||
@@ -770,7 +777,7 @@ encode_mcu(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
st = entropy->ac_stats[tbl] + 3 * (k - 1);
|
||||||
arith_encode(cinfo, st, 0); /* EOB decision */
|
arith_encode(cinfo, st, 0); /* EOB decision */
|
||||||
while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
|
while ((v = (*block)[jpeg_natural_order[k]]) == 0) {
|
||||||
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
arith_encode(cinfo, st + 1, 0); st += 3; k++;
|
||||||
}
|
}
|
||||||
arith_encode(cinfo, st + 1, 1);
|
arith_encode(cinfo, st + 1, 1);
|
||||||
/* Figure F.6: Encoding nonzero value v */
|
/* Figure F.6: Encoding nonzero value v */
|
||||||
@@ -827,6 +834,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy;
|
||||||
int ci, tbl;
|
int ci, tbl;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
|
boolean progressive_mode;
|
||||||
|
|
||||||
if (gather_statistics)
|
if (gather_statistics)
|
||||||
/* Make sure to avoid that in the master control logic!
|
/* Make sure to avoid that in the master control logic!
|
||||||
@@ -837,8 +845,12 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
|
|
||||||
/* We assume jcmaster.c already validated the progressive scan parameters. */
|
/* We assume jcmaster.c already validated the progressive scan parameters. */
|
||||||
|
|
||||||
|
/* Trellis optimization does DC and AC in same pass and without refinement
|
||||||
|
* so consider progressive mode to be off in such case */
|
||||||
|
progressive_mode = (cinfo->master->trellis_passes) ? FALSE : cinfo->progressive_mode;
|
||||||
|
|
||||||
/* Select execution routines */
|
/* Select execution routines */
|
||||||
if (cinfo->progressive_mode) {
|
if (progressive_mode) {
|
||||||
if (cinfo->Ah == 0) {
|
if (cinfo->Ah == 0) {
|
||||||
if (cinfo->Ss == 0)
|
if (cinfo->Ss == 0)
|
||||||
entropy->pub.encode_mcu = encode_mcu_DC_first;
|
entropy->pub.encode_mcu = encode_mcu_DC_first;
|
||||||
@@ -857,7 +869,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
/* DC needs no table for refinement scan */
|
/* DC needs no table for refinement scan */
|
||||||
if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
|
if (progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
|
||||||
tbl = compptr->dc_tbl_no;
|
tbl = compptr->dc_tbl_no;
|
||||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||||
@@ -870,7 +882,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
entropy->dc_context[ci] = 0;
|
entropy->dc_context[ci] = 0;
|
||||||
}
|
}
|
||||||
/* AC needs no table when not present */
|
/* AC needs no table when not present */
|
||||||
if (cinfo->progressive_mode == 0 || cinfo->Se) {
|
if (progressive_mode == 0 || cinfo->Se) {
|
||||||
tbl = compptr->ac_tbl_no;
|
tbl = compptr->ac_tbl_no;
|
||||||
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
|
||||||
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
|
||||||
@@ -879,7 +891,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
|
||||||
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
|
||||||
#ifdef CALCULATE_SPECTRAL_CONDITIONING
|
#ifdef CALCULATE_SPECTRAL_CONDITIONING
|
||||||
if (cinfo->progressive_mode)
|
if (progressive_mode)
|
||||||
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
|
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
|
||||||
cinfo->arith_ac_K[tbl] = cinfo->Ss +
|
cinfo->arith_ac_K[tbl] = cinfo->Ss +
|
||||||
((8 + cinfo->Se - cinfo->Ss) >> 4);
|
((8 + cinfo->Se - cinfo->Ss) >> 4);
|
||||||
@@ -927,3 +939,34 @@ jinit_arith_encoder(j_compress_ptr cinfo)
|
|||||||
/* Initialize index for fixed probability estimation */
|
/* Initialize index for fixed probability estimation */
|
||||||
entropy->fixed_bin[0] = 113;
|
entropy->fixed_bin[0] = 113;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLOBAL(void)
|
||||||
|
jget_arith_rates (j_compress_ptr cinfo, int dc_tbl_no, int ac_tbl_no, arith_rates *r)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
|
||||||
|
|
||||||
|
r->arith_dc_L = cinfo->arith_dc_L[dc_tbl_no];
|
||||||
|
r->arith_dc_U = cinfo->arith_dc_U[dc_tbl_no];
|
||||||
|
r->arith_ac_K = cinfo->arith_ac_K[ac_tbl_no];
|
||||||
|
|
||||||
|
for (i = 0; i < DC_STAT_BINS; i++) {
|
||||||
|
int state = entropy->dc_stats[dc_tbl_no][i];
|
||||||
|
int mps_val = state >> 7;
|
||||||
|
float prob_lps = (jpeg_aritab[state & 0x7f] >> 16) / 46340.95; /* 32768*sqrt(2) */
|
||||||
|
float prob_0 = (mps_val) ? prob_lps : 1.0 - prob_lps;
|
||||||
|
float prob_1 = 1.0 - prob_0;
|
||||||
|
r->rate_dc[i][0] = -log(prob_0) / log(2.0);
|
||||||
|
r->rate_dc[i][1] = -log(prob_1) / log(2.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < AC_STAT_BINS; i++) {
|
||||||
|
int state = entropy->ac_stats[ac_tbl_no][i];
|
||||||
|
int mps_val = state >> 7;
|
||||||
|
float prob_lps = (jpeg_aritab[state & 0x7f] >> 16) / 46340.95;
|
||||||
|
float prob_0 = (mps_val) ? prob_lps : 1.0 - prob_lps;
|
||||||
|
float prob_1 = 1.0 - prob_0;
|
||||||
|
r->rate_ac[i][0] = -log(prob_0) / log(2.0);
|
||||||
|
r->rate_ac[i][1] = -log(prob_1) / log(2.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
186
jccoefct.c
186
jccoefct.c
@@ -5,8 +5,9 @@
|
|||||||
* Copyright (C) 1994-1997, Thomas G. Lane.
|
* Copyright (C) 1994-1997, Thomas G. Lane.
|
||||||
* It was modified by The libjpeg-turbo Project to include only code and
|
* It was modified by The libjpeg-turbo Project to include only code and
|
||||||
* information relevant to libjpeg-turbo.
|
* information relevant to libjpeg-turbo.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains the coefficient buffer controller for compression.
|
* This file contains the coefficient buffer controller for compression.
|
||||||
* This controller is the top level of the JPEG compressor proper.
|
* This controller is the top level of the JPEG compressor proper.
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
|
#include "jchuff.h"
|
||||||
|
|
||||||
/* We use a full-image coefficient buffer when doing Huffman optimization,
|
/* We use a full-image coefficient buffer when doing Huffman optimization,
|
||||||
* and also for writing multiple-scan JPEG files. In all cases, the DCT
|
* and also for writing multiple-scan JPEG files. In all cases, the DCT
|
||||||
@@ -52,6 +53,10 @@ typedef struct {
|
|||||||
|
|
||||||
/* In multi-pass modes, we need a virtual block array for each component. */
|
/* In multi-pass modes, we need a virtual block array for each component. */
|
||||||
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
|
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
|
||||||
|
|
||||||
|
/* when using trellis quantization, need to keep a copy of all unquantized coefficients */
|
||||||
|
jvirt_barray_ptr whole_image_uq[MAX_COMPONENTS];
|
||||||
|
|
||||||
} my_coef_controller;
|
} my_coef_controller;
|
||||||
|
|
||||||
typedef my_coef_controller *my_coef_ptr;
|
typedef my_coef_controller *my_coef_ptr;
|
||||||
@@ -64,6 +69,8 @@ METHODDEF(boolean) compress_first_pass(j_compress_ptr cinfo,
|
|||||||
JSAMPIMAGE input_buf);
|
JSAMPIMAGE input_buf);
|
||||||
METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
METHODDEF(boolean) compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||||
#endif
|
#endif
|
||||||
|
METHODDEF(boolean) compress_trellis_pass
|
||||||
|
(j_compress_ptr cinfo, JSAMPIMAGE input_buf);
|
||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
@@ -120,6 +127,12 @@ start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
|||||||
coef->pub.compress_data = compress_output;
|
coef->pub.compress_data = compress_output;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case JBUF_REQUANT:
|
||||||
|
if (coef->whole_image[0] == NULL)
|
||||||
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
|
coef->pub.compress_data = compress_trellis_pass;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
break;
|
break;
|
||||||
@@ -175,7 +188,8 @@ compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||||
input_buf[compptr->component_index],
|
input_buf[compptr->component_index],
|
||||||
coef->MCU_buffer[blkn],
|
coef->MCU_buffer[blkn],
|
||||||
ypos, xpos, (JDIMENSION)blockcnt);
|
ypos, xpos, (JDIMENSION) blockcnt,
|
||||||
|
NULL);
|
||||||
if (blockcnt < compptr->MCU_width) {
|
if (blockcnt < compptr->MCU_width) {
|
||||||
/* Create some dummy blocks at the right edge of the image. */
|
/* Create some dummy blocks at the right edge of the image. */
|
||||||
jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
|
jzero_far((void *)coef->MCU_buffer[blkn + blockcnt],
|
||||||
@@ -252,6 +266,7 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
JBLOCKARRAY buffer;
|
JBLOCKARRAY buffer;
|
||||||
JBLOCKROW thisblockrow, lastblockrow;
|
JBLOCKROW thisblockrow, lastblockrow;
|
||||||
|
JBLOCKARRAY buffer_dst;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
@@ -259,7 +274,13 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
buffer = (*cinfo->mem->access_virt_barray)
|
buffer = (*cinfo->mem->access_virt_barray)
|
||||||
((j_common_ptr)cinfo, coef->whole_image[ci],
|
((j_common_ptr)cinfo, coef->whole_image[ci],
|
||||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||||
(JDIMENSION)compptr->v_samp_factor, TRUE);
|
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||||
|
|
||||||
|
buffer_dst = (*cinfo->mem->access_virt_barray)
|
||||||
|
((j_common_ptr) cinfo, coef->whole_image_uq[ci],
|
||||||
|
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||||
|
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||||
|
|
||||||
/* Count non-dummy DCT block rows in this iMCU row. */
|
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||||
if (coef->iMCU_row_num < last_iMCU_row)
|
if (coef->iMCU_row_num < last_iMCU_row)
|
||||||
block_rows = compptr->v_samp_factor;
|
block_rows = compptr->v_samp_factor;
|
||||||
@@ -281,8 +302,9 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
thisblockrow = buffer[block_row];
|
thisblockrow = buffer[block_row];
|
||||||
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
(*cinfo->fdct->forward_DCT) (cinfo, compptr,
|
||||||
input_buf[ci], thisblockrow,
|
input_buf[ci], thisblockrow,
|
||||||
(JDIMENSION)(block_row * DCTSIZE),
|
(JDIMENSION) (block_row * DCTSIZE),
|
||||||
(JDIMENSION)0, blocks_across);
|
(JDIMENSION) 0, blocks_across,
|
||||||
|
buffer_dst[block_row]);
|
||||||
if (ndummy > 0) {
|
if (ndummy > 0) {
|
||||||
/* Create dummy blocks at the right edge of the image. */
|
/* Create dummy blocks at the right edge of the image. */
|
||||||
thisblockrow += blocks_across; /* => first dummy block */
|
thisblockrow += blocks_across; /* => first dummy block */
|
||||||
@@ -326,6 +348,136 @@ compress_first_pass(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
return compress_output(cinfo, input_buf);
|
return compress_output(cinfo, input_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHODDEF(boolean)
|
||||||
|
compress_trellis_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||||
|
{
|
||||||
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
|
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||||
|
JDIMENSION blocks_across, MCUs_across, MCUindex;
|
||||||
|
int bi, ci, h_samp_factor, block_row, block_rows, ndummy;
|
||||||
|
JCOEF lastDC;
|
||||||
|
jpeg_component_info *compptr;
|
||||||
|
JBLOCKARRAY buffer;
|
||||||
|
JBLOCKROW thisblockrow, lastblockrow;
|
||||||
|
JBLOCKARRAY buffer_dst;
|
||||||
|
|
||||||
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
|
c_derived_tbl dctbl_data;
|
||||||
|
c_derived_tbl *dctbl = &dctbl_data;
|
||||||
|
c_derived_tbl actbl_data;
|
||||||
|
c_derived_tbl *actbl = &actbl_data;
|
||||||
|
|
||||||
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
|
arith_rates arith_r_data;
|
||||||
|
arith_rates *arith_r = &arith_r_data;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
|
|
||||||
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
|
if (cinfo->arith_code)
|
||||||
|
jget_arith_rates(cinfo, compptr->dc_tbl_no, compptr->ac_tbl_no, arith_r);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
jpeg_make_c_derived_tbl(cinfo, TRUE, compptr->dc_tbl_no, &dctbl);
|
||||||
|
jpeg_make_c_derived_tbl(cinfo, FALSE, compptr->ac_tbl_no, &actbl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Align the virtual buffer for this component. */
|
||||||
|
buffer = (*cinfo->mem->access_virt_barray)
|
||||||
|
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||||
|
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||||
|
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||||
|
|
||||||
|
buffer_dst = (*cinfo->mem->access_virt_barray)
|
||||||
|
((j_common_ptr) cinfo, coef->whole_image_uq[compptr->component_index],
|
||||||
|
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||||
|
(JDIMENSION) compptr->v_samp_factor, TRUE);
|
||||||
|
|
||||||
|
/* Count non-dummy DCT block rows in this iMCU row. */
|
||||||
|
if (coef->iMCU_row_num < last_iMCU_row)
|
||||||
|
block_rows = compptr->v_samp_factor;
|
||||||
|
else {
|
||||||
|
/* NB: can't use last_row_height here, since may not be set! */
|
||||||
|
block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||||
|
if (block_rows == 0) block_rows = compptr->v_samp_factor;
|
||||||
|
}
|
||||||
|
blocks_across = compptr->width_in_blocks;
|
||||||
|
h_samp_factor = compptr->h_samp_factor;
|
||||||
|
/* Count number of dummy blocks to be added at the right margin. */
|
||||||
|
ndummy = (int) (blocks_across % h_samp_factor);
|
||||||
|
if (ndummy > 0)
|
||||||
|
ndummy = h_samp_factor - ndummy;
|
||||||
|
|
||||||
|
lastDC = 0;
|
||||||
|
|
||||||
|
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call
|
||||||
|
* on forward_DCT processes a complete horizontal row of DCT blocks.
|
||||||
|
*/
|
||||||
|
for (block_row = 0; block_row < block_rows; block_row++) {
|
||||||
|
thisblockrow = buffer[block_row];
|
||||||
|
lastblockrow = (block_row > 0) ? buffer[block_row-1] : NULL;
|
||||||
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
|
if (cinfo->arith_code)
|
||||||
|
quantize_trellis_arith(cinfo, arith_r, thisblockrow,
|
||||||
|
buffer_dst[block_row], blocks_across,
|
||||||
|
cinfo->quant_tbl_ptrs[compptr->quant_tbl_no],
|
||||||
|
cinfo->master->norm_src[compptr->quant_tbl_no],
|
||||||
|
cinfo->master->norm_coef[compptr->quant_tbl_no],
|
||||||
|
&lastDC, lastblockrow, buffer_dst[block_row-1]);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
quantize_trellis(cinfo, dctbl, actbl, thisblockrow,
|
||||||
|
buffer_dst[block_row], blocks_across,
|
||||||
|
cinfo->quant_tbl_ptrs[compptr->quant_tbl_no],
|
||||||
|
cinfo->master->norm_src[compptr->quant_tbl_no],
|
||||||
|
cinfo->master->norm_coef[compptr->quant_tbl_no],
|
||||||
|
&lastDC, lastblockrow, buffer_dst[block_row-1]);
|
||||||
|
|
||||||
|
if (ndummy > 0) {
|
||||||
|
/* Create dummy blocks at the right edge of the image. */
|
||||||
|
thisblockrow += blocks_across; /* => first dummy block */
|
||||||
|
jzero_far((void *) thisblockrow, ndummy * sizeof(JBLOCK));
|
||||||
|
lastDC = thisblockrow[-1][0];
|
||||||
|
for (bi = 0; bi < ndummy; bi++) {
|
||||||
|
thisblockrow[bi][0] = lastDC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* If at end of image, create dummy block rows as needed.
|
||||||
|
* The tricky part here is that within each MCU, we want the DC values
|
||||||
|
* of the dummy blocks to match the last real block's DC value.
|
||||||
|
* This squeezes a few more bytes out of the resulting file...
|
||||||
|
*/
|
||||||
|
if (coef->iMCU_row_num == last_iMCU_row) {
|
||||||
|
blocks_across += ndummy; /* include lower right corner */
|
||||||
|
MCUs_across = blocks_across / h_samp_factor;
|
||||||
|
for (block_row = block_rows; block_row < compptr->v_samp_factor;
|
||||||
|
block_row++) {
|
||||||
|
thisblockrow = buffer[block_row];
|
||||||
|
lastblockrow = buffer[block_row-1];
|
||||||
|
jzero_far((void *) thisblockrow,
|
||||||
|
(size_t) (blocks_across * sizeof(JBLOCK)));
|
||||||
|
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
|
||||||
|
lastDC = lastblockrow[h_samp_factor-1][0];
|
||||||
|
for (bi = 0; bi < h_samp_factor; bi++) {
|
||||||
|
thisblockrow[bi][0] = lastDC;
|
||||||
|
}
|
||||||
|
thisblockrow += h_samp_factor; /* advance to next MCU in row */
|
||||||
|
lastblockrow += h_samp_factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NB: compress_output will increment iMCU_row_num if successful.
|
||||||
|
* A suspension return will result in redoing all the work above next time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Emit data to the entropy encoder, sharing code with subsequent passes */
|
||||||
|
return compress_output(cinfo, input_buf);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process some data in subsequent passes of a multi-pass case.
|
* Process some data in subsequent passes of a multi-pass case.
|
||||||
@@ -423,12 +575,20 @@ jinit_c_coef_controller(j_compress_ptr cinfo, boolean need_full_buffer)
|
|||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
|
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||||
(JDIMENSION)jround_up((long)compptr->width_in_blocks,
|
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||||
(long)compptr->h_samp_factor),
|
(long) compptr->h_samp_factor),
|
||||||
(JDIMENSION)jround_up((long)compptr->height_in_blocks,
|
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||||
(long)compptr->v_samp_factor),
|
(long) compptr->v_samp_factor),
|
||||||
(JDIMENSION)compptr->v_samp_factor);
|
(JDIMENSION) compptr->v_samp_factor);
|
||||||
|
|
||||||
|
coef->whole_image_uq[ci] = (*cinfo->mem->request_virt_barray)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
||||||
|
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
|
||||||
|
(long) compptr->h_samp_factor),
|
||||||
|
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
||||||
|
(long) compptr->v_samp_factor),
|
||||||
|
(JDIMENSION) compptr->v_samp_factor);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
|
|||||||
1172
jcdctmgr.c
1172
jcdctmgr.c
File diff suppressed because it is too large
Load Diff
219
jcext.c
Normal file
219
jcext.c
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
/*
|
||||||
|
* jcext.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014, D. R. Commander.
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
|
*
|
||||||
|
* This file contains accessor functions for extension parameters. These
|
||||||
|
* allow for extending the functionality of the libjpeg API without breaking
|
||||||
|
* backward ABI compatibility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define JPEG_INTERNALS
|
||||||
|
#include "jinclude.h"
|
||||||
|
#include "jpeglib.h"
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(boolean)
|
||||||
|
jpeg_c_bool_param_supported (const j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JBOOLEAN_OPTIMIZE_SCANS:
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT:
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT_DC:
|
||||||
|
case JBOOLEAN_TRELLIS_EOB_OPT:
|
||||||
|
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
|
||||||
|
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
|
||||||
|
case JBOOLEAN_TRELLIS_Q_OPT:
|
||||||
|
case JBOOLEAN_OVERSHOOT_DERINGING:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(void)
|
||||||
|
jpeg_c_set_bool_param (j_compress_ptr cinfo, J_BOOLEAN_PARAM param,
|
||||||
|
boolean value)
|
||||||
|
{
|
||||||
|
switch(param) {
|
||||||
|
case JBOOLEAN_OPTIMIZE_SCANS:
|
||||||
|
cinfo->master->optimize_scans = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT:
|
||||||
|
cinfo->master->trellis_quant = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT_DC:
|
||||||
|
cinfo->master->trellis_quant_dc = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_TRELLIS_EOB_OPT:
|
||||||
|
cinfo->master->trellis_eob_opt = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
|
||||||
|
cinfo->master->use_lambda_weight_tbl = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
|
||||||
|
cinfo->master->use_scans_in_trellis = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_TRELLIS_Q_OPT:
|
||||||
|
cinfo->master->trellis_q_opt = value;
|
||||||
|
break;
|
||||||
|
case JBOOLEAN_OVERSHOOT_DERINGING:
|
||||||
|
cinfo->master->overshoot_deringing = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(boolean)
|
||||||
|
jpeg_c_get_bool_param (const j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
|
||||||
|
{
|
||||||
|
switch(param) {
|
||||||
|
case JBOOLEAN_OPTIMIZE_SCANS:
|
||||||
|
return cinfo->master->optimize_scans;
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT:
|
||||||
|
return cinfo->master->trellis_quant;
|
||||||
|
case JBOOLEAN_TRELLIS_QUANT_DC:
|
||||||
|
return cinfo->master->trellis_quant_dc;
|
||||||
|
case JBOOLEAN_TRELLIS_EOB_OPT:
|
||||||
|
return cinfo->master->trellis_eob_opt;
|
||||||
|
case JBOOLEAN_USE_LAMBDA_WEIGHT_TBL:
|
||||||
|
return cinfo->master->use_lambda_weight_tbl;
|
||||||
|
case JBOOLEAN_USE_SCANS_IN_TRELLIS:
|
||||||
|
return cinfo->master->use_scans_in_trellis;
|
||||||
|
case JBOOLEAN_TRELLIS_Q_OPT:
|
||||||
|
return cinfo->master->trellis_q_opt;
|
||||||
|
case JBOOLEAN_OVERSHOOT_DERINGING:
|
||||||
|
return cinfo->master->overshoot_deringing;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(boolean)
|
||||||
|
jpeg_c_float_param_supported (const j_compress_ptr cinfo, J_FLOAT_PARAM param)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE1:
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE2:
|
||||||
|
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(void)
|
||||||
|
jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param, float value)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE1:
|
||||||
|
cinfo->master->lambda_log_scale1 = value;
|
||||||
|
break;
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE2:
|
||||||
|
cinfo->master->lambda_log_scale2 = value;
|
||||||
|
break;
|
||||||
|
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
|
||||||
|
cinfo->master->trellis_delta_dc_weight = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(float)
|
||||||
|
jpeg_c_get_float_param (const j_compress_ptr cinfo, J_FLOAT_PARAM param)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE1:
|
||||||
|
return cinfo->master->lambda_log_scale1;
|
||||||
|
case JFLOAT_LAMBDA_LOG_SCALE2:
|
||||||
|
return cinfo->master->lambda_log_scale2;
|
||||||
|
case JFLOAT_TRELLIS_DELTA_DC_WEIGHT:
|
||||||
|
return cinfo->master->trellis_delta_dc_weight;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(boolean)
|
||||||
|
jpeg_c_int_param_supported (const j_compress_ptr cinfo, J_INT_PARAM param)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JINT_COMPRESS_PROFILE:
|
||||||
|
case JINT_TRELLIS_FREQ_SPLIT:
|
||||||
|
case JINT_TRELLIS_NUM_LOOPS:
|
||||||
|
case JINT_BASE_QUANT_TBL_IDX:
|
||||||
|
case JINT_DC_SCAN_OPT_MODE:
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(void)
|
||||||
|
jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param, int value)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JINT_COMPRESS_PROFILE:
|
||||||
|
switch (value) {
|
||||||
|
case JCP_MAX_COMPRESSION:
|
||||||
|
case JCP_FASTEST:
|
||||||
|
cinfo->master->compress_profile = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM_VALUE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case JINT_TRELLIS_FREQ_SPLIT:
|
||||||
|
cinfo->master->trellis_freq_split = value;
|
||||||
|
break;
|
||||||
|
case JINT_TRELLIS_NUM_LOOPS:
|
||||||
|
cinfo->master->trellis_num_loops = value;
|
||||||
|
break;
|
||||||
|
case JINT_BASE_QUANT_TBL_IDX:
|
||||||
|
if (value >= 0 && value <= 8)
|
||||||
|
cinfo->master->quant_tbl_master_idx = value;
|
||||||
|
break;
|
||||||
|
case JINT_DC_SCAN_OPT_MODE:
|
||||||
|
cinfo->master->dc_scan_opt_mode = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(int)
|
||||||
|
jpeg_c_get_int_param (const j_compress_ptr cinfo, J_INT_PARAM param)
|
||||||
|
{
|
||||||
|
switch (param) {
|
||||||
|
case JINT_COMPRESS_PROFILE:
|
||||||
|
return cinfo->master->compress_profile;
|
||||||
|
case JINT_TRELLIS_FREQ_SPLIT:
|
||||||
|
return cinfo->master->trellis_freq_split;
|
||||||
|
case JINT_TRELLIS_NUM_LOOPS:
|
||||||
|
return cinfo->master->trellis_num_loops;
|
||||||
|
case JINT_BASE_QUANT_TBL_IDX:
|
||||||
|
return cinfo->master->quant_tbl_master_idx;
|
||||||
|
case JINT_DC_SCAN_OPT_MODE:
|
||||||
|
return cinfo->master->dc_scan_opt_mode;
|
||||||
|
default:
|
||||||
|
ERREXIT(cinfo, JERR_BAD_PARAM);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
47
jchuff.c
47
jchuff.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, 2014-2016, D. R. Commander.
|
* Copyright (C) 2009-2011, 2014-2016, 2018-2019, D. R. Commander.
|
||||||
* Copyright (C) 2015, Matthieu Darbois.
|
* Copyright (C) 2015, Matthieu Darbois.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
@@ -16,6 +16,9 @@
|
|||||||
* back up to the start of the current MCU. To do this, we copy state
|
* back up to the start of the current MCU. To do this, we copy state
|
||||||
* variables into local working storage, and update them back to the
|
* variables into local working storage, and update them back to the
|
||||||
* permanent JPEG objects only upon successful completion of an MCU.
|
* permanent JPEG objects only upon successful completion of an MCU.
|
||||||
|
*
|
||||||
|
* NOTE: All referenced figures are from
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
@@ -40,8 +43,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTE: Both GCC and Clang define __GNUC__ */
|
/* NOTE: Both GCC and Clang define __GNUC__ */
|
||||||
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
#if defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
|
||||||
#if !defined __thumb__ || defined __thumb2__
|
#if !defined(__thumb__) || defined(__thumb2__)
|
||||||
#define USE_CLZ_INTRINSIC
|
#define USE_CLZ_INTRINSIC
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -353,6 +356,8 @@ dump_buffer(working_state *state)
|
|||||||
put_buffer = (put_buffer << size) | code; \
|
put_buffer = (put_buffer << size) | code; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SIZEOF_SIZE_T != 8 && !defined(_WIN64)
|
||||||
|
|
||||||
#define CHECKBUF15() { \
|
#define CHECKBUF15() { \
|
||||||
if (put_bits > 15) { \
|
if (put_bits > 15) { \
|
||||||
EMIT_BYTE() \
|
EMIT_BYTE() \
|
||||||
@@ -360,6 +365,8 @@ dump_buffer(working_state *state)
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CHECKBUF31() { \
|
#define CHECKBUF31() { \
|
||||||
if (put_bits > 31) { \
|
if (put_bits > 31) { \
|
||||||
EMIT_BYTE() \
|
EMIT_BYTE() \
|
||||||
@@ -425,7 +432,7 @@ dump_buffer(working_state *state)
|
|||||||
* scanning order-- 1, 8, 16, etc.), then this will produce an encoded block
|
* scanning order-- 1, 8, 16, etc.), then this will produce an encoded block
|
||||||
* larger than 200 bytes.
|
* larger than 200 bytes.
|
||||||
*/
|
*/
|
||||||
#define BUFSIZE (DCTSIZE2 * 4)
|
#define BUFSIZE (DCTSIZE2 * 8)
|
||||||
|
|
||||||
#define LOAD_BUFFER() { \
|
#define LOAD_BUFFER() { \
|
||||||
if (state->free_in_buffer < BUFSIZE) { \
|
if (state->free_in_buffer < BUFSIZE) { \
|
||||||
@@ -859,13 +866,14 @@ encode_mcu_gather(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
* one bits (so that padding bits added at the end of a compressed segment
|
* one bits (so that padding bits added at the end of a compressed segment
|
||||||
* can't look like a valid code). Because of the canonical ordering of
|
* can't look like a valid code). Because of the canonical ordering of
|
||||||
* codewords, this just means that there must be an unused slot in the
|
* codewords, this just means that there must be an unused slot in the
|
||||||
* longest codeword length category. Section K.2 of the JPEG spec suggests
|
* longest codeword length category. Annex K (Clause K.2) of
|
||||||
* reserving such a slot by pretending that symbol 256 is a valid symbol
|
* Rec. ITU-T T.81 (1992) | ISO/IEC 10918-1:1994 suggests reserving such a slot
|
||||||
* with count 1. In theory that's not optimal; giving it count zero but
|
* by pretending that symbol 256 is a valid symbol with count 1. In theory
|
||||||
* including it in the symbol set anyway should give a better Huffman code.
|
* that's not optimal; giving it count zero but including it in the symbol set
|
||||||
* But the theoretically better code actually seems to come out worse in
|
* anyway should give a better Huffman code. But the theoretically better code
|
||||||
* practice, because it produces more all-ones bytes (which incur stuffed
|
* actually seems to come out worse in practice, because it produces more
|
||||||
* zero bytes in the final file). In any case the difference is tiny.
|
* all-ones bytes (which incur stuffed zero bytes in the final file). In any
|
||||||
|
* case the difference is tiny.
|
||||||
*
|
*
|
||||||
* The JPEG standard requires Huffman codes to be no more than 16 bits long.
|
* The JPEG standard requires Huffman codes to be no more than 16 bits long.
|
||||||
* If some symbols have a very small but nonzero probability, the Huffman tree
|
* If some symbols have a very small but nonzero probability, the Huffman tree
|
||||||
@@ -967,13 +975,13 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
|||||||
|
|
||||||
/* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
|
/* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
|
||||||
* Huffman procedure assigned any such lengths, we must adjust the coding.
|
* Huffman procedure assigned any such lengths, we must adjust the coding.
|
||||||
* Here is what the JPEG spec says about how this next bit works:
|
* Here is what Rec. ITU-T T.81 | ISO/IEC 10918-1 says about how this next
|
||||||
* Since symbols are paired for the longest Huffman code, the symbols are
|
* bit works: Since symbols are paired for the longest Huffman code, the
|
||||||
* removed from this length category two at a time. The prefix for the pair
|
* symbols are removed from this length category two at a time. The prefix
|
||||||
* (which is one bit shorter) is allocated to one of the pair; then,
|
* for the pair (which is one bit shorter) is allocated to one of the pair;
|
||||||
* skipping the BITS entry for that prefix length, a code word from the next
|
* then, skipping the BITS entry for that prefix length, a code word from the
|
||||||
* shortest nonzero BITS entry is converted into a prefix for two code words
|
* next shortest nonzero BITS entry is converted into a prefix for two code
|
||||||
* one bit longer.
|
* words one bit longer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = MAX_CLEN; i > 16; i--) {
|
for (i = MAX_CLEN; i > 16; i--) {
|
||||||
@@ -999,7 +1007,8 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
|
|||||||
|
|
||||||
/* Return a list of the symbols sorted by code length */
|
/* Return a list of the symbols sorted by code length */
|
||||||
/* It's not real clear to me why we don't need to consider the codelength
|
/* It's not real clear to me why we don't need to consider the codelength
|
||||||
* changes made above, but the JPEG spec seems to think this works.
|
* changes made above, but Rec. ITU-T T.81 | ISO/IEC 10918-1 seems to think
|
||||||
|
* this works.
|
||||||
*/
|
*/
|
||||||
p = 0;
|
p = 0;
|
||||||
for (i = 1; i <= MAX_CLEN; i++) {
|
for (i = 1; i <= MAX_CLEN; i++) {
|
||||||
|
|||||||
18
jchuff.h
18
jchuff.h
@@ -5,8 +5,9 @@
|
|||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||||
* to libjpeg-turbo.
|
* to libjpeg-turbo.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains declarations for Huffman entropy encoding routines
|
* This file contains declarations for Huffman entropy encoding routines
|
||||||
* that are shared between the sequential encoder (jchuff.c) and the
|
* that are shared between the sequential encoder (jchuff.c) and the
|
||||||
@@ -20,9 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if BITS_IN_JSAMPLE == 8
|
#if BITS_IN_JSAMPLE == 8
|
||||||
#define MAX_COEF_BITS 10
|
#define MAX_COEF_BITS 10
|
||||||
#else
|
#else
|
||||||
#define MAX_COEF_BITS 14
|
#define MAX_COEF_BITS 14
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Derived data constructed for each Huffman table */
|
/* Derived data constructed for each Huffman table */
|
||||||
@@ -38,5 +39,10 @@ EXTERN(void) jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC,
|
|||||||
int tblno, c_derived_tbl **pdtbl);
|
int tblno, c_derived_tbl **pdtbl);
|
||||||
|
|
||||||
/* Generate an optimal table definition given the specified counts */
|
/* Generate an optimal table definition given the specified counts */
|
||||||
EXTERN(void) jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl,
|
EXTERN(void) jpeg_gen_optimal_table
|
||||||
long freq[]);
|
(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[]);
|
||||||
|
|
||||||
|
EXTERN(void) quantize_trellis
|
||||||
|
(j_compress_ptr cinfo, c_derived_tbl *dctbl, c_derived_tbl *actbl, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
|
||||||
|
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef, JCOEF *last_dc_val,
|
||||||
|
JBLOCKROW coef_blocks_above, JBLOCKROW src_above);
|
||||||
|
|||||||
16
jcinit.c
16
jcinit.c
@@ -3,8 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* This file is part of the Independent JPEG Group's software.
|
* This file is part of the Independent JPEG Group's software.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains initialization logic for the JPEG compressor.
|
* This file contains initialization logic for the JPEG compressor.
|
||||||
* This routine is in charge of selecting the modules to be executed and
|
* This routine is in charge of selecting the modules to be executed and
|
||||||
@@ -28,13 +29,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jinit_compress_master(j_compress_ptr cinfo)
|
jinit_compress_master (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
/* Initialize master control (includes parameter checking/processing) */
|
/* Initialize master control (includes parameter checking/processing) */
|
||||||
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
||||||
|
|
||||||
/* Preprocessing */
|
/* Preprocessing */
|
||||||
if (!cinfo->raw_data_in) {
|
if (! cinfo->raw_data_in) {
|
||||||
jinit_color_converter(cinfo);
|
jinit_color_converter(cinfo);
|
||||||
jinit_downsampler(cinfo);
|
jinit_downsampler(cinfo);
|
||||||
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
|
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
|
||||||
@@ -60,14 +61,15 @@ jinit_compress_master(j_compress_ptr cinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
||||||
jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 ||
|
jinit_c_coef_controller(cinfo,
|
||||||
cinfo->optimize_coding));
|
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding ||
|
||||||
|
cinfo->master->optimize_scans || cinfo->master->trellis_quant));
|
||||||
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
|
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
|
||||||
|
|
||||||
jinit_marker_writer(cinfo);
|
jinit_marker_writer(cinfo);
|
||||||
|
|
||||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||||
|
|
||||||
/* Write the datastream header (SOI) immediately.
|
/* Write the datastream header (SOI) immediately.
|
||||||
* Frame and scan headers are postponed till later.
|
* Frame and scan headers are postponed till later.
|
||||||
|
|||||||
180
jcmarker.c
180
jcmarker.c
@@ -184,6 +184,72 @@ emit_dqt(j_compress_ptr cinfo, int index)
|
|||||||
return prec;
|
return prec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL(int)
|
||||||
|
emit_multi_dqt (j_compress_ptr cinfo)
|
||||||
|
/* Emits a DQT marker containing all quantization tables */
|
||||||
|
/* Returns number of emitted 16-bit tables, or -1 for failed for baseline checking. */
|
||||||
|
{
|
||||||
|
int prec[MAX_COMPONENTS];
|
||||||
|
int seen[MAX_COMPONENTS] = { 0 };
|
||||||
|
int fin_prec = 0;
|
||||||
|
int ci;
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
if (cinfo->master->compress_profile == JCP_FASTEST)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
|
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
|
||||||
|
int i;
|
||||||
|
JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[tbl_num];
|
||||||
|
|
||||||
|
if (qtbl == NULL || qtbl->sent_table == TRUE)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
prec[ci] = 0;
|
||||||
|
for (i = 0; i < DCTSIZE2; i++)
|
||||||
|
prec[ci] = !!(prec[ci] + (qtbl->quantval[i] > 255));
|
||||||
|
|
||||||
|
fin_prec += prec[ci];
|
||||||
|
}
|
||||||
|
|
||||||
|
emit_marker(cinfo, M_DQT);
|
||||||
|
|
||||||
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
|
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
|
||||||
|
|
||||||
|
if (!seen[tbl_num]) {
|
||||||
|
size += DCTSIZE2 * (prec[ci] + 1) + 1;
|
||||||
|
seen[tbl_num] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size += 2;
|
||||||
|
|
||||||
|
emit_2bytes(cinfo, size);
|
||||||
|
|
||||||
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
|
int tbl_num = cinfo->comp_info[ci].quant_tbl_no;
|
||||||
|
int i;
|
||||||
|
JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[tbl_num];
|
||||||
|
|
||||||
|
if (qtbl->sent_table == TRUE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
emit_byte(cinfo, tbl_num + (prec[ci] << 4));
|
||||||
|
|
||||||
|
for (i = 0; i < DCTSIZE2; i++) {
|
||||||
|
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
||||||
|
|
||||||
|
if (prec[ci])
|
||||||
|
emit_byte(cinfo, (int) (qval >> 8));
|
||||||
|
emit_byte(cinfo, (int) (qval & 0xFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
qtbl->sent_table = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fin_prec;
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
|
emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
|
||||||
@@ -222,6 +288,115 @@ emit_dht(j_compress_ptr cinfo, int index, boolean is_ac)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOCAL(boolean)
|
||||||
|
emit_multi_dht (j_compress_ptr cinfo)
|
||||||
|
/* Emit all DHT markers */
|
||||||
|
/* Returns FALSE on failure, TRUE otherwise. */
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
int length = 2;
|
||||||
|
int dclens[NUM_HUFF_TBLS] = { 0 };
|
||||||
|
int aclens[NUM_HUFF_TBLS] = { 0 };
|
||||||
|
JHUFF_TBL *dcseen[NUM_HUFF_TBLS] = { NULL };
|
||||||
|
JHUFF_TBL *acseen[NUM_HUFF_TBLS] = { NULL };
|
||||||
|
|
||||||
|
if (cinfo->master->compress_profile == JCP_FASTEST)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Calclate the total length. */
|
||||||
|
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
||||||
|
jpeg_component_info *compptr = cinfo->cur_comp_info[i];
|
||||||
|
int dcidx = compptr->dc_tbl_no;
|
||||||
|
int acidx = compptr->ac_tbl_no;
|
||||||
|
JHUFF_TBL *dctbl = cinfo->dc_huff_tbl_ptrs[dcidx];
|
||||||
|
JHUFF_TBL *actbl = cinfo->ac_huff_tbl_ptrs[acidx];
|
||||||
|
int seen = 0;
|
||||||
|
|
||||||
|
/* Handle DC table lenghts */
|
||||||
|
if (cinfo->Ss == 0 && cinfo->Ah == 0) {
|
||||||
|
if (dctbl == NULL)
|
||||||
|
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dcidx);
|
||||||
|
|
||||||
|
if (dctbl->sent_table)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (j = 0; j < NUM_HUFF_TBLS; j++)
|
||||||
|
seen += (dctbl == dcseen[j]);
|
||||||
|
if (seen)
|
||||||
|
continue;
|
||||||
|
dcseen[i] = dctbl;
|
||||||
|
|
||||||
|
for (j = 1; j <= 16; j++)
|
||||||
|
dclens[i] += dctbl->bits[j];
|
||||||
|
length += dclens[i] + 16 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle AC table lengths */
|
||||||
|
if (cinfo->Se) {
|
||||||
|
if (actbl == NULL)
|
||||||
|
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, acidx + 0x10);
|
||||||
|
|
||||||
|
if (actbl->sent_table)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
seen = 0;
|
||||||
|
for (j = 0; j < NUM_HUFF_TBLS; j++)
|
||||||
|
seen += (actbl == acseen[j]);
|
||||||
|
if (seen)
|
||||||
|
continue;
|
||||||
|
acseen[i] = actbl;
|
||||||
|
|
||||||
|
for (j = 1; j <= 16; j++)
|
||||||
|
aclens[i] += actbl->bits[j];
|
||||||
|
length += aclens[i] + 16 + 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure we can fit it all into one DHT marker */
|
||||||
|
if (length > (1 << 16) - 1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
emit_marker(cinfo, M_DHT);
|
||||||
|
emit_2bytes(cinfo, length);
|
||||||
|
|
||||||
|
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
||||||
|
jpeg_component_info *compptr = cinfo->cur_comp_info[i];
|
||||||
|
int dcidx = compptr->dc_tbl_no;
|
||||||
|
int acidx = compptr->ac_tbl_no;
|
||||||
|
JHUFF_TBL *dctbl = cinfo->dc_huff_tbl_ptrs[dcidx];
|
||||||
|
JHUFF_TBL *actbl = cinfo->ac_huff_tbl_ptrs[acidx];
|
||||||
|
|
||||||
|
acidx += 0x10;
|
||||||
|
|
||||||
|
/* DC */
|
||||||
|
if (cinfo->Ss == 0 && cinfo->Ah == 0 && !dctbl->sent_table) {
|
||||||
|
emit_byte(cinfo, dcidx);
|
||||||
|
|
||||||
|
for (j = 1; j <= 16; j++)
|
||||||
|
emit_byte(cinfo, dctbl->bits[j]);
|
||||||
|
|
||||||
|
for (j = 0; j < dclens[i]; j++)
|
||||||
|
emit_byte(cinfo, dctbl->huffval[j]);
|
||||||
|
|
||||||
|
dctbl->sent_table = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cinfo->Se && !actbl->sent_table) {
|
||||||
|
emit_byte(cinfo, acidx);
|
||||||
|
|
||||||
|
for (j = 1; j <= 16; j++)
|
||||||
|
emit_byte(cinfo, actbl->bits[j]);
|
||||||
|
|
||||||
|
for (j = 0; j < aclens[i]; j++)
|
||||||
|
emit_byte(cinfo, actbl->huffval[j]);
|
||||||
|
|
||||||
|
actbl->sent_table = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_dac(j_compress_ptr cinfo)
|
emit_dac(j_compress_ptr cinfo)
|
||||||
@@ -504,11 +679,14 @@ write_frame_header(j_compress_ptr cinfo)
|
|||||||
/* Emit DQT for each quantization table.
|
/* Emit DQT for each quantization table.
|
||||||
* Note that emit_dqt() suppresses any duplicate tables.
|
* Note that emit_dqt() suppresses any duplicate tables.
|
||||||
*/
|
*/
|
||||||
|
prec = emit_multi_dqt(cinfo);
|
||||||
|
if (prec == -1) {
|
||||||
prec = 0;
|
prec = 0;
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
prec += emit_dqt(cinfo, compptr->quant_tbl_no);
|
prec += emit_dqt(cinfo, compptr->quant_tbl_no);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* now prec is nonzero iff there are any 16-bit quant tables. */
|
/* now prec is nonzero iff there are any 16-bit quant tables. */
|
||||||
|
|
||||||
/* Check for a non-baseline specification.
|
/* Check for a non-baseline specification.
|
||||||
@@ -571,6 +749,7 @@ write_scan_header(j_compress_ptr cinfo)
|
|||||||
/* Emit Huffman tables.
|
/* Emit Huffman tables.
|
||||||
* Note that emit_dht() suppresses any duplicate tables.
|
* Note that emit_dht() suppresses any duplicate tables.
|
||||||
*/
|
*/
|
||||||
|
if (!emit_multi_dht(cinfo)) {
|
||||||
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
||||||
compptr = cinfo->cur_comp_info[i];
|
compptr = cinfo->cur_comp_info[i];
|
||||||
/* DC needs no table for refinement scan */
|
/* DC needs no table for refinement scan */
|
||||||
@@ -581,6 +760,7 @@ write_scan_header(j_compress_ptr cinfo)
|
|||||||
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
|
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Emit DRI if required --- note that DRI value could change for each scan.
|
/* Emit DRI if required --- note that DRI value could change for each scan.
|
||||||
* We avoid wasting space with unnecessary DRIs, however.
|
* We avoid wasting space with unnecessary DRIs, however.
|
||||||
|
|||||||
518
jcmaster.c
518
jcmaster.c
@@ -5,9 +5,10 @@
|
|||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2003-2010 by Guido Vollbeding.
|
* Modified 2003-2010 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2016, D. R. Commander.
|
* Copyright (C) 2010, 2016, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains master control logic for the JPEG compressor.
|
* This file contains master control logic for the JPEG compressor.
|
||||||
* These routines are concerned with parameter validation, initial setup,
|
* These routines are concerned with parameter validation, initial setup,
|
||||||
@@ -20,41 +21,11 @@
|
|||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jpegcomp.h"
|
#include "jpegcomp.h"
|
||||||
#include "jconfigint.h"
|
#include "jconfigint.h"
|
||||||
|
#include "jmemsys.h"
|
||||||
|
#include "jcmaster.h"
|
||||||
|
|
||||||
|
|
||||||
/* Private state */
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
main_pass, /* input data, also do first output step */
|
|
||||||
huff_opt_pass, /* Huffman code optimization pass */
|
|
||||||
output_pass /* data output pass */
|
|
||||||
} c_pass_type;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct jpeg_comp_master pub; /* public fields */
|
|
||||||
|
|
||||||
c_pass_type pass_type; /* the type of the current pass */
|
|
||||||
|
|
||||||
int pass_number; /* # of passes completed */
|
|
||||||
int total_passes; /* total # of passes needed */
|
|
||||||
|
|
||||||
int scan_number; /* current index in scan_info[] */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is here so we can add libjpeg-turbo version/build information to the
|
|
||||||
* global string table without introducing a new global symbol. Adding this
|
|
||||||
* information to the global string table allows one to examine a binary
|
|
||||||
* object and determine which version of libjpeg-turbo it was built from or
|
|
||||||
* linked against.
|
|
||||||
*/
|
|
||||||
const char *jpeg_version;
|
|
||||||
|
|
||||||
} my_comp_master;
|
|
||||||
|
|
||||||
typedef my_comp_master *my_master_ptr;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Support routines that do various essential calculations.
|
* Support routines that do various essential calculations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -66,7 +37,7 @@ typedef my_comp_master *my_master_ptr;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
|
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
|
||||||
/* Do computations that are needed before master selection phase */
|
/* Do computations that are needed before master selection phase */
|
||||||
{
|
{
|
||||||
/* Hardwire it to "no scaling" */
|
/* Hardwire it to "no scaling" */
|
||||||
@@ -79,7 +50,7 @@ jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
initial_setup (j_compress_ptr cinfo, boolean transcode_only)
|
||||||
/* Do computations that are needed before master selection phase */
|
/* Do computations that are needed before master selection phase */
|
||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
@@ -100,14 +71,14 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
|
||||||
|
|
||||||
/* Make sure image isn't bigger than I can handle */
|
/* Make sure image isn't bigger than I can handle */
|
||||||
if ((long)cinfo->_jpeg_height > (long)JPEG_MAX_DIMENSION ||
|
if ((long) cinfo->_jpeg_height > (long) JPEG_MAX_DIMENSION ||
|
||||||
(long)cinfo->_jpeg_width > (long)JPEG_MAX_DIMENSION)
|
(long) cinfo->_jpeg_width > (long) JPEG_MAX_DIMENSION)
|
||||||
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int)JPEG_MAX_DIMENSION);
|
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
|
||||||
|
|
||||||
/* Width of an input scanline must be representable as JDIMENSION. */
|
/* Width of an input scanline must be representable as JDIMENSION. */
|
||||||
samplesperrow = (long)cinfo->image_width * (long)cinfo->input_components;
|
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
|
||||||
jd_samplesperrow = (JDIMENSION)samplesperrow;
|
jd_samplesperrow = (JDIMENSION) samplesperrow;
|
||||||
if ((long)jd_samplesperrow != samplesperrow)
|
if ((long) jd_samplesperrow != samplesperrow)
|
||||||
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||||
|
|
||||||
/* For now, precision must match compiled-in value... */
|
/* For now, precision must match compiled-in value... */
|
||||||
@@ -148,18 +119,18 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
#endif
|
#endif
|
||||||
/* Size in DCT blocks */
|
/* Size in DCT blocks */
|
||||||
compptr->width_in_blocks = (JDIMENSION)
|
compptr->width_in_blocks = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
(long) (cinfo->max_h_samp_factor * DCTSIZE));
|
||||||
compptr->height_in_blocks = (JDIMENSION)
|
compptr->height_in_blocks = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
(long) (cinfo->max_v_samp_factor * DCTSIZE));
|
||||||
/* Size in samples */
|
/* Size in samples */
|
||||||
compptr->downsampled_width = (JDIMENSION)
|
compptr->downsampled_width = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_width * (long)compptr->h_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_width * (long) compptr->h_samp_factor,
|
||||||
(long)cinfo->max_h_samp_factor);
|
(long) cinfo->max_h_samp_factor);
|
||||||
compptr->downsampled_height = (JDIMENSION)
|
compptr->downsampled_height = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_height * (long)compptr->v_samp_factor,
|
jdiv_round_up((long) cinfo->_jpeg_height * (long) compptr->v_samp_factor,
|
||||||
(long)cinfo->max_v_samp_factor);
|
(long) cinfo->max_v_samp_factor);
|
||||||
/* Mark component needed (this flag isn't actually used for compression) */
|
/* Mark component needed (this flag isn't actually used for compression) */
|
||||||
compptr->component_needed = TRUE;
|
compptr->component_needed = TRUE;
|
||||||
}
|
}
|
||||||
@@ -168,15 +139,15 @@ initial_setup(j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
* main controller will call coefficient controller).
|
* main controller will call coefficient controller).
|
||||||
*/
|
*/
|
||||||
cinfo->total_iMCU_rows = (JDIMENSION)
|
cinfo->total_iMCU_rows = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
validate_script(j_compress_ptr cinfo)
|
validate_script (j_compress_ptr cinfo)
|
||||||
/* Verify that the scan script in cinfo->scan_info[] is valid; also
|
/* Verify that the scan script in cinfo->scan_info[] is valid; also
|
||||||
* determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
|
* determine whether it uses progressive JPEG, and set cinfo->progressive_mode.
|
||||||
*/
|
*/
|
||||||
@@ -191,6 +162,14 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
/* -1 until that coefficient has been seen; then last Al for it */
|
/* -1 until that coefficient has been seen; then last Al for it */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (cinfo->master->optimize_scans) {
|
||||||
|
cinfo->progressive_mode = TRUE;
|
||||||
|
/* When we optimize scans, there is redundancy in the scan list
|
||||||
|
* and this function will fail. Therefore skip all this checking
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cinfo->num_scans <= 0)
|
if (cinfo->num_scans <= 0)
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
|
||||||
|
|
||||||
@@ -198,10 +177,10 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
* for progressive JPEG, no scan can have this.
|
* for progressive JPEG, no scan can have this.
|
||||||
*/
|
*/
|
||||||
scanptr = cinfo->scan_info;
|
scanptr = cinfo->scan_info;
|
||||||
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2 - 1) {
|
if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) {
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
cinfo->progressive_mode = TRUE;
|
cinfo->progressive_mode = TRUE;
|
||||||
last_bitpos_ptr = &last_bitpos[0][0];
|
last_bitpos_ptr = & last_bitpos[0][0];
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++)
|
for (ci = 0; ci < cinfo->num_components; ci++)
|
||||||
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
for (coefi = 0; coefi < DCTSIZE2; coefi++)
|
||||||
*last_bitpos_ptr++ = -1;
|
*last_bitpos_ptr++ = -1;
|
||||||
@@ -224,7 +203,7 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
if (thisi < 0 || thisi >= cinfo->num_components)
|
if (thisi < 0 || thisi >= cinfo->num_components)
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||||
/* Components must appear in SOF order within each scan */
|
/* Components must appear in SOF order within each scan */
|
||||||
if (ci > 0 && thisi <= scanptr->component_index[ci - 1])
|
if (ci > 0 && thisi <= scanptr->component_index[ci-1])
|
||||||
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
/* Validate progression parameters */
|
/* Validate progression parameters */
|
||||||
@@ -234,17 +213,17 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
Al = scanptr->Al;
|
Al = scanptr->Al;
|
||||||
if (cinfo->progressive_mode) {
|
if (cinfo->progressive_mode) {
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
/* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that
|
/* Rec. ITU-T T.81 | ISO/IEC 10918-1 simply gives the ranges 0..13 for Ah
|
||||||
* seems wrong: the upper bound ought to depend on data precision.
|
* and Al, but that seems wrong: the upper bound ought to depend on data
|
||||||
* Perhaps they really meant 0..N+1 for N-bit precision.
|
* precision. Perhaps they really meant 0..N+1 for N-bit precision.
|
||||||
* Here we allow 0..10 for 8-bit data; Al larger than 10 results in
|
* Here we allow 0..10 for 8-bit data; Al larger than 10 results in
|
||||||
* out-of-range reconstructed DC values during the first DC scan,
|
* out-of-range reconstructed DC values during the first DC scan,
|
||||||
* which might cause problems for some decoders.
|
* which might cause problems for some decoders.
|
||||||
*/
|
*/
|
||||||
#if BITS_IN_JSAMPLE == 8
|
#if BITS_IN_JSAMPLE == 8
|
||||||
#define MAX_AH_AL 10
|
#define MAX_AH_AL 10
|
||||||
#else
|
#else
|
||||||
#define MAX_AH_AL 13
|
#define MAX_AH_AL 13
|
||||||
#endif
|
#endif
|
||||||
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
|
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
|
||||||
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
|
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
|
||||||
@@ -257,7 +236,7 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
for (ci = 0; ci < ncomps; ci++) {
|
for (ci = 0; ci < ncomps; ci++) {
|
||||||
last_bitpos_ptr = &last_bitpos[scanptr->component_index[ci]][0];
|
last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0];
|
||||||
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
for (coefi = Ss; coefi <= Se; coefi++) {
|
for (coefi = Ss; coefi <= Se; coefi++) {
|
||||||
@@ -267,7 +246,7 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
} else {
|
} else {
|
||||||
/* not first scan */
|
/* not first scan */
|
||||||
if (Ah != last_bitpos_ptr[coefi] || Al != Ah - 1)
|
if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
}
|
}
|
||||||
last_bitpos_ptr[coefi] = Al;
|
last_bitpos_ptr[coefi] = Al;
|
||||||
@@ -276,7 +255,7 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* For sequential JPEG, all progression parameters must be these: */
|
/* For sequential JPEG, all progression parameters must be these: */
|
||||||
if (Ss != 0 || Se != DCTSIZE2 - 1 || Ah != 0 || Al != 0)
|
if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0)
|
||||||
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
|
||||||
/* Make sure components are not sent twice */
|
/* Make sure components are not sent twice */
|
||||||
for (ci = 0; ci < ncomps; ci++) {
|
for (ci = 0; ci < ncomps; ci++) {
|
||||||
@@ -303,7 +282,7 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
if (!component_sent[ci])
|
if (! component_sent[ci])
|
||||||
ERREXIT(cinfo, JERR_MISSING_DATA);
|
ERREXIT(cinfo, JERR_MISSING_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,15 +292,33 @@ validate_script(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
select_scan_parameters(j_compress_ptr cinfo)
|
select_scan_parameters (j_compress_ptr cinfo)
|
||||||
/* Set up the scan parameters for the current scan */
|
/* Set up the scan parameters for the current scan */
|
||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
|
|
||||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||||
if (cinfo->scan_info != NULL) {
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
if (master->pass_number < master->pass_number_scan_opt_base) {
|
||||||
|
cinfo->comps_in_scan = 1;
|
||||||
|
if (cinfo->master->use_scans_in_trellis) {
|
||||||
|
cinfo->cur_comp_info[0] =
|
||||||
|
&cinfo->comp_info[master->pass_number /
|
||||||
|
(4 * cinfo->master->trellis_num_loops)];
|
||||||
|
cinfo->Ss = (master->pass_number % 4 < 2) ?
|
||||||
|
1 : cinfo->master->trellis_freq_split + 1;
|
||||||
|
cinfo->Se = (master->pass_number % 4 < 2) ?
|
||||||
|
cinfo->master->trellis_freq_split : DCTSIZE2 - 1;
|
||||||
|
} else {
|
||||||
|
cinfo->cur_comp_info[0] =
|
||||||
|
&cinfo->comp_info[master->pass_number /
|
||||||
|
(2 * cinfo->master->trellis_num_loops)];
|
||||||
|
cinfo->Ss = 1;
|
||||||
|
cinfo->Se = DCTSIZE2-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cinfo->scan_info != NULL) {
|
||||||
/* Prepare for current scan --- the script is already validated */
|
/* Prepare for current scan --- the script is already validated */
|
||||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
|
||||||
const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
|
const jpeg_scan_info *scanptr = cinfo->scan_info + master->scan_number;
|
||||||
|
|
||||||
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
cinfo->comps_in_scan = scanptr->comps_in_scan;
|
||||||
@@ -333,7 +330,23 @@ select_scan_parameters(j_compress_ptr cinfo)
|
|||||||
cinfo->Se = scanptr->Se;
|
cinfo->Se = scanptr->Se;
|
||||||
cinfo->Ah = scanptr->Ah;
|
cinfo->Ah = scanptr->Ah;
|
||||||
cinfo->Al = scanptr->Al;
|
cinfo->Al = scanptr->Al;
|
||||||
} else
|
if (cinfo->master->optimize_scans) {
|
||||||
|
/* luma frequency split passes */
|
||||||
|
if (master->scan_number >= cinfo->master->num_scans_luma_dc +
|
||||||
|
3 * cinfo->master->Al_max_luma + 2 &&
|
||||||
|
master->scan_number < cinfo->master->num_scans_luma)
|
||||||
|
cinfo->Al = master->best_Al_luma;
|
||||||
|
/* chroma frequency split passes */
|
||||||
|
if (master->scan_number >= cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc +
|
||||||
|
(6 * cinfo->master->Al_max_chroma + 4) &&
|
||||||
|
master->scan_number < cinfo->num_scans)
|
||||||
|
cinfo->Al = master->best_Al_chroma;
|
||||||
|
}
|
||||||
|
/* save value for later retrieval during printout of scans */
|
||||||
|
master->actual_Al[master->scan_number] = cinfo->Al;
|
||||||
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Prepare for single sequential-JPEG scan containing all components */
|
/* Prepare for single sequential-JPEG scan containing all components */
|
||||||
@@ -345,7 +358,7 @@ select_scan_parameters(j_compress_ptr cinfo)
|
|||||||
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
|
||||||
}
|
}
|
||||||
cinfo->Ss = 0;
|
cinfo->Ss = 0;
|
||||||
cinfo->Se = DCTSIZE2 - 1;
|
cinfo->Se = DCTSIZE2-1;
|
||||||
cinfo->Ah = 0;
|
cinfo->Ah = 0;
|
||||||
cinfo->Al = 0;
|
cinfo->Al = 0;
|
||||||
}
|
}
|
||||||
@@ -353,7 +366,7 @@ select_scan_parameters(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
per_scan_setup(j_compress_ptr cinfo)
|
per_scan_setup (j_compress_ptr cinfo)
|
||||||
/* Do computations that are needed before processing a JPEG scan */
|
/* Do computations that are needed before processing a JPEG scan */
|
||||||
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
|
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */
|
||||||
{
|
{
|
||||||
@@ -378,7 +391,7 @@ per_scan_setup(j_compress_ptr cinfo)
|
|||||||
/* For noninterleaved scans, it is convenient to define last_row_height
|
/* For noninterleaved scans, it is convenient to define last_row_height
|
||||||
* as the number of block rows present in the last iMCU row.
|
* as the number of block rows present in the last iMCU row.
|
||||||
*/
|
*/
|
||||||
tmp = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
|
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
|
||||||
if (tmp == 0) tmp = compptr->v_samp_factor;
|
if (tmp == 0) tmp = compptr->v_samp_factor;
|
||||||
compptr->last_row_height = tmp;
|
compptr->last_row_height = tmp;
|
||||||
|
|
||||||
@@ -395,11 +408,11 @@ per_scan_setup(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
/* Overall image size in MCUs */
|
/* Overall image size in MCUs */
|
||||||
cinfo->MCUs_per_row = (JDIMENSION)
|
cinfo->MCUs_per_row = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_width,
|
jdiv_round_up((long) cinfo->_jpeg_width,
|
||||||
(long)(cinfo->max_h_samp_factor * DCTSIZE));
|
(long) (cinfo->max_h_samp_factor*DCTSIZE));
|
||||||
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
cinfo->MCU_rows_in_scan = (JDIMENSION)
|
||||||
jdiv_round_up((long)cinfo->_jpeg_height,
|
jdiv_round_up((long) cinfo->_jpeg_height,
|
||||||
(long)(cinfo->max_v_samp_factor * DCTSIZE));
|
(long) (cinfo->max_v_samp_factor*DCTSIZE));
|
||||||
|
|
||||||
cinfo->blocks_in_MCU = 0;
|
cinfo->blocks_in_MCU = 0;
|
||||||
|
|
||||||
@@ -411,10 +424,10 @@ per_scan_setup(j_compress_ptr cinfo)
|
|||||||
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
|
||||||
compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
|
compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE;
|
||||||
/* Figure number of non-dummy blocks in last MCU column & row */
|
/* Figure number of non-dummy blocks in last MCU column & row */
|
||||||
tmp = (int)(compptr->width_in_blocks % compptr->MCU_width);
|
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
|
||||||
if (tmp == 0) tmp = compptr->MCU_width;
|
if (tmp == 0) tmp = compptr->MCU_width;
|
||||||
compptr->last_col_width = tmp;
|
compptr->last_col_width = tmp;
|
||||||
tmp = (int)(compptr->height_in_blocks % compptr->MCU_height);
|
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
|
||||||
if (tmp == 0) tmp = compptr->MCU_height;
|
if (tmp == 0) tmp = compptr->MCU_height;
|
||||||
compptr->last_row_height = tmp;
|
compptr->last_row_height = tmp;
|
||||||
/* Prepare array describing MCU composition */
|
/* Prepare array describing MCU composition */
|
||||||
@@ -431,8 +444,8 @@ per_scan_setup(j_compress_ptr cinfo)
|
|||||||
/* Convert restart specified in rows to actual MCU count. */
|
/* Convert restart specified in rows to actual MCU count. */
|
||||||
/* Note that count must fit in 16 bits, so we provide limiting. */
|
/* Note that count must fit in 16 bits, so we provide limiting. */
|
||||||
if (cinfo->restart_in_rows > 0) {
|
if (cinfo->restart_in_rows > 0) {
|
||||||
long nominal = (long)cinfo->restart_in_rows * (long)cinfo->MCUs_per_row;
|
long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row;
|
||||||
cinfo->restart_interval = (unsigned int)MIN(nominal, 65535L);
|
cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,9 +459,11 @@ per_scan_setup(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
prepare_for_pass(j_compress_ptr cinfo)
|
prepare_for_pass (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
cinfo->master->trellis_passes =
|
||||||
|
master->pass_number < master->pass_number_scan_opt_base;
|
||||||
|
|
||||||
switch (master->pass_type) {
|
switch (master->pass_type) {
|
||||||
case main_pass:
|
case main_pass:
|
||||||
@@ -457,18 +472,18 @@ prepare_for_pass(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
select_scan_parameters(cinfo);
|
select_scan_parameters(cinfo);
|
||||||
per_scan_setup(cinfo);
|
per_scan_setup(cinfo);
|
||||||
if (!cinfo->raw_data_in) {
|
if (! cinfo->raw_data_in) {
|
||||||
(*cinfo->cconvert->start_pass) (cinfo);
|
(*cinfo->cconvert->start_pass) (cinfo);
|
||||||
(*cinfo->downsample->start_pass) (cinfo);
|
(*cinfo->downsample->start_pass) (cinfo);
|
||||||
(*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
|
(*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU);
|
||||||
}
|
}
|
||||||
(*cinfo->fdct->start_pass) (cinfo);
|
(*cinfo->fdct->start_pass) (cinfo);
|
||||||
(*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
|
(*cinfo->entropy->start_pass) (cinfo, (cinfo->optimize_coding || cinfo->master->trellis_quant) && !cinfo->arith_code);
|
||||||
(*cinfo->coef->start_pass) (cinfo,
|
(*cinfo->coef->start_pass) (cinfo,
|
||||||
(master->total_passes > 1 ?
|
(master->total_passes > 1 ?
|
||||||
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
|
JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
|
||||||
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
|
(*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
|
||||||
if (cinfo->optimize_coding) {
|
if (cinfo->optimize_coding || cinfo->master->trellis_quant) {
|
||||||
/* No immediate data output; postpone writing frame/scan headers */
|
/* No immediate data output; postpone writing frame/scan headers */
|
||||||
master->pub.call_pass_startup = FALSE;
|
master->pub.call_pass_startup = FALSE;
|
||||||
} else {
|
} else {
|
||||||
@@ -492,15 +507,22 @@ prepare_for_pass(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
master->pass_type = output_pass;
|
master->pass_type = output_pass;
|
||||||
master->pass_number++;
|
master->pass_number++;
|
||||||
/*FALLTHROUGH*/
|
|
||||||
#endif
|
#endif
|
||||||
|
/*FALLTHROUGH*/
|
||||||
case output_pass:
|
case output_pass:
|
||||||
/* Do a data-output pass. */
|
/* Do a data-output pass. */
|
||||||
/* We need not repeat per-scan setup if prior optimization pass did it. */
|
/* We need not repeat per-scan setup if prior optimization pass did it. */
|
||||||
if (!cinfo->optimize_coding) {
|
if (! cinfo->optimize_coding) {
|
||||||
select_scan_parameters(cinfo);
|
select_scan_parameters(cinfo);
|
||||||
per_scan_setup(cinfo);
|
per_scan_setup(cinfo);
|
||||||
}
|
}
|
||||||
|
if (cinfo->master->optimize_scans) {
|
||||||
|
master->saved_dest = cinfo->dest;
|
||||||
|
cinfo->dest = NULL;
|
||||||
|
master->scan_size[master->scan_number] = 0;
|
||||||
|
jpeg_mem_dest_internal(cinfo, &master->scan_buffer[master->scan_number], &master->scan_size[master->scan_number], JPOOL_IMAGE);
|
||||||
|
(*cinfo->dest->init_destination)(cinfo);
|
||||||
|
}
|
||||||
(*cinfo->entropy->start_pass) (cinfo, FALSE);
|
(*cinfo->entropy->start_pass) (cinfo, FALSE);
|
||||||
(*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
|
(*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
|
||||||
/* We emit frame/scan headers now */
|
/* We emit frame/scan headers now */
|
||||||
@@ -509,11 +531,29 @@ prepare_for_pass(j_compress_ptr cinfo)
|
|||||||
(*cinfo->marker->write_scan_header) (cinfo);
|
(*cinfo->marker->write_scan_header) (cinfo);
|
||||||
master->pub.call_pass_startup = FALSE;
|
master->pub.call_pass_startup = FALSE;
|
||||||
break;
|
break;
|
||||||
|
case trellis_pass:
|
||||||
|
if (master->pass_number %
|
||||||
|
(cinfo->num_components * (cinfo->master->use_scans_in_trellis ? 4 : 2)) == 1 &&
|
||||||
|
cinfo->master->trellis_q_opt) {
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||||
|
for (j = 1; j < DCTSIZE2; j++) {
|
||||||
|
cinfo->master->norm_src[i][j] = 0.0;
|
||||||
|
cinfo->master->norm_coef[i][j] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*cinfo->entropy->start_pass) (cinfo, !cinfo->arith_code);
|
||||||
|
(*cinfo->coef->start_pass) (cinfo, JBUF_REQUANT);
|
||||||
|
master->pub.call_pass_startup = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
ERREXIT(cinfo, JERR_NOT_COMPILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
|
master->pub.is_last_pass = (master->pass_number == master->total_passes-1);
|
||||||
|
|
||||||
/* Set up progress monitor's pass info if present */
|
/* Set up progress monitor's pass info if present */
|
||||||
if (cinfo->progress != NULL) {
|
if (cinfo->progress != NULL) {
|
||||||
@@ -534,7 +574,7 @@ prepare_for_pass(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
pass_startup(j_compress_ptr cinfo)
|
pass_startup (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
|
cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */
|
||||||
|
|
||||||
@@ -543,14 +583,240 @@ pass_startup(j_compress_ptr cinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LOCAL(void)
|
||||||
|
copy_buffer (j_compress_ptr cinfo, int scan_idx)
|
||||||
|
{
|
||||||
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
|
unsigned long size = master->scan_size[scan_idx];
|
||||||
|
unsigned char * src = master->scan_buffer[scan_idx];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (cinfo->err->trace_level > 0) {
|
||||||
|
fprintf(stderr, "SCAN ");
|
||||||
|
for (i = 0; i < cinfo->scan_info[scan_idx].comps_in_scan; i++)
|
||||||
|
fprintf(stderr, "%s%d", (i==0)?"":",", cinfo->scan_info[scan_idx].component_index[i]);
|
||||||
|
fprintf(stderr, ": %d %d", cinfo->scan_info[scan_idx].Ss, cinfo->scan_info[scan_idx].Se);
|
||||||
|
fprintf(stderr, " %d %d", cinfo->scan_info[scan_idx].Ah, master->actual_Al[scan_idx]);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
while (size >= cinfo->dest->free_in_buffer)
|
||||||
|
{
|
||||||
|
MEMCOPY(cinfo->dest->next_output_byte, src, cinfo->dest->free_in_buffer);
|
||||||
|
src += cinfo->dest->free_in_buffer;
|
||||||
|
size -= cinfo->dest->free_in_buffer;
|
||||||
|
cinfo->dest->next_output_byte += cinfo->dest->free_in_buffer;
|
||||||
|
cinfo->dest->free_in_buffer = 0;
|
||||||
|
|
||||||
|
if (!(*cinfo->dest->empty_output_buffer)(cinfo))
|
||||||
|
ERREXIT(cinfo, JERR_UNSUPPORTED_SUSPEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMCOPY(cinfo->dest->next_output_byte, src, size);
|
||||||
|
cinfo->dest->next_output_byte += size;
|
||||||
|
cinfo->dest->free_in_buffer -= size;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL(void)
|
||||||
|
select_scans (j_compress_ptr cinfo, int next_scan_number)
|
||||||
|
{
|
||||||
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
|
int base_scan_idx = 0;
|
||||||
|
int luma_freq_split_scan_start = cinfo->master->num_scans_luma_dc +
|
||||||
|
3 * cinfo->master->Al_max_luma + 2;
|
||||||
|
int chroma_freq_split_scan_start = cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc +
|
||||||
|
(6 * cinfo->master->Al_max_chroma + 4);
|
||||||
|
int passes_per_scan = cinfo->optimize_coding ? 2 : 1;
|
||||||
|
|
||||||
|
if (next_scan_number > 1 && next_scan_number <= luma_freq_split_scan_start) {
|
||||||
|
if ((next_scan_number - 1) % 3 == 2) {
|
||||||
|
int Al = (next_scan_number - 1) / 3;
|
||||||
|
int i;
|
||||||
|
unsigned long cost = 0;
|
||||||
|
cost += master->scan_size[next_scan_number-2];
|
||||||
|
cost += master->scan_size[next_scan_number-1];
|
||||||
|
for (i = 0; i < Al; i++)
|
||||||
|
cost += master->scan_size[3 + 3*i];
|
||||||
|
|
||||||
|
if (Al == 0 || cost < master->best_cost) {
|
||||||
|
master->best_cost = cost;
|
||||||
|
master->best_Al_luma = Al;
|
||||||
|
} else {
|
||||||
|
master->scan_number = luma_freq_split_scan_start - 1;
|
||||||
|
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (next_scan_number > luma_freq_split_scan_start &&
|
||||||
|
next_scan_number <= cinfo->master->num_scans_luma) {
|
||||||
|
if (next_scan_number == luma_freq_split_scan_start + 1) {
|
||||||
|
master->best_freq_split_idx_luma = 0;
|
||||||
|
master->best_cost = master->scan_size[next_scan_number-1];
|
||||||
|
|
||||||
|
} else if ((next_scan_number - luma_freq_split_scan_start) % 2 == 1) {
|
||||||
|
int idx = (next_scan_number - luma_freq_split_scan_start) >> 1;
|
||||||
|
unsigned long cost = 0;
|
||||||
|
cost += master->scan_size[next_scan_number-2];
|
||||||
|
cost += master->scan_size[next_scan_number-1];
|
||||||
|
|
||||||
|
if (cost < master->best_cost) {
|
||||||
|
master->best_cost = cost;
|
||||||
|
master->best_freq_split_idx_luma = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if after testing first 3, no split is the best, don't search further */
|
||||||
|
if ((idx == 2 && master->best_freq_split_idx_luma == 0) ||
|
||||||
|
(idx == 3 && master->best_freq_split_idx_luma != 2) ||
|
||||||
|
(idx == 4 && master->best_freq_split_idx_luma != 4)) {
|
||||||
|
master->scan_number = cinfo->master->num_scans_luma - 1;
|
||||||
|
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
|
||||||
|
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (cinfo->num_scans > cinfo->master->num_scans_luma) {
|
||||||
|
|
||||||
|
if (next_scan_number == cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc) {
|
||||||
|
base_scan_idx = cinfo->master->num_scans_luma;
|
||||||
|
|
||||||
|
master->interleave_chroma_dc = master->scan_size[base_scan_idx] <= master->scan_size[base_scan_idx+1] + master->scan_size[base_scan_idx+2];
|
||||||
|
|
||||||
|
} else if (next_scan_number > cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc &&
|
||||||
|
next_scan_number <= chroma_freq_split_scan_start) {
|
||||||
|
base_scan_idx = cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc;
|
||||||
|
if ((next_scan_number - base_scan_idx) % 6 == 4) {
|
||||||
|
int Al = (next_scan_number - base_scan_idx) / 6;
|
||||||
|
int i;
|
||||||
|
unsigned long cost = 0;
|
||||||
|
cost += master->scan_size[next_scan_number-4];
|
||||||
|
cost += master->scan_size[next_scan_number-3];
|
||||||
|
cost += master->scan_size[next_scan_number-2];
|
||||||
|
cost += master->scan_size[next_scan_number-1];
|
||||||
|
for (i = 0; i < Al; i++) {
|
||||||
|
cost += master->scan_size[base_scan_idx + 4 + 6*i];
|
||||||
|
cost += master->scan_size[base_scan_idx + 5 + 6*i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Al == 0 || cost < master->best_cost) {
|
||||||
|
master->best_cost = cost;
|
||||||
|
master->best_Al_chroma = Al;
|
||||||
|
} else {
|
||||||
|
master->scan_number = chroma_freq_split_scan_start - 1;
|
||||||
|
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (next_scan_number > chroma_freq_split_scan_start && next_scan_number <= cinfo->num_scans) {
|
||||||
|
if (next_scan_number == chroma_freq_split_scan_start + 2) {
|
||||||
|
master->best_freq_split_idx_chroma = 0;
|
||||||
|
master->best_cost = master->scan_size[next_scan_number-2];
|
||||||
|
master->best_cost += master->scan_size[next_scan_number-1];
|
||||||
|
|
||||||
|
} else if ((next_scan_number - chroma_freq_split_scan_start) % 4 == 2) {
|
||||||
|
int idx = (next_scan_number - chroma_freq_split_scan_start) >> 2;
|
||||||
|
unsigned long cost = 0;
|
||||||
|
cost += master->scan_size[next_scan_number-4];
|
||||||
|
cost += master->scan_size[next_scan_number-3];
|
||||||
|
cost += master->scan_size[next_scan_number-2];
|
||||||
|
cost += master->scan_size[next_scan_number-1];
|
||||||
|
|
||||||
|
if (cost < master->best_cost) {
|
||||||
|
master->best_cost = cost;
|
||||||
|
master->best_freq_split_idx_chroma = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if after testing first 3, no split is the best, don't search further */
|
||||||
|
if ((idx == 2 && master->best_freq_split_idx_chroma == 0) ||
|
||||||
|
(idx == 3 && master->best_freq_split_idx_chroma != 2) ||
|
||||||
|
(idx == 4 && master->best_freq_split_idx_chroma != 4)) {
|
||||||
|
master->scan_number = cinfo->num_scans - 1;
|
||||||
|
master->pass_number = passes_per_scan * (master->scan_number + 1) - 1 + master->pass_number_scan_opt_base;
|
||||||
|
master->pub.is_last_pass = (master->pass_number == master->total_passes - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (master->scan_number == cinfo->num_scans - 1) {
|
||||||
|
int i, Al;
|
||||||
|
int min_Al = MIN(master->best_Al_luma, master->best_Al_chroma);
|
||||||
|
|
||||||
|
copy_buffer(cinfo, 0);
|
||||||
|
|
||||||
|
if (cinfo->num_scans > cinfo->master->num_scans_luma &&
|
||||||
|
cinfo->master->dc_scan_opt_mode != 0) {
|
||||||
|
base_scan_idx = cinfo->master->num_scans_luma;
|
||||||
|
|
||||||
|
if (master->interleave_chroma_dc && cinfo->master->dc_scan_opt_mode != 1)
|
||||||
|
copy_buffer(cinfo, base_scan_idx);
|
||||||
|
else {
|
||||||
|
copy_buffer(cinfo, base_scan_idx+1);
|
||||||
|
copy_buffer(cinfo, base_scan_idx+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (master->best_freq_split_idx_luma == 0)
|
||||||
|
copy_buffer(cinfo, luma_freq_split_scan_start);
|
||||||
|
else {
|
||||||
|
copy_buffer(cinfo, luma_freq_split_scan_start+2*(master->best_freq_split_idx_luma-1)+1);
|
||||||
|
copy_buffer(cinfo, luma_freq_split_scan_start+2*(master->best_freq_split_idx_luma-1)+2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* copy the LSB refinements as well */
|
||||||
|
for (Al = master->best_Al_luma-1; Al >= min_Al; Al--)
|
||||||
|
copy_buffer(cinfo, 3 + 3*Al);
|
||||||
|
|
||||||
|
if (cinfo->num_scans > cinfo->master->num_scans_luma) {
|
||||||
|
if (master->best_freq_split_idx_chroma == 0) {
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start);
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start+1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+2);
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+3);
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+4);
|
||||||
|
copy_buffer(cinfo, chroma_freq_split_scan_start+4*(master->best_freq_split_idx_chroma-1)+5);
|
||||||
|
}
|
||||||
|
|
||||||
|
base_scan_idx = cinfo->master->num_scans_luma +
|
||||||
|
cinfo->master->num_scans_chroma_dc;
|
||||||
|
|
||||||
|
for (Al = master->best_Al_chroma-1; Al >= min_Al; Al--) {
|
||||||
|
copy_buffer(cinfo, base_scan_idx + 6*Al + 4);
|
||||||
|
copy_buffer(cinfo, base_scan_idx + 6*Al + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Al = min_Al-1; Al >= 0; Al--) {
|
||||||
|
copy_buffer(cinfo, 3 + 3*Al);
|
||||||
|
|
||||||
|
if (cinfo->num_scans > cinfo->master->num_scans_luma) {
|
||||||
|
copy_buffer(cinfo, base_scan_idx + 6*Al + 4);
|
||||||
|
copy_buffer(cinfo, base_scan_idx + 6*Al + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the memory allocated for buffers */
|
||||||
|
for (i = 0; i < cinfo->num_scans; i++)
|
||||||
|
if (master->scan_buffer[i])
|
||||||
|
free(master->scan_buffer[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finish up at end of pass.
|
* Finish up at end of pass.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
finish_pass_master(j_compress_ptr cinfo)
|
finish_pass_master (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_master_ptr master = (my_master_ptr)cinfo->master;
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
/* The entropy coder always needs an end-of-pass call,
|
/* The entropy coder always needs an end-of-pass call,
|
||||||
* either to analyze statistics or to flush its output buffer.
|
* either to analyze statistics or to flush its output buffer.
|
||||||
@@ -563,20 +829,54 @@ finish_pass_master(j_compress_ptr cinfo)
|
|||||||
/* next pass is either output of scan 0 (after optimization)
|
/* next pass is either output of scan 0 (after optimization)
|
||||||
* or output of scan 1 (if no optimization).
|
* or output of scan 1 (if no optimization).
|
||||||
*/
|
*/
|
||||||
|
if (cinfo->master->trellis_quant)
|
||||||
|
master->pass_type = trellis_pass;
|
||||||
|
else {
|
||||||
master->pass_type = output_pass;
|
master->pass_type = output_pass;
|
||||||
if (!cinfo->optimize_coding)
|
if (! cinfo->optimize_coding)
|
||||||
master->scan_number++;
|
master->scan_number++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case huff_opt_pass:
|
case huff_opt_pass:
|
||||||
/* next pass is always output of current scan */
|
/* next pass is always output of current scan */
|
||||||
master->pass_type = output_pass;
|
master->pass_type = (master->pass_number < master->pass_number_scan_opt_base-1) ? trellis_pass : output_pass;
|
||||||
break;
|
break;
|
||||||
case output_pass:
|
case output_pass:
|
||||||
/* next pass is either optimization or output of next scan */
|
/* next pass is either optimization or output of next scan */
|
||||||
if (cinfo->optimize_coding)
|
if (cinfo->optimize_coding)
|
||||||
master->pass_type = huff_opt_pass;
|
master->pass_type = huff_opt_pass;
|
||||||
|
if (cinfo->master->optimize_scans) {
|
||||||
|
(*cinfo->dest->term_destination)(cinfo);
|
||||||
|
cinfo->dest = master->saved_dest;
|
||||||
|
select_scans(cinfo, master->scan_number + 1);
|
||||||
|
}
|
||||||
|
|
||||||
master->scan_number++;
|
master->scan_number++;
|
||||||
break;
|
break;
|
||||||
|
case trellis_pass:
|
||||||
|
if (cinfo->optimize_coding)
|
||||||
|
master->pass_type = huff_opt_pass;
|
||||||
|
else
|
||||||
|
master->pass_type = (master->pass_number < master->pass_number_scan_opt_base-1) ? trellis_pass : output_pass;
|
||||||
|
|
||||||
|
if ((master->pass_number + 1) %
|
||||||
|
(cinfo->num_components * (cinfo->master->use_scans_in_trellis ? 4 : 2)) == 0 &&
|
||||||
|
cinfo->master->trellis_q_opt) {
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
||||||
|
for (j = 1; j < DCTSIZE2; j++) {
|
||||||
|
if (cinfo->master->norm_coef[i][j] != 0.0) {
|
||||||
|
int q = (int)(cinfo->master->norm_src[i][j] /
|
||||||
|
cinfo->master->norm_coef[i][j] + 0.5);
|
||||||
|
if (q > 254) q = 254;
|
||||||
|
if (q < 1) q = 1;
|
||||||
|
cinfo->quant_tbl_ptrs[i]->quantval[j] = q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
master->pass_number++;
|
master->pass_number++;
|
||||||
@@ -588,18 +888,15 @@ finish_pass_master(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
|
jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
|
||||||
{
|
{
|
||||||
my_master_ptr master;
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
master = (my_master_ptr)
|
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
|
||||||
sizeof(my_comp_master));
|
|
||||||
cinfo->master = (struct jpeg_comp_master *)master;
|
|
||||||
master->pub.prepare_for_pass = prepare_for_pass;
|
master->pub.prepare_for_pass = prepare_for_pass;
|
||||||
master->pub.pass_startup = pass_startup;
|
master->pub.pass_startup = pass_startup;
|
||||||
master->pub.finish_pass = finish_pass_master;
|
master->pub.finish_pass = finish_pass_master;
|
||||||
master->pub.is_last_pass = FALSE;
|
master->pub.is_last_pass = FALSE;
|
||||||
|
master->pub.call_pass_startup = FALSE;
|
||||||
|
|
||||||
/* Validate parameters, determine derived values */
|
/* Validate parameters, determine derived values */
|
||||||
initial_setup(cinfo, transcode_only);
|
initial_setup(cinfo, transcode_only);
|
||||||
@@ -637,4 +934,25 @@ jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
|
|||||||
master->total_passes = cinfo->num_scans;
|
master->total_passes = cinfo->num_scans;
|
||||||
|
|
||||||
master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
|
master->jpeg_version = PACKAGE_NAME " version " VERSION " (build " BUILD ")";
|
||||||
|
|
||||||
|
master->pass_number_scan_opt_base = 0;
|
||||||
|
if (cinfo->master->trellis_quant) {
|
||||||
|
if (cinfo->optimize_coding)
|
||||||
|
master->pass_number_scan_opt_base =
|
||||||
|
((cinfo->master->use_scans_in_trellis) ? 4 : 2) * cinfo->num_components *
|
||||||
|
cinfo->master->trellis_num_loops;
|
||||||
|
else
|
||||||
|
master->pass_number_scan_opt_base =
|
||||||
|
((cinfo->master->use_scans_in_trellis) ? 2 : 1) * cinfo->num_components *
|
||||||
|
cinfo->master->trellis_num_loops + 1;
|
||||||
|
master->total_passes += master->pass_number_scan_opt_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cinfo->master->optimize_scans) {
|
||||||
|
int i;
|
||||||
|
master->best_Al_chroma = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < cinfo->num_scans; i++)
|
||||||
|
master->scan_buffer[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
jcmaster.h
Normal file
56
jcmaster.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* jcmaster.h
|
||||||
|
*
|
||||||
|
* This file was part of the Independent JPEG Group's software:
|
||||||
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
|
* mozjpeg Modifications:
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
|
*
|
||||||
|
* This file contains the master control structures for the JPEG compressor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Private state */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
main_pass, /* input data, also do first output step */
|
||||||
|
huff_opt_pass, /* Huffman code optimization pass */
|
||||||
|
output_pass, /* data output pass */
|
||||||
|
trellis_pass /* trellis quantization pass */
|
||||||
|
} c_pass_type;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct jpeg_comp_master pub; /* public fields */
|
||||||
|
|
||||||
|
c_pass_type pass_type; /* the type of the current pass */
|
||||||
|
|
||||||
|
int pass_number; /* # of passes completed */
|
||||||
|
int total_passes; /* total # of passes needed */
|
||||||
|
|
||||||
|
int scan_number; /* current index in scan_info[] */
|
||||||
|
|
||||||
|
/* fields for scan optimisation */
|
||||||
|
int pass_number_scan_opt_base; /* pass number where scan optimization begins */
|
||||||
|
unsigned char * scan_buffer[64]; /* buffer for a given scan */
|
||||||
|
unsigned long scan_size[64]; /* size for a given scan */
|
||||||
|
int actual_Al[64]; /* actual value of Al used for a scan */
|
||||||
|
unsigned long best_cost; /* bit count for best frequency split */
|
||||||
|
int best_freq_split_idx_luma; /* index for best frequency split (luma) */
|
||||||
|
int best_freq_split_idx_chroma; /* index for best frequency split (chroma) */
|
||||||
|
int best_Al_luma; /* best value for Al found in scan search (luma) */
|
||||||
|
int best_Al_chroma; /* best value for Al found in scan search (luma) */
|
||||||
|
boolean interleave_chroma_dc; /* indicate whether to interleave chroma DC scans */
|
||||||
|
struct jpeg_destination_mgr * saved_dest; /* saved value of cinfo->dest */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is here so we can add libjpeg-turbo version/build information to the
|
||||||
|
* global string table without introducing a new global symbol. Adding this
|
||||||
|
* information to the global string table allows one to examine a binary
|
||||||
|
* object and determine which version of libjpeg-turbo it was built from or
|
||||||
|
* linked against.
|
||||||
|
*/
|
||||||
|
const char *jpeg_version;
|
||||||
|
} my_comp_master;
|
||||||
|
|
||||||
|
typedef my_comp_master * my_master_ptr;
|
||||||
28
jconfig.h.in
28
jconfig.h.in
@@ -10,16 +10,16 @@
|
|||||||
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
|
#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
|
||||||
|
|
||||||
/* Support arithmetic encoding */
|
/* Support arithmetic encoding */
|
||||||
#cmakedefine C_ARITH_CODING_SUPPORTED
|
#cmakedefine C_ARITH_CODING_SUPPORTED 1
|
||||||
|
|
||||||
/* Support arithmetic decoding */
|
/* Support arithmetic decoding */
|
||||||
#cmakedefine D_ARITH_CODING_SUPPORTED
|
#cmakedefine D_ARITH_CODING_SUPPORTED 1
|
||||||
|
|
||||||
/* Support in-memory source/destination managers */
|
/* Support in-memory source/destination managers */
|
||||||
#cmakedefine MEM_SRCDST_SUPPORTED
|
#cmakedefine MEM_SRCDST_SUPPORTED 1
|
||||||
|
|
||||||
/* Use accelerated SIMD routines. */
|
/* Use accelerated SIMD routines. */
|
||||||
#cmakedefine WITH_SIMD
|
#cmakedefine WITH_SIMD 1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define BITS_IN_JSAMPLE as either
|
* Define BITS_IN_JSAMPLE as either
|
||||||
@@ -33,37 +33,37 @@
|
|||||||
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
|
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
|
||||||
|
|
||||||
/* Define to 1 if you have the <locale.h> header file. */
|
/* Define to 1 if you have the <locale.h> header file. */
|
||||||
#cmakedefine HAVE_LOCALE_H
|
#cmakedefine HAVE_LOCALE_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <stddef.h> header file. */
|
/* Define to 1 if you have the <stddef.h> header file. */
|
||||||
#cmakedefine HAVE_STDDEF_H
|
#cmakedefine HAVE_STDDEF_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
#cmakedefine HAVE_STDLIB_H
|
#cmakedefine HAVE_STDLIB_H 1
|
||||||
|
|
||||||
/* Define if you need to include <sys/types.h> to get size_t. */
|
/* Define if you need to include <sys/types.h> to get size_t. */
|
||||||
#cmakedefine NEED_SYS_TYPES_H
|
#cmakedefine NEED_SYS_TYPES_H 1
|
||||||
|
|
||||||
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
|
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
|
||||||
memset/memcpy in <string.h>. */
|
memset/memcpy in <string.h>. */
|
||||||
#cmakedefine NEED_BSD_STRINGS
|
#cmakedefine NEED_BSD_STRINGS 1
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `unsigned char'. */
|
/* Define to 1 if the system has the type `unsigned char'. */
|
||||||
#cmakedefine HAVE_UNSIGNED_CHAR
|
#cmakedefine HAVE_UNSIGNED_CHAR 1
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `unsigned short'. */
|
/* Define to 1 if the system has the type `unsigned short'. */
|
||||||
#cmakedefine HAVE_UNSIGNED_SHORT
|
#cmakedefine HAVE_UNSIGNED_SHORT 1
|
||||||
|
|
||||||
/* Compiler does not support pointers to undefined structures. */
|
/* Compiler does not support pointers to undefined structures. */
|
||||||
#cmakedefine INCOMPLETE_TYPES_BROKEN
|
#cmakedefine INCOMPLETE_TYPES_BROKEN 1
|
||||||
|
|
||||||
/* Define if your (broken) compiler shifts signed values as if they were
|
/* Define if your (broken) compiler shifts signed values as if they were
|
||||||
unsigned. */
|
unsigned. */
|
||||||
#cmakedefine RIGHT_SHIFT_IS_UNSIGNED
|
#cmakedefine RIGHT_SHIFT_IS_UNSIGNED 1
|
||||||
|
|
||||||
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
|
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
|
||||||
#ifndef __CHAR_UNSIGNED__
|
#ifndef __CHAR_UNSIGNED__
|
||||||
#cmakedefine __CHAR_UNSIGNED__
|
#cmakedefine __CHAR_UNSIGNED__ 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to empty if `const' does not conform to ANSI C. */
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ typedef unsigned char boolean;
|
|||||||
|
|
||||||
/* These defines indicate which image (non-JPEG) file formats are allowed. */
|
/* These defines indicate which image (non-JPEG) file formats are allowed. */
|
||||||
|
|
||||||
|
#define PNG_SUPPORTED /* PNG image file format */
|
||||||
#define BMP_SUPPORTED /* BMP image file format */
|
#define BMP_SUPPORTED /* BMP image file format */
|
||||||
#define GIF_SUPPORTED /* GIF image file format */
|
#define GIF_SUPPORTED /* GIF image file format */
|
||||||
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
||||||
@@ -128,7 +129,7 @@ typedef unsigned char boolean;
|
|||||||
*/
|
*/
|
||||||
#undef TWO_FILE_COMMANDLINE
|
#undef TWO_FILE_COMMANDLINE
|
||||||
|
|
||||||
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
|
/* By default, we open image files with fopen(..., "rb") or fopen(..., "wb").
|
||||||
* This is necessary on systems that distinguish text files from binary files,
|
* This is necessary on systems that distinguish text files from binary files,
|
||||||
* and is harmless on most systems that don't. If you have one of the rare
|
* and is harmless on most systems that don't. If you have one of the rare
|
||||||
* systems that complains about the "b" spec, define this symbol.
|
* systems that complains about the "b" spec, define this symbol.
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
/* How to obtain function inlining. */
|
/* How to obtain function inlining. */
|
||||||
#define INLINE @INLINE@
|
#define INLINE @INLINE@
|
||||||
|
|
||||||
|
/* How to obtain thread-local storage */
|
||||||
|
#define THREAD_LOCAL @THREAD_LOCAL@
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
/* Define to the full name of this package. */
|
||||||
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
|
#define PACKAGE_NAME "@CMAKE_PROJECT_NAME@"
|
||||||
|
|
||||||
|
|||||||
559
jcparam.c
559
jcparam.c
@@ -5,9 +5,10 @@
|
|||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modified 2003-2008 by Guido Vollbeding.
|
* Modified 2003-2008 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, D. R. Commander.
|
* Copyright (C) 2009-2011, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains optional default-setting code for the JPEG compressor.
|
* This file contains optional default-setting code for the JPEG compressor.
|
||||||
* Applications do not have to use this file, but those that don't use it
|
* Applications do not have to use this file, but those that don't use it
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||||
const unsigned int *basic_table, int scale_factor,
|
const unsigned int *basic_table, int scale_factor,
|
||||||
boolean force_baseline)
|
boolean force_baseline)
|
||||||
/* Define a quantization table equal to the basic_table times
|
/* Define a quantization table equal to the basic_table times
|
||||||
@@ -45,19 +46,19 @@ jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
|||||||
if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
|
if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS)
|
||||||
ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
|
ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl);
|
||||||
|
|
||||||
qtblptr = &cinfo->quant_tbl_ptrs[which_tbl];
|
qtblptr = & cinfo->quant_tbl_ptrs[which_tbl];
|
||||||
|
|
||||||
if (*qtblptr == NULL)
|
if (*qtblptr == NULL)
|
||||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)cinfo);
|
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo);
|
||||||
|
|
||||||
for (i = 0; i < DCTSIZE2; i++) {
|
for (i = 0; i < DCTSIZE2; i++) {
|
||||||
temp = ((long)basic_table[i] * scale_factor + 50L) / 100L;
|
temp = ((long) basic_table[i] * scale_factor + 50L) / 100L;
|
||||||
/* limit the values to the valid range */
|
/* limit the values to the valid range */
|
||||||
if (temp <= 0L) temp = 1L;
|
if (temp <= 0L) temp = 1L;
|
||||||
if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
|
if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */
|
||||||
if (force_baseline && temp > 255L)
|
if (force_baseline && temp > 255L)
|
||||||
temp = 255L; /* limit to baseline range if requested */
|
temp = 255L; /* limit to baseline range if requested */
|
||||||
(*qtblptr)->quantval[i] = (UINT16)temp;
|
(*qtblptr)->quantval[i] = (UINT16) temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
/* Initialize sent_table FALSE so table will be written to JPEG file. */
|
||||||
@@ -65,11 +66,15 @@ jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* These are the sample quantization tables given in JPEG spec section K.1.
|
/* These are the sample quantization tables given in Annex K (Clause K.1) of
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
* The spec says that the values given produce "good" quality, and
|
* The spec says that the values given produce "good" quality, and
|
||||||
* when divided by 2, "very good" quality.
|
* when divided by 2, "very good" quality.
|
||||||
*/
|
*/
|
||||||
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
|
static const unsigned int std_luminance_quant_tbl[9][DCTSIZE2] = {
|
||||||
|
{
|
||||||
|
/* JPEG Annex K
|
||||||
|
*/
|
||||||
16, 11, 10, 16, 24, 40, 51, 61,
|
16, 11, 10, 16, 24, 40, 51, 61,
|
||||||
12, 12, 14, 19, 26, 58, 60, 55,
|
12, 12, 14, 19, 26, 58, 60, 55,
|
||||||
14, 13, 16, 24, 40, 57, 69, 56,
|
14, 13, 16, 24, 40, 57, 69, 56,
|
||||||
@@ -78,8 +83,105 @@ static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
|
|||||||
24, 35, 55, 64, 81, 104, 113, 92,
|
24, 35, 55, 64, 81, 104, 113, 92,
|
||||||
49, 64, 78, 87, 103, 121, 120, 101,
|
49, 64, 78, 87, 103, 121, 120, 101,
|
||||||
72, 92, 95, 98, 112, 100, 103, 99
|
72, 92, 95, 98, 112, 100, 103, 99
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* flat
|
||||||
|
*/
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16
|
||||||
|
},
|
||||||
|
{
|
||||||
|
12, 17, 20, 21, 30, 34, 56, 63,
|
||||||
|
18, 20, 20, 26, 28, 51, 61, 55,
|
||||||
|
19, 20, 21, 26, 33, 58, 69, 55,
|
||||||
|
26, 26, 26, 30, 46, 87, 86, 66,
|
||||||
|
31, 33, 36, 40, 46, 96, 100, 73,
|
||||||
|
40, 35, 46, 62, 81, 100, 111, 91,
|
||||||
|
46, 66, 76, 86, 102, 121, 120, 101,
|
||||||
|
68, 90, 90, 96, 113, 102, 105, 103
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
|
||||||
|
*/
|
||||||
|
16, 16, 16, 18, 25, 37, 56, 85,
|
||||||
|
16, 17, 20, 27, 34, 40, 53, 75,
|
||||||
|
16, 20, 24, 31, 43, 62, 91, 135,
|
||||||
|
18, 27, 31, 40, 53, 74, 106, 156,
|
||||||
|
25, 34, 43, 53, 69, 94, 131, 189,
|
||||||
|
37, 40, 62, 74, 94, 124, 169, 238,
|
||||||
|
56, 53, 91, 106, 131, 169, 226, 311,
|
||||||
|
85, 75, 135, 156, 189, 238, 311, 418
|
||||||
|
},
|
||||||
|
{
|
||||||
|
9, 10, 12, 14, 27, 32, 51, 62,
|
||||||
|
11, 12, 14, 19, 27, 44, 59, 73,
|
||||||
|
12, 14, 18, 25, 42, 59, 79, 78,
|
||||||
|
17, 18, 25, 42, 61, 92, 87, 92,
|
||||||
|
23, 28, 42, 75, 79, 112, 112, 99,
|
||||||
|
40, 42, 59, 84, 88, 124, 132, 111,
|
||||||
|
42, 64, 78, 95, 105, 126, 125, 99,
|
||||||
|
70, 75, 100, 102, 116, 100, 107, 98
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
|
||||||
|
*/
|
||||||
|
10, 12, 14, 19, 26, 38, 57, 86,
|
||||||
|
12, 18, 21, 28, 35, 41, 54, 76,
|
||||||
|
14, 21, 25, 32, 44, 63, 92, 136,
|
||||||
|
19, 28, 32, 41, 54, 75, 107, 157,
|
||||||
|
26, 35, 44, 54, 70, 95, 132, 190,
|
||||||
|
38, 41, 63, 75, 95, 125, 170, 239,
|
||||||
|
57, 54, 92, 107, 132, 170, 227, 312,
|
||||||
|
86, 76, 136, 157, 190, 239, 312, 419
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
|
||||||
|
*/
|
||||||
|
7, 8, 10, 14, 23, 44, 95, 241,
|
||||||
|
8, 8, 11, 15, 25, 47, 102, 255,
|
||||||
|
10, 11, 13, 19, 31, 58, 127, 255,
|
||||||
|
14, 15, 19, 27, 44, 83, 181, 255,
|
||||||
|
23, 25, 31, 44, 72, 136, 255, 255,
|
||||||
|
44, 47, 58, 83, 136, 255, 255, 255,
|
||||||
|
95, 102, 127, 181, 255, 255, 255, 255,
|
||||||
|
241, 255, 255, 255, 255, 255, 255, 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
|
||||||
|
*/
|
||||||
|
15, 11, 11, 12, 15, 19, 25, 32,
|
||||||
|
11, 13, 10, 10, 12, 15, 19, 24,
|
||||||
|
11, 10, 14, 14, 16, 18, 22, 27,
|
||||||
|
12, 10, 14, 18, 21, 24, 28, 33,
|
||||||
|
15, 12, 16, 21, 26, 31, 36, 42,
|
||||||
|
19, 15, 18, 24, 31, 38, 45, 53,
|
||||||
|
25, 19, 22, 28, 36, 45, 55, 65,
|
||||||
|
32, 24, 27, 33, 42, 53, 65, 77
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
|
||||||
|
*/
|
||||||
|
14, 10, 11, 14, 19, 25, 34, 45,
|
||||||
|
10, 11, 11, 12, 15, 20, 26, 33,
|
||||||
|
11, 11, 15, 18, 21, 25, 31, 38,
|
||||||
|
14, 12, 18, 24, 28, 33, 39, 47,
|
||||||
|
19, 15, 21, 28, 36, 43, 51, 59,
|
||||||
|
25, 20, 25, 33, 43, 54, 64, 74,
|
||||||
|
34, 26, 31, 39, 51, 64, 77, 91,
|
||||||
|
45, 33, 38, 47, 59, 74, 91, 108
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
|
||||||
|
static const unsigned int std_chrominance_quant_tbl[9][DCTSIZE2] = {
|
||||||
|
{
|
||||||
|
/* JPEG Annex K
|
||||||
|
*/
|
||||||
17, 18, 24, 47, 99, 99, 99, 99,
|
17, 18, 24, 47, 99, 99, 99, 99,
|
||||||
18, 21, 26, 66, 99, 99, 99, 99,
|
18, 21, 26, 66, 99, 99, 99, 99,
|
||||||
24, 26, 56, 99, 99, 99, 99, 99,
|
24, 26, 56, 99, 99, 99, 99, 99,
|
||||||
@@ -88,29 +190,125 @@ static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
|
|||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
99, 99, 99, 99, 99, 99, 99, 99,
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
99, 99, 99, 99, 99, 99, 99, 99
|
99, 99, 99, 99, 99, 99, 99, 99
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* flat
|
||||||
|
*/
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16
|
||||||
|
},
|
||||||
|
{
|
||||||
|
8, 12, 15, 15, 86, 96, 96, 98,
|
||||||
|
13, 13, 15, 26, 90, 96, 99, 98,
|
||||||
|
12, 15, 18, 96, 99, 99, 99, 99,
|
||||||
|
17, 16, 90, 96, 99, 99, 99, 99,
|
||||||
|
96, 96, 99, 99, 99, 99, 99, 99,
|
||||||
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
|
99, 99, 99, 99, 99, 99, 99, 99
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* From http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
|
||||||
|
*/
|
||||||
|
16, 16, 16, 18, 25, 37, 56, 85,
|
||||||
|
16, 17, 20, 27, 34, 40, 53, 75,
|
||||||
|
16, 20, 24, 31, 43, 62, 91, 135,
|
||||||
|
18, 27, 31, 40, 53, 74, 106, 156,
|
||||||
|
25, 34, 43, 53, 69, 94, 131, 189,
|
||||||
|
37, 40, 62, 74, 94, 124, 169, 238,
|
||||||
|
56, 53, 91, 106, 131, 169, 226, 311,
|
||||||
|
85, 75, 135, 156, 189, 238, 311, 418
|
||||||
|
},
|
||||||
|
{
|
||||||
|
9, 10, 17, 19, 62, 89, 91, 97,
|
||||||
|
12, 13, 18, 29, 84, 91, 88, 98,
|
||||||
|
14, 19, 29, 93, 95, 95, 98, 97,
|
||||||
|
20, 26, 84, 88, 95, 95, 98, 94,
|
||||||
|
26, 86, 91, 93, 97, 99, 98, 99,
|
||||||
|
99, 100, 98, 99, 99, 99, 99, 99,
|
||||||
|
99, 99, 99, 99, 99, 99, 99, 99,
|
||||||
|
97, 97, 99, 99, 99, 99, 97, 99
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* Relevance of human vision to JPEG-DCT compression (1992) Klein, Silverstein and Carney.
|
||||||
|
* Copied from luma
|
||||||
|
*/
|
||||||
|
10, 12, 14, 19, 26, 38, 57, 86,
|
||||||
|
12, 18, 21, 28, 35, 41, 54, 76,
|
||||||
|
14, 21, 25, 32, 44, 63, 92, 136,
|
||||||
|
19, 28, 32, 41, 54, 75, 107, 157,
|
||||||
|
26, 35, 44, 54, 70, 95, 132, 190,
|
||||||
|
38, 41, 63, 75, 95, 125, 170, 239,
|
||||||
|
57, 54, 92, 107, 132, 170, 227, 312,
|
||||||
|
86, 76, 136, 157, 190, 239, 312, 419
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* DCTune perceptual optimization of compressed dental X-Rays (1997) Watson, Taylor, Borthwick
|
||||||
|
* Copied from luma
|
||||||
|
*/
|
||||||
|
7, 8, 10, 14, 23, 44, 95, 241,
|
||||||
|
8, 8, 11, 15, 25, 47, 102, 255,
|
||||||
|
10, 11, 13, 19, 31, 58, 127, 255,
|
||||||
|
14, 15, 19, 27, 44, 83, 181, 255,
|
||||||
|
23, 25, 31, 44, 72, 136, 255, 255,
|
||||||
|
44, 47, 58, 83, 136, 255, 255, 255,
|
||||||
|
95, 102, 127, 181, 255, 255, 255, 255,
|
||||||
|
241, 255, 255, 255, 255, 255, 255, 255
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* A visual detection model for DCT coefficient quantization (12/9/93) Ahumada, Watson, Peterson
|
||||||
|
* Copied from luma
|
||||||
|
*/
|
||||||
|
15, 11, 11, 12, 15, 19, 25, 32,
|
||||||
|
11, 13, 10, 10, 12, 15, 19, 24,
|
||||||
|
11, 10, 14, 14, 16, 18, 22, 27,
|
||||||
|
12, 10, 14, 18, 21, 24, 28, 33,
|
||||||
|
15, 12, 16, 21, 26, 31, 36, 42,
|
||||||
|
19, 15, 18, 24, 31, 38, 45, 53,
|
||||||
|
25, 19, 22, 28, 36, 45, 55, 65,
|
||||||
|
32, 24, 27, 33, 42, 53, 65, 77
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* An improved detection model for DCT coefficient quantization (1993) Peterson, Ahumada and Watson
|
||||||
|
* Copied from luma
|
||||||
|
*/
|
||||||
|
14, 10, 11, 14, 19, 25, 34, 45,
|
||||||
|
10, 11, 11, 12, 15, 20, 26, 33,
|
||||||
|
11, 11, 15, 18, 21, 25, 31, 38,
|
||||||
|
14, 12, 18, 24, 28, 33, 39, 47,
|
||||||
|
19, 15, 21, 28, 36, 43, 51, 59,
|
||||||
|
25, 20, 25, 33, 43, 54, 64, 74,
|
||||||
|
34, 26, 31, 39, 51, 64, 77, 91,
|
||||||
|
45, 33, 38, 47, 59, 74, 91, 108
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_default_qtables(j_compress_ptr cinfo, boolean force_baseline)
|
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
|
||||||
/* Set or change the 'quality' (quantization) setting, using default tables
|
/* Set or change the 'quality' (quantization) setting, using default tables
|
||||||
* and straight percentage-scaling quality scales.
|
* and straight percentage-scaling quality scales.
|
||||||
* This entry point allows different scalings for luminance and chrominance.
|
* This entry point allows different scalings for luminance and chrominance.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Set up two quantization tables using the specified scaling */
|
/* Set up two quantization tables using the specified scaling */
|
||||||
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl[cinfo->master->quant_tbl_master_idx],
|
||||||
cinfo->q_scale_factor[0], force_baseline);
|
cinfo->q_scale_factor[0], force_baseline);
|
||||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl[cinfo->master->quant_tbl_master_idx],
|
||||||
cinfo->q_scale_factor[1], force_baseline);
|
cinfo->q_scale_factor[1], force_baseline);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||||
boolean force_baseline)
|
boolean force_baseline)
|
||||||
/* Set or change the 'quality' (quantization) setting, using default tables
|
/* Set or change the 'quality' (quantization) setting, using default tables
|
||||||
* and a straight percentage-scaling quality scale. In most cases it's better
|
* and a straight percentage-scaling quality scale. In most cases it's better
|
||||||
* to use jpeg_set_quality (below); this entry point is provided for
|
* to use jpeg_set_quality (below); this entry point is provided for
|
||||||
@@ -118,23 +316,29 @@ jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Set up two quantization tables using the specified scaling */
|
/* Set up two quantization tables using the specified scaling */
|
||||||
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl[cinfo->master->quant_tbl_master_idx],
|
||||||
scale_factor, force_baseline);
|
scale_factor, force_baseline);
|
||||||
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
|
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl[cinfo->master->quant_tbl_master_idx],
|
||||||
scale_factor, force_baseline);
|
scale_factor, force_baseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(int)
|
GLOBAL(int)
|
||||||
jpeg_quality_scaling(int quality)
|
jpeg_quality_scaling (int quality)
|
||||||
|
{
|
||||||
|
return jpeg_float_quality_scaling(quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
GLOBAL(float)
|
||||||
|
jpeg_float_quality_scaling(float quality)
|
||||||
/* Convert a user-specified quality rating to a percentage scaling factor
|
/* Convert a user-specified quality rating to a percentage scaling factor
|
||||||
* for an underlying quantization table, using our recommended scaling curve.
|
* for an underlying quantization table, using our recommended scaling curve.
|
||||||
* The input 'quality' factor should be 0 (terrible) to 100 (very good).
|
* The input 'quality' factor should be 0 (terrible) to 100 (very good).
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */
|
/* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */
|
||||||
if (quality <= 0) quality = 1;
|
if (quality <= 0.f) quality = 1.f;
|
||||||
if (quality > 100) quality = 100;
|
if (quality > 100.f) quality = 100.f;
|
||||||
|
|
||||||
/* The basic table is used as-is (scaling 100) for a quality of 50.
|
/* The basic table is used as-is (scaling 100) for a quality of 50.
|
||||||
* Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
|
* Qualities 50..100 are converted to scaling percentage 200 - 2*Q;
|
||||||
@@ -142,17 +346,17 @@ jpeg_quality_scaling(int quality)
|
|||||||
* to make all the table entries 1 (hence, minimum quantization loss).
|
* to make all the table entries 1 (hence, minimum quantization loss).
|
||||||
* Qualities 1..50 are converted to scaling percentage 5000/Q.
|
* Qualities 1..50 are converted to scaling percentage 5000/Q.
|
||||||
*/
|
*/
|
||||||
if (quality < 50)
|
if (quality < 50.f)
|
||||||
quality = 5000 / quality;
|
quality = 5000.f / quality;
|
||||||
else
|
else
|
||||||
quality = 200 - quality * 2;
|
quality = 200.f - quality*2.f;
|
||||||
|
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
|
jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
||||||
/* Set or change the 'quality' (quantization) setting, using default tables.
|
/* Set or change the 'quality' (quantization) setting, using default tables.
|
||||||
* This is the standard quality-adjusting entry point for typical user
|
* This is the standard quality-adjusting entry point for typical user
|
||||||
* interfaces; only those who want detailed control over quantization tables
|
* interfaces; only those who want detailed control over quantization tables
|
||||||
@@ -178,7 +382,7 @@ jpeg_set_quality(j_compress_ptr cinfo, int quality, boolean force_baseline)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_set_defaults(j_compress_ptr cinfo)
|
jpeg_set_defaults (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -192,7 +396,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
if (cinfo->comp_info == NULL)
|
if (cinfo->comp_info == NULL)
|
||||||
cinfo->comp_info = (jpeg_component_info *)
|
cinfo->comp_info = (jpeg_component_info *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
MAX_COMPONENTS * sizeof(jpeg_component_info));
|
MAX_COMPONENTS * sizeof(jpeg_component_info));
|
||||||
|
|
||||||
/* Initialize everything not dependent on the color space */
|
/* Initialize everything not dependent on the color space */
|
||||||
@@ -205,7 +409,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
/* Set up two quantization tables using default quality of 75 */
|
/* Set up two quantization tables using default quality of 75 */
|
||||||
jpeg_set_quality(cinfo, 75, TRUE);
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
/* Set up two Huffman tables */
|
/* Set up two Huffman tables */
|
||||||
std_huff_tables((j_common_ptr)cinfo);
|
std_huff_tables((j_common_ptr) cinfo);
|
||||||
|
|
||||||
/* Initialize default arithmetic coding conditioning */
|
/* Initialize default arithmetic coding conditioning */
|
||||||
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
||||||
@@ -224,8 +428,18 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
/* Use Huffman coding, not arithmetic coding, by default */
|
/* Use Huffman coding, not arithmetic coding, by default */
|
||||||
cinfo->arith_code = FALSE;
|
cinfo->arith_code = FALSE;
|
||||||
|
|
||||||
|
#ifdef ENTROPY_OPT_SUPPORTED
|
||||||
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION)
|
||||||
|
/* By default, do extra passes to optimize entropy coding */
|
||||||
|
cinfo->optimize_coding = TRUE;
|
||||||
|
else
|
||||||
/* By default, don't do extra passes to optimize entropy coding */
|
/* By default, don't do extra passes to optimize entropy coding */
|
||||||
cinfo->optimize_coding = FALSE;
|
cinfo->optimize_coding = FALSE;
|
||||||
|
#else
|
||||||
|
/* By default, don't do extra passes to optimize entropy coding */
|
||||||
|
cinfo->optimize_coding = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The standard Huffman tables are only valid for 8-bit data precision.
|
/* The standard Huffman tables are only valid for 8-bit data precision.
|
||||||
* If the precision is higher, force optimization on so that usable
|
* If the precision is higher, force optimization on so that usable
|
||||||
* tables will be computed. This test can be removed if default tables
|
* tables will be computed. This test can be removed if default tables
|
||||||
@@ -242,6 +456,9 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
cinfo->do_fancy_downsampling = TRUE;
|
cinfo->do_fancy_downsampling = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cinfo->master->overshoot_deringing =
|
||||||
|
cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
|
||||||
|
|
||||||
/* No input smoothing */
|
/* No input smoothing */
|
||||||
cinfo->smoothing_factor = 0;
|
cinfo->smoothing_factor = 0;
|
||||||
|
|
||||||
@@ -270,6 +487,31 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
/* Choose JPEG colorspace based on input space, set defaults accordingly */
|
/* Choose JPEG colorspace based on input space, set defaults accordingly */
|
||||||
|
|
||||||
jpeg_default_colorspace(cinfo);
|
jpeg_default_colorspace(cinfo);
|
||||||
|
|
||||||
|
cinfo->master->dc_scan_opt_mode = 1;
|
||||||
|
|
||||||
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
|
cinfo->master->optimize_scans = TRUE;
|
||||||
|
jpeg_simple_progression(cinfo);
|
||||||
|
} else
|
||||||
|
cinfo->master->optimize_scans = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cinfo->master->trellis_quant =
|
||||||
|
cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
|
||||||
|
cinfo->master->lambda_log_scale1 = 14.75;
|
||||||
|
cinfo->master->lambda_log_scale2 = 16.5;
|
||||||
|
cinfo->master->quant_tbl_master_idx =
|
||||||
|
cinfo->master->compress_profile == JCP_MAX_COMPRESSION ? 3 : 0;
|
||||||
|
|
||||||
|
cinfo->master->use_lambda_weight_tbl = TRUE;
|
||||||
|
cinfo->master->use_scans_in_trellis = FALSE;
|
||||||
|
cinfo->master->trellis_freq_split = 8;
|
||||||
|
cinfo->master->trellis_num_loops = 1;
|
||||||
|
cinfo->master->trellis_q_opt = FALSE;
|
||||||
|
cinfo->master->trellis_quant_dc = TRUE;
|
||||||
|
cinfo->master->trellis_delta_dc_weight = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,7 +520,7 @@ jpeg_set_defaults(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_default_colorspace(j_compress_ptr cinfo)
|
jpeg_default_colorspace (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
switch (cinfo->in_color_space) {
|
switch (cinfo->in_color_space) {
|
||||||
case JCS_GRAYSCALE:
|
case JCS_GRAYSCALE:
|
||||||
@@ -320,12 +562,12 @@ jpeg_default_colorspace(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
||||||
{
|
{
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
int ci;
|
int ci;
|
||||||
|
|
||||||
#define SET_COMP(index, id, hsamp, vsamp, quant, dctbl, actbl) \
|
#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \
|
||||||
(compptr = &cinfo->comp_info[index], \
|
(compptr = &cinfo->comp_info[index], \
|
||||||
compptr->component_id = (id), \
|
compptr->component_id = (id), \
|
||||||
compptr->h_samp_factor = (hsamp), \
|
compptr->h_samp_factor = (hsamp), \
|
||||||
@@ -352,39 +594,39 @@ jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
cinfo->num_components = 1;
|
cinfo->num_components = 1;
|
||||||
/* JFIF specifies component ID 1 */
|
/* JFIF specifies component ID 1 */
|
||||||
SET_COMP(0, 1, 1, 1, 0, 0, 0);
|
SET_COMP(0, 1, 1,1, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_RGB:
|
case JCS_RGB:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
SET_COMP(0, 0x52 /* 'R' */, 1, 1, 0, 0, 0);
|
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(1, 0x47 /* 'G' */, 1, 1, 0, 0, 0);
|
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(2, 0x42 /* 'B' */, 1, 1, 0, 0, 0);
|
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_YCbCr:
|
case JCS_YCbCr:
|
||||||
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
|
||||||
cinfo->num_components = 3;
|
cinfo->num_components = 3;
|
||||||
/* JFIF specifies component IDs 1,2,3 */
|
/* JFIF specifies component IDs 1,2,3 */
|
||||||
/* We default to 2x2 subsamples of chrominance */
|
/* We default to 2x2 subsamples of chrominance */
|
||||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||||
break;
|
break;
|
||||||
case JCS_CMYK:
|
case JCS_CMYK:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
|
||||||
cinfo->num_components = 4;
|
cinfo->num_components = 4;
|
||||||
SET_COMP(0, 0x43 /* 'C' */, 1, 1, 0, 0, 0);
|
SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(1, 0x4D /* 'M' */, 1, 1, 0, 0, 0);
|
SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(2, 0x59 /* 'Y' */, 1, 1, 0, 0, 0);
|
SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0);
|
||||||
SET_COMP(3, 0x4B /* 'K' */, 1, 1, 0, 0, 0);
|
SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_YCCK:
|
case JCS_YCCK:
|
||||||
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
|
||||||
cinfo->num_components = 4;
|
cinfo->num_components = 4;
|
||||||
SET_COMP(0, 1, 2, 2, 0, 0, 0);
|
SET_COMP(0, 1, 2,2, 0, 0,0);
|
||||||
SET_COMP(1, 2, 1, 1, 1, 1, 1);
|
SET_COMP(1, 2, 1,1, 1, 1,1);
|
||||||
SET_COMP(2, 3, 1, 1, 1, 1, 1);
|
SET_COMP(2, 3, 1,1, 1, 1,1);
|
||||||
SET_COMP(3, 4, 2, 2, 0, 0, 0);
|
SET_COMP(3, 4, 2,2, 0, 0,0);
|
||||||
break;
|
break;
|
||||||
case JCS_UNKNOWN:
|
case JCS_UNKNOWN:
|
||||||
cinfo->num_components = cinfo->input_components;
|
cinfo->num_components = cinfo->input_components;
|
||||||
@@ -392,7 +634,7 @@ jpeg_set_colorspace(j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
|
|||||||
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
|
||||||
MAX_COMPONENTS);
|
MAX_COMPONENTS);
|
||||||
for (ci = 0; ci < cinfo->num_components; ci++) {
|
for (ci = 0; ci < cinfo->num_components; ci++) {
|
||||||
SET_COMP(ci, ci, 1, 1, 0, 0, 0);
|
SET_COMP(ci, ci, 1,1, 0, 0,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -418,7 +660,24 @@ fill_a_scan(jpeg_scan_info *scanptr, int ci, int Ss, int Se, int Ah, int Al)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOCAL(jpeg_scan_info *)
|
LOCAL(jpeg_scan_info *)
|
||||||
fill_scans(jpeg_scan_info *scanptr, int ncomps, int Ss, int Se, int Ah, int Al)
|
fill_a_scan_pair (jpeg_scan_info * scanptr, int ci,
|
||||||
|
int Ss, int Se, int Ah, int Al)
|
||||||
|
/* Support routine: generate one scan for pair of components */
|
||||||
|
{
|
||||||
|
scanptr->comps_in_scan = 2;
|
||||||
|
scanptr->component_index[0] = ci;
|
||||||
|
scanptr->component_index[1] = ci + 1;
|
||||||
|
scanptr->Ss = Ss;
|
||||||
|
scanptr->Se = Se;
|
||||||
|
scanptr->Ah = Ah;
|
||||||
|
scanptr->Al = Al;
|
||||||
|
scanptr++;
|
||||||
|
return scanptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL(jpeg_scan_info *)
|
||||||
|
fill_scans (jpeg_scan_info *scanptr, int ncomps,
|
||||||
|
int Ss, int Se, int Ah, int Al)
|
||||||
/* Support routine: generate one scan for each component */
|
/* Support routine: generate one scan for each component */
|
||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
@@ -436,7 +695,7 @@ fill_scans(jpeg_scan_info *scanptr, int ncomps, int Ss, int Se, int Ah, int Al)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOCAL(jpeg_scan_info *)
|
LOCAL(jpeg_scan_info *)
|
||||||
fill_dc_scans(jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
fill_dc_scans (jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
||||||
/* Support routine: generate interleaved DC scan if possible, else N scans */
|
/* Support routine: generate interleaved DC scan if possible, else N scans */
|
||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
@@ -458,33 +717,182 @@ fill_dc_scans(jpeg_scan_info *scanptr, int ncomps, int Ah, int Al)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of scans to be tested
|
||||||
|
* cinfo->num_components and cinfo->jpeg_color_space must be correct.
|
||||||
|
*/
|
||||||
|
|
||||||
|
LOCAL(boolean)
|
||||||
|
jpeg_search_progression (j_compress_ptr cinfo)
|
||||||
|
{
|
||||||
|
int ncomps = cinfo->num_components;
|
||||||
|
int nscans;
|
||||||
|
jpeg_scan_info * scanptr;
|
||||||
|
int Al;
|
||||||
|
int frequency_split[] = { 2, 8, 5, 12, 18 };
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Safety check to ensure start_compress not called yet. */
|
||||||
|
if (cinfo->global_state != CSTATE_START)
|
||||||
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
|
|
||||||
|
/* Figure space needed for script. Calculation must match code below! */
|
||||||
|
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||||
|
/* Custom script for YCbCr color images. */
|
||||||
|
nscans = 64;
|
||||||
|
} else if (ncomps == 1) {
|
||||||
|
nscans = 23;
|
||||||
|
} else {
|
||||||
|
cinfo->master->num_scans_luma = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate space for script.
|
||||||
|
* We need to put it in the permanent pool in case the application performs
|
||||||
|
* multiple compressions without changing the settings. To avoid a memory
|
||||||
|
* leak if jpeg_simple_progression is called repeatedly for the same JPEG
|
||||||
|
* object, we try to re-use previously allocated space, and we allocate
|
||||||
|
* enough space to handle YCbCr even if initially asked for grayscale.
|
||||||
|
*/
|
||||||
|
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||||
|
cinfo->script_space_size = MAX(nscans, 64);
|
||||||
|
cinfo->script_space = (jpeg_scan_info *)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
|
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||||
|
}
|
||||||
|
scanptr = cinfo->script_space;
|
||||||
|
cinfo->scan_info = scanptr;
|
||||||
|
cinfo->num_scans = nscans;
|
||||||
|
|
||||||
|
cinfo->master->Al_max_luma = 3;
|
||||||
|
cinfo->master->num_scans_luma_dc = 1;
|
||||||
|
cinfo->master->num_frequency_splits = 5;
|
||||||
|
cinfo->master->num_scans_luma =
|
||||||
|
cinfo->master->num_scans_luma_dc + (3 * cinfo->master->Al_max_luma + 2) +
|
||||||
|
(2 * cinfo->master->num_frequency_splits + 1);
|
||||||
|
|
||||||
|
/* 23 scans for luma */
|
||||||
|
/* 1 scan for DC */
|
||||||
|
/* 11 scans to determine successive approximation */
|
||||||
|
/* 11 scans to determine frequency approximation */
|
||||||
|
/* after 12 scans need to update following 11 */
|
||||||
|
/* after 23 scans need to determine which to keep */
|
||||||
|
/* last 4 done conditionally */
|
||||||
|
|
||||||
|
/* luma DC by itself */
|
||||||
|
if (cinfo->master->dc_scan_opt_mode == 0)
|
||||||
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
|
||||||
|
else
|
||||||
|
scanptr = fill_dc_scans(scanptr, 1, 0, 0);
|
||||||
|
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, 0);
|
||||||
|
|
||||||
|
for (Al = 0; Al < cinfo->master->Al_max_luma; Al++) {
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, Al+1, Al);
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, Al+1);
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, Al+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 0, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < cinfo->master->num_frequency_splits; i++) {
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, frequency_split[i], 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, frequency_split[i]+1, 63, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ncomps == 1) {
|
||||||
|
cinfo->master->Al_max_chroma = 0;
|
||||||
|
cinfo->master->num_scans_chroma_dc = 0;
|
||||||
|
} else {
|
||||||
|
cinfo->master->Al_max_chroma = 2;
|
||||||
|
cinfo->master->num_scans_chroma_dc = 3;
|
||||||
|
/* 41 scans for chroma */
|
||||||
|
|
||||||
|
/* chroma DC combined */
|
||||||
|
scanptr = fill_a_scan_pair(scanptr, 1, 0, 0, 0, 0);
|
||||||
|
/* chroma DC separate */
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 0, 0, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
|
||||||
|
|
||||||
|
for (Al = 0; Al < cinfo->master->Al_max_chroma; Al++) {
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, 63, Al+1, Al);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, 63, Al+1, Al);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, Al+1);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, Al+1);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, Al+1);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, Al+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 0);
|
||||||
|
|
||||||
|
for (i = 0; i < cinfo->master->num_frequency_splits; i++) {
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, frequency_split[i], 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, frequency_split[i]+1, 63, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, frequency_split[i], 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, frequency_split[i]+1, 63, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a recommended progressive-JPEG script.
|
* Create a recommended progressive-JPEG script.
|
||||||
* cinfo->num_components and cinfo->jpeg_color_space must be correct.
|
* cinfo->num_components and cinfo->jpeg_color_space must be correct.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_simple_progression(j_compress_ptr cinfo)
|
jpeg_simple_progression (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
int ncomps = cinfo->num_components;
|
int ncomps;
|
||||||
int nscans;
|
int nscans;
|
||||||
jpeg_scan_info *scanptr;
|
jpeg_scan_info *scanptr;
|
||||||
|
|
||||||
|
if (cinfo->master->optimize_scans) {
|
||||||
|
if (jpeg_search_progression(cinfo) == TRUE)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Safety check to ensure start_compress not called yet. */
|
/* Safety check to ensure start_compress not called yet. */
|
||||||
if (cinfo->global_state != CSTATE_START)
|
if (cinfo->global_state != CSTATE_START)
|
||||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
|
|
||||||
/* Figure space needed for script. Calculation must match code below! */
|
/* Figure space needed for script. Calculation must match code below! */
|
||||||
|
ncomps = cinfo->num_components;
|
||||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||||
/* Custom script for YCbCr color images. */
|
/* Custom script for YCbCr color images. */
|
||||||
nscans = 10;
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
|
if (cinfo->master->dc_scan_opt_mode == 0) {
|
||||||
|
nscans = 9; /* 1 DC scan for all components */
|
||||||
|
} else if (cinfo->master->dc_scan_opt_mode == 1) {
|
||||||
|
nscans = 11; /* 1 DC scan for each component */
|
||||||
|
} else {
|
||||||
|
nscans = 10; /* 1 DC scan for luminance and 1 DC scan for chroma */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nscans = 10; /* 2 DC scans and 8 AC scans */
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
if (ncomps > MAX_COMPS_IN_SCAN)
|
if (ncomps > MAX_COMPS_IN_SCAN)
|
||||||
|
nscans = 5 * ncomps; /* 2 DC + 4 AC scans per component */
|
||||||
|
else
|
||||||
|
nscans = 1 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
||||||
|
} else {
|
||||||
|
if (ncomps > MAX_COMPS_IN_SCAN)
|
||||||
nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
|
nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */
|
||||||
else
|
else
|
||||||
nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate space for script.
|
/* Allocate space for script.
|
||||||
* We need to put it in the permanent pool in case the application performs
|
* We need to put it in the permanent pool in case the application performs
|
||||||
@@ -496,7 +904,7 @@ jpeg_simple_progression(j_compress_ptr cinfo)
|
|||||||
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
|
||||||
cinfo->script_space_size = MAX(nscans, 10);
|
cinfo->script_space_size = MAX(nscans, 10);
|
||||||
cinfo->script_space = (jpeg_scan_info *)
|
cinfo->script_space = (jpeg_scan_info *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
cinfo->script_space_size * sizeof(jpeg_scan_info));
|
||||||
}
|
}
|
||||||
scanptr = cinfo->script_space;
|
scanptr = cinfo->script_space;
|
||||||
@@ -505,6 +913,35 @@ jpeg_simple_progression(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||||
/* Custom script for YCbCr color images. */
|
/* Custom script for YCbCr color images. */
|
||||||
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
|
/* scan defined in jpeg_scan_rgb.txt in jpgcrush */
|
||||||
|
/* Initial DC scan */
|
||||||
|
if (cinfo->master->dc_scan_opt_mode == 0) {
|
||||||
|
/* 1 DC scan for all components */
|
||||||
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
|
||||||
|
} else if (cinfo->master->dc_scan_opt_mode == 1) {
|
||||||
|
/* 1 DC scan for each component */
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 0, 0, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 0, 0, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 0, 0, 0, 0);
|
||||||
|
} else {
|
||||||
|
/* 1 DC scan for luminance and 1 DC scan for chroma */
|
||||||
|
scanptr = fill_dc_scans(scanptr, 1, 0, 0);
|
||||||
|
scanptr = fill_a_scan_pair(scanptr, 1, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
/* Low frequency AC scans */
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 8, 0, 2);
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 1, 8, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 1, 8, 0, 0);
|
||||||
|
/* Complete spectral selection for luma AC */
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 9, 63, 0, 2);
|
||||||
|
/* Finish luma AC successive approximation */
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1);
|
||||||
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
|
||||||
|
/* Complete spectral selection for chroma AC */
|
||||||
|
scanptr = fill_a_scan(scanptr, 1, 9, 63, 0, 0);
|
||||||
|
scanptr = fill_a_scan(scanptr, 2, 9, 63, 0, 0);
|
||||||
|
} else {
|
||||||
/* Initial DC scan */
|
/* Initial DC scan */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||||
/* Initial AC scan: get some luma data out in a hurry */
|
/* Initial AC scan: get some luma data out in a hurry */
|
||||||
@@ -523,9 +960,22 @@ jpeg_simple_progression(j_compress_ptr cinfo)
|
|||||||
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
|
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
|
||||||
/* Luma bottom bit comes last since it's usually largest scan */
|
/* Luma bottom bit comes last since it's usually largest scan */
|
||||||
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
|
scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* All-purpose script for other color spaces. */
|
/* All-purpose script for other color spaces. */
|
||||||
|
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
|
||||||
|
/* scan defined in jpeg_scan_bw.txt in jpgcrush */
|
||||||
|
/* DC component, no successive approximation */
|
||||||
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
|
||||||
/* Successive approximation first pass */
|
/* Successive approximation first pass */
|
||||||
|
scanptr = fill_scans(scanptr, ncomps, 1, 8, 0, 2);
|
||||||
|
scanptr = fill_scans(scanptr, ncomps, 9, 63, 0, 2);
|
||||||
|
/* Successive approximation second pass */
|
||||||
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
|
||||||
|
/* Successive approximation final pass */
|
||||||
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
||||||
|
} else {
|
||||||
|
/* Successive approximation first pass */
|
||||||
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2);
|
||||||
scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
|
scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2);
|
||||||
@@ -536,5 +986,6 @@ jpeg_simple_progression(j_compress_ptr cinfo)
|
|||||||
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* C_PROGRESSIVE_SUPPORTED */
|
#endif /* C_PROGRESSIVE_SUPPORTED */
|
||||||
|
|||||||
135
jcphuff.c
135
jcphuff.c
@@ -6,6 +6,7 @@
|
|||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2011, 2015, 2018, D. R. Commander.
|
* Copyright (C) 2011, 2015, 2018, D. R. Commander.
|
||||||
* Copyright (C) 2016, 2018, Matthieu Darbois.
|
* Copyright (C) 2016, 2018, Matthieu Darbois.
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -52,8 +53,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* NOTE: Both GCC and Clang define __GNUC__ */
|
/* NOTE: Both GCC and Clang define __GNUC__ */
|
||||||
#if defined __GNUC__ && (defined __arm__ || defined __aarch64__)
|
#if defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
|
||||||
#if !defined __thumb__ || defined __thumb2__
|
#if !defined(__thumb__) || defined(__thumb2__)
|
||||||
#define USE_CLZ_INTRINSIC
|
#define USE_CLZ_INTRINSIC
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -134,34 +135,34 @@ typedef phuff_entropy_encoder *phuff_entropy_ptr;
|
|||||||
|
|
||||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||||
#define ISHIFT_TEMPS int ishift_temp;
|
#define ISHIFT_TEMPS int ishift_temp;
|
||||||
#define IRIGHT_SHIFT(x, shft) \
|
#define IRIGHT_SHIFT(x,shft) \
|
||||||
((ishift_temp = (x)) < 0 ? \
|
((ishift_temp = (x)) < 0 ? \
|
||||||
(ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
|
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
|
||||||
(ishift_temp >> (shft)))
|
(ishift_temp >> (shft)))
|
||||||
#else
|
#else
|
||||||
#define ISHIFT_TEMPS
|
#define ISHIFT_TEMPS
|
||||||
#define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
|
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
|
#define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
|
METHODDEF(boolean) encode_mcu_DC_first (j_compress_ptr cinfo,
|
||||||
JBLOCKROW *MCU_data);
|
JBLOCKROW *MCU_data);
|
||||||
METHODDEF(void) encode_mcu_AC_first_prepare
|
METHODDEF(void) encode_mcu_AC_first_prepare
|
||||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||||
JCOEF *values, size_t *zerobits);
|
JCOEF *values, size_t *zerobits);
|
||||||
METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
|
METHODDEF(boolean) encode_mcu_AC_first (j_compress_ptr cinfo,
|
||||||
JBLOCKROW *MCU_data);
|
|
||||||
METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
|
|
||||||
JBLOCKROW *MCU_data);
|
JBLOCKROW *MCU_data);
|
||||||
|
METHODDEF(boolean) encode_mcu_DC_refine (j_compress_ptr cinfo,
|
||||||
|
JBLOCKROW *MCU_data);
|
||||||
METHODDEF(int) encode_mcu_AC_refine_prepare
|
METHODDEF(int) encode_mcu_AC_refine_prepare
|
||||||
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
(const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
|
||||||
JCOEF *absvalues, size_t *bits);
|
JCOEF *absvalues, size_t *bits);
|
||||||
METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
|
METHODDEF(boolean) encode_mcu_AC_refine (j_compress_ptr cinfo,
|
||||||
JBLOCKROW *MCU_data);
|
JBLOCKROW *MCU_data);
|
||||||
METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
|
METHODDEF(void) finish_pass_phuff (j_compress_ptr cinfo);
|
||||||
METHODDEF(void) finish_pass_gather_phuff(j_compress_ptr cinfo);
|
METHODDEF(void) finish_pass_gather_phuff (j_compress_ptr cinfo);
|
||||||
|
|
||||||
|
|
||||||
/* Count bit loop zeroes */
|
/* Count bit loop zeroes */
|
||||||
@@ -195,9 +196,9 @@ count_zeroes(size_t *x)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
boolean is_DC_band;
|
boolean is_DC_band;
|
||||||
int ci, tbl;
|
int ci, tbl;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
@@ -231,7 +232,7 @@ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
/* AC refinement needs a correction bit buffer */
|
/* AC refinement needs a correction bit buffer */
|
||||||
if (entropy->bit_buffer == NULL)
|
if (entropy->bit_buffer == NULL)
|
||||||
entropy->bit_buffer = (char *)
|
entropy->bit_buffer = (char *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
MAX_CORR_BITS * sizeof(char));
|
MAX_CORR_BITS * sizeof(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,14 +265,22 @@ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
|
||||||
if (entropy->count_ptrs[tbl] == NULL)
|
if (entropy->count_ptrs[tbl] == NULL)
|
||||||
entropy->count_ptrs[tbl] = (long *)
|
entropy->count_ptrs[tbl] = (long *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
257 * sizeof(long));
|
257 * sizeof(long));
|
||||||
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
|
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
|
||||||
|
if (cinfo->master->trellis_passes) {
|
||||||
|
/* When generating tables for trellis passes, make sure that all */
|
||||||
|
/* codewords have an assigned length */
|
||||||
|
int i, j;
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
for (j = 0; j < 12; j++)
|
||||||
|
entropy->count_ptrs[tbl][16 * i + j] = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Compute derived values for Huffman table */
|
/* Compute derived values for Huffman table */
|
||||||
/* We may do this more than once for a table, but it's not expensive */
|
/* We may do this more than once for a table, but it's not expensive */
|
||||||
jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
|
jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
|
||||||
&entropy->derived_tbls[tbl]);
|
& entropy->derived_tbls[tbl]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,18 +306,18 @@ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
|
|||||||
/* Emit a byte */
|
/* Emit a byte */
|
||||||
#define emit_byte(entropy, val) { \
|
#define emit_byte(entropy, val) { \
|
||||||
*(entropy)->next_output_byte++ = (JOCTET)(val); \
|
*(entropy)->next_output_byte++ = (JOCTET)(val); \
|
||||||
if (--(entropy)->free_in_buffer == 0) \
|
if (--(entropy)->free_in_buffer == 0) \
|
||||||
dump_buffer(entropy); \
|
dump_buffer(entropy); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
dump_buffer(phuff_entropy_ptr entropy)
|
dump_buffer (phuff_entropy_ptr entropy)
|
||||||
/* Empty the output buffer; we do not support suspension in this module. */
|
/* Empty the output buffer; we do not support suspension in this module. */
|
||||||
{
|
{
|
||||||
struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
|
struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
|
||||||
|
|
||||||
if (!(*dest->empty_output_buffer) (entropy->cinfo))
|
if (! (*dest->empty_output_buffer) (entropy->cinfo))
|
||||||
ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
|
ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
|
||||||
/* After a successful buffer dump, must reset buffer pointers */
|
/* After a successful buffer dump, must reset buffer pointers */
|
||||||
entropy->next_output_byte = dest->next_output_byte;
|
entropy->next_output_byte = dest->next_output_byte;
|
||||||
@@ -325,11 +334,11 @@ dump_buffer(phuff_entropy_ptr entropy)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size)
|
||||||
/* Emit some bits, unless we are in gather mode */
|
/* Emit some bits, unless we are in gather mode */
|
||||||
{
|
{
|
||||||
/* This routine is heavily used, so it's worth coding tightly. */
|
/* This routine is heavily used, so it's worth coding tightly. */
|
||||||
register size_t put_buffer = (size_t)code;
|
register size_t put_buffer = (size_t) code;
|
||||||
register int put_bits = entropy->put_bits;
|
register int put_bits = entropy->put_bits;
|
||||||
|
|
||||||
/* if size is 0, caller used an invalid Huffman table entry */
|
/* if size is 0, caller used an invalid Huffman table entry */
|
||||||
@@ -339,7 +348,7 @@ emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
|||||||
if (entropy->gather_statistics)
|
if (entropy->gather_statistics)
|
||||||
return; /* do nothing if we're only getting stats */
|
return; /* do nothing if we're only getting stats */
|
||||||
|
|
||||||
put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
|
put_buffer &= (((size_t) 1)<<size) - 1; /* mask off any extra bits in code */
|
||||||
|
|
||||||
put_bits += size; /* new number of bits in buffer */
|
put_bits += size; /* new number of bits in buffer */
|
||||||
|
|
||||||
@@ -348,7 +357,7 @@ emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
|||||||
put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
|
put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
|
||||||
|
|
||||||
while (put_bits >= 8) {
|
while (put_bits >= 8) {
|
||||||
int c = (int)((put_buffer >> 16) & 0xFF);
|
int c = (int) ((put_buffer >> 16) & 0xFF);
|
||||||
|
|
||||||
emit_byte(entropy, c);
|
emit_byte(entropy, c);
|
||||||
if (c == 0xFF) { /* need to stuff a zero byte? */
|
if (c == 0xFF) { /* need to stuff a zero byte? */
|
||||||
@@ -364,7 +373,7 @@ emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
|
|||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
flush_bits(phuff_entropy_ptr entropy)
|
flush_bits (phuff_entropy_ptr entropy)
|
||||||
{
|
{
|
||||||
emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
|
emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
|
||||||
entropy->put_buffer = 0; /* and reset bit-buffer to empty */
|
entropy->put_buffer = 0; /* and reset bit-buffer to empty */
|
||||||
@@ -377,7 +386,7 @@ flush_bits(phuff_entropy_ptr entropy)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
||||||
{
|
{
|
||||||
if (entropy->gather_statistics)
|
if (entropy->gather_statistics)
|
||||||
entropy->count_ptrs[tbl_no][symbol]++;
|
entropy->count_ptrs[tbl_no][symbol]++;
|
||||||
@@ -393,14 +402,14 @@ emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
|
emit_buffered_bits (phuff_entropy_ptr entropy, char *bufstart,
|
||||||
unsigned int nbits)
|
unsigned int nbits)
|
||||||
{
|
{
|
||||||
if (entropy->gather_statistics)
|
if (entropy->gather_statistics)
|
||||||
return; /* no real work */
|
return; /* no real work */
|
||||||
|
|
||||||
while (nbits > 0) {
|
while (nbits > 0) {
|
||||||
emit_bits(entropy, (unsigned int)(*bufstart), 1);
|
emit_bits(entropy, (unsigned int) (*bufstart), 1);
|
||||||
bufstart++;
|
bufstart++;
|
||||||
nbits--;
|
nbits--;
|
||||||
}
|
}
|
||||||
@@ -412,7 +421,7 @@ emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_eobrun(phuff_entropy_ptr entropy)
|
emit_eobrun (phuff_entropy_ptr entropy)
|
||||||
{
|
{
|
||||||
register int temp, nbits;
|
register int temp, nbits;
|
||||||
|
|
||||||
@@ -441,13 +450,13 @@ emit_eobrun(phuff_entropy_ptr entropy)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
emit_restart(phuff_entropy_ptr entropy, int restart_num)
|
emit_restart (phuff_entropy_ptr entropy, int restart_num)
|
||||||
{
|
{
|
||||||
int ci;
|
int ci;
|
||||||
|
|
||||||
emit_eobrun(entropy);
|
emit_eobrun(entropy);
|
||||||
|
|
||||||
if (!entropy->gather_statistics) {
|
if (! entropy->gather_statistics) {
|
||||||
flush_bits(entropy);
|
flush_bits(entropy);
|
||||||
emit_byte(entropy, 0xFF);
|
emit_byte(entropy, 0xFF);
|
||||||
emit_byte(entropy, JPEG_RST0 + restart_num);
|
emit_byte(entropy, JPEG_RST0 + restart_num);
|
||||||
@@ -471,9 +480,9 @@ emit_restart(phuff_entropy_ptr entropy, int restart_num)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp, temp2, temp3;
|
register int temp, temp2, temp3;
|
||||||
register int nbits;
|
register int nbits;
|
||||||
int blkn, ci;
|
int blkn, ci;
|
||||||
@@ -499,7 +508,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
/* Compute the DC value after the required point transform by Al.
|
/* Compute the DC value after the required point transform by Al.
|
||||||
* This is simply an arithmetic right shift.
|
* This is simply an arithmetic right shift.
|
||||||
*/
|
*/
|
||||||
temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
|
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
|
||||||
|
|
||||||
/* DC differences are figured on the point-transformed values. */
|
/* DC differences are figured on the point-transformed values. */
|
||||||
temp = temp2 - entropy->last_dc_val[ci];
|
temp = temp2 - entropy->last_dc_val[ci];
|
||||||
@@ -515,7 +524,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
|
temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
|
||||||
temp ^= temp3;
|
temp ^= temp3;
|
||||||
temp -= temp3; /* temp is abs value of input */
|
temp -= temp3; /* temp is abs value of input */
|
||||||
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
/* For a negative input, want temp2 = bitwise complement of abs(input) */
|
||||||
temp2 = temp ^ temp3;
|
temp2 = temp ^ temp3;
|
||||||
|
|
||||||
/* Find the number of bits needed for the magnitude of the coefficient */
|
/* Find the number of bits needed for the magnitude of the coefficient */
|
||||||
@@ -523,7 +532,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
/* Check for out-of-range coefficient values.
|
/* Check for out-of-range coefficient values.
|
||||||
* Since we're encoding a difference, the range limit is twice as much.
|
* Since we're encoding a difference, the range limit is twice as much.
|
||||||
*/
|
*/
|
||||||
if (nbits > MAX_COEF_BITS + 1)
|
if (nbits > MAX_COEF_BITS+1)
|
||||||
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
|
|
||||||
/* Count/emit the Huffman-coded symbol for the number of bits */
|
/* Count/emit the Huffman-coded symbol for the number of bits */
|
||||||
@@ -532,7 +541,7 @@ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
/* Emit that number of bits of the value, if positive, */
|
/* Emit that number of bits of the value, if positive, */
|
||||||
/* or the complement of its magnitude, if negative. */
|
/* or the complement of its magnitude, if negative. */
|
||||||
if (nbits) /* emit_bits rejects calls with size 0 */
|
if (nbits) /* emit_bits rejects calls with size 0 */
|
||||||
emit_bits(entropy, (unsigned int)temp2, nbits);
|
emit_bits(entropy, (unsigned int) temp2, nbits);
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||||
@@ -650,9 +659,9 @@ label \
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp, temp2;
|
register int temp, temp2;
|
||||||
register int nbits, r;
|
register int nbits, r;
|
||||||
int Sl = cinfo->Se - cinfo->Ss + 1;
|
int Sl = cinfo->Se - cinfo->Ss + 1;
|
||||||
@@ -687,9 +696,9 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
zerobits |= bits[1];
|
zerobits |= bits[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Emit any pending EOBRUN */
|
/* Emit any pending EOBRUN */
|
||||||
if (zerobits && (entropy->EOBRUN > 0))
|
if (zerobits && (entropy->EOBRUN > 0))
|
||||||
emit_eobrun(entropy);
|
emit_eobrun(entropy);
|
||||||
|
|
||||||
#if SIZEOF_SIZE_T == 4
|
#if SIZEOF_SIZE_T == 4
|
||||||
zerobits = bits[0];
|
zerobits = bits[0];
|
||||||
@@ -742,9 +751,9 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp;
|
register int temp;
|
||||||
int blkn;
|
int blkn;
|
||||||
int Al = cinfo->Al;
|
int Al = cinfo->Al;
|
||||||
@@ -764,7 +773,7 @@ encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
/* We simply emit the Al'th bit of the DC coefficient value. */
|
/* We simply emit the Al'th bit of the DC coefficient value. */
|
||||||
temp = (*block)[0];
|
temp = (*block)[0];
|
||||||
emit_bits(entropy, (unsigned int)(temp >> Al), 1);
|
emit_bits(entropy, (unsigned int) (temp >> Al), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
cinfo->dest->next_output_byte = entropy->next_output_byte;
|
||||||
@@ -914,9 +923,9 @@ label \
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
register int temp, r;
|
register int temp, r;
|
||||||
char *BR_buffer;
|
char *BR_buffer;
|
||||||
unsigned int BR;
|
unsigned int BR;
|
||||||
@@ -974,7 +983,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
r += idx;
|
r += idx;
|
||||||
cabsvalue += idx;
|
cabsvalue += idx;
|
||||||
goto first_iter_ac_refine;
|
goto first_iter_ac_refine;
|
||||||
}
|
}
|
||||||
|
|
||||||
ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
|
ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
|
||||||
#endif
|
#endif
|
||||||
@@ -1015,9 +1024,9 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
finish_pass_phuff(j_compress_ptr cinfo)
|
finish_pass_phuff (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
|
|
||||||
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
entropy->next_output_byte = cinfo->dest->next_output_byte;
|
||||||
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
|
||||||
@@ -1036,9 +1045,9 @@ finish_pass_phuff(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
finish_pass_gather_phuff(j_compress_ptr cinfo)
|
finish_pass_gather_phuff (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
|
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
|
||||||
boolean is_DC_band;
|
boolean is_DC_band;
|
||||||
int ci, tbl;
|
int ci, tbl;
|
||||||
jpeg_component_info *compptr;
|
jpeg_component_info *compptr;
|
||||||
@@ -1064,13 +1073,13 @@ finish_pass_gather_phuff(j_compress_ptr cinfo)
|
|||||||
} else {
|
} else {
|
||||||
tbl = compptr->ac_tbl_no;
|
tbl = compptr->ac_tbl_no;
|
||||||
}
|
}
|
||||||
if (!did[tbl]) {
|
if (! did[tbl]) {
|
||||||
if (is_DC_band)
|
if (is_DC_band)
|
||||||
htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
|
htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
|
||||||
else
|
else
|
||||||
htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
|
htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
|
||||||
if (*htblptr == NULL)
|
if (*htblptr == NULL)
|
||||||
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
|
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
|
||||||
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
|
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
|
||||||
did[tbl] = TRUE;
|
did[tbl] = TRUE;
|
||||||
}
|
}
|
||||||
@@ -1083,15 +1092,15 @@ finish_pass_gather_phuff(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jinit_phuff_encoder(j_compress_ptr cinfo)
|
jinit_phuff_encoder (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
phuff_entropy_ptr entropy;
|
phuff_entropy_ptr entropy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
entropy = (phuff_entropy_ptr)
|
entropy = (phuff_entropy_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
sizeof(phuff_entropy_encoder));
|
sizeof(phuff_entropy_encoder));
|
||||||
cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
|
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
|
||||||
entropy->pub.start_pass = start_pass_phuff;
|
entropy->pub.start_pass = start_pass_phuff;
|
||||||
|
|
||||||
/* Mark tables unallocated */
|
/* Mark tables unallocated */
|
||||||
|
|||||||
12
jcsample.c
12
jcsample.c
@@ -280,7 +280,7 @@ h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
(JSAMPLE)((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
(JSAMPLE)((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
|
||||||
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + bias) >> 2);
|
GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) + bias) >> 2);
|
||||||
bias ^= 3; /* 1=>2, 2=>1 */
|
bias ^= 3; /* 1=>2, 2=>1 */
|
||||||
inptr0 += 2; inptr1 += 2;
|
inptr0 += 2; inptr1 += 2;
|
||||||
}
|
}
|
||||||
inrow += 2;
|
inrow += 2;
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
|
GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
|
||||||
membersum = membersum * memberscale + neighsum * neighscale;
|
membersum = membersum * memberscale + neighsum * neighscale;
|
||||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||||
|
|
||||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||||
/* sum of pixels directly mapped to this output element */
|
/* sum of pixels directly mapped to this output element */
|
||||||
@@ -368,7 +368,7 @@ h2v2_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
membersum = membersum * memberscale + neighsum * neighscale;
|
membersum = membersum * memberscale + neighsum * neighscale;
|
||||||
/* round, descale and output it */
|
/* round, descale and output it */
|
||||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||||
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special case for last column */
|
/* Special case for last column */
|
||||||
@@ -437,17 +437,17 @@ fullsize_smooth_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
neighsum = colsum + (colsum - membersum) + nextcolsum;
|
neighsum = colsum + (colsum - membersum) + nextcolsum;
|
||||||
membersum = membersum * memberscale + neighsum * neighscale;
|
membersum = membersum * memberscale + neighsum * neighscale;
|
||||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||||
lastcolsum = colsum; colsum = nextcolsum;
|
lastcolsum = colsum; colsum = nextcolsum;
|
||||||
|
|
||||||
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
for (colctr = output_cols - 2; colctr > 0; colctr--) {
|
||||||
membersum = GETJSAMPLE(*inptr++);
|
membersum = GETJSAMPLE(*inptr++);
|
||||||
above_ptr++; below_ptr++;
|
above_ptr++; below_ptr++;
|
||||||
nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
|
nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
|
||||||
GETJSAMPLE(*inptr);
|
GETJSAMPLE(*inptr);
|
||||||
neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
|
neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
|
||||||
membersum = membersum * memberscale + neighsum * neighscale;
|
membersum = membersum * memberscale + neighsum * neighscale;
|
||||||
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
*outptr++ = (JSAMPLE)((membersum + 32768) >> 16);
|
||||||
lastcolsum = colsum; colsum = nextcolsum;
|
lastcolsum = colsum; colsum = nextcolsum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special case for last column */
|
/* Special case for last column */
|
||||||
|
|||||||
65
jctrans.c
65
jctrans.c
@@ -6,8 +6,9 @@
|
|||||||
* Modified 2000-2009 by Guido Vollbeding.
|
* Modified 2000-2009 by Guido Vollbeding.
|
||||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||||
* to libjpeg-turbo.
|
* to libjpeg-turbo.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains library routines for transcoding compression,
|
* This file contains library routines for transcoding compression,
|
||||||
* that is, writing raw DCT coefficient arrays to an output JPEG file.
|
* that is, writing raw DCT coefficient arrays to an output JPEG file.
|
||||||
@@ -39,14 +40,18 @@ LOCAL(void) transencode_coef_controller(j_compress_ptr cinfo,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
||||||
{
|
{
|
||||||
|
/* setting up scan optimisation pattern failed, disable scan optimisation */
|
||||||
|
if (cinfo->master->num_scans_luma == 0)
|
||||||
|
cinfo->master->optimize_scans = FALSE;
|
||||||
|
|
||||||
if (cinfo->global_state != CSTATE_START)
|
if (cinfo->global_state != CSTATE_START)
|
||||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
/* Mark all tables to be written */
|
/* Mark all tables to be written */
|
||||||
jpeg_suppress_tables(cinfo, FALSE);
|
jpeg_suppress_tables(cinfo, FALSE);
|
||||||
/* (Re)initialize error mgr and destination modules */
|
/* (Re)initialize error mgr and destination modules */
|
||||||
(*cinfo->err->reset_error_mgr) ((j_common_ptr)cinfo);
|
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
||||||
(*cinfo->dest->init_destination) (cinfo);
|
(*cinfo->dest->init_destination) (cinfo);
|
||||||
/* Perform master selection of active modules */
|
/* Perform master selection of active modules */
|
||||||
transencode_master_selection(cinfo, coef_arrays);
|
transencode_master_selection(cinfo, coef_arrays);
|
||||||
@@ -64,7 +69,7 @@ jpeg_write_coefficients(j_compress_ptr cinfo, jvirt_barray_ptr *coef_arrays)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
jpeg_copy_critical_parameters (const j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
||||||
{
|
{
|
||||||
JQUANT_TBL **qtblptr;
|
JQUANT_TBL **qtblptr;
|
||||||
jpeg_component_info *incomp, *outcomp;
|
jpeg_component_info *incomp, *outcomp;
|
||||||
@@ -87,6 +92,8 @@ jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
|||||||
#endif
|
#endif
|
||||||
/* Initialize all parameters to default values */
|
/* Initialize all parameters to default values */
|
||||||
jpeg_set_defaults(dstinfo);
|
jpeg_set_defaults(dstinfo);
|
||||||
|
dstinfo->master->trellis_quant = FALSE;
|
||||||
|
|
||||||
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
|
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
|
||||||
* Fix it to get the right header markers for the image colorspace.
|
* Fix it to get the right header markers for the image colorspace.
|
||||||
*/
|
*/
|
||||||
@@ -96,9 +103,9 @@ jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
|||||||
/* Copy the source's quantization tables. */
|
/* Copy the source's quantization tables. */
|
||||||
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
||||||
if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
||||||
qtblptr = &dstinfo->quant_tbl_ptrs[tblno];
|
qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
|
||||||
if (*qtblptr == NULL)
|
if (*qtblptr == NULL)
|
||||||
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo);
|
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
||||||
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
||||||
sizeof((*qtblptr)->quantval));
|
sizeof((*qtblptr)->quantval));
|
||||||
(*qtblptr)->sent_table = FALSE;
|
(*qtblptr)->sent_table = FALSE;
|
||||||
@@ -163,8 +170,8 @@ jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
transencode_master_selection(j_compress_ptr cinfo,
|
transencode_master_selection (j_compress_ptr cinfo,
|
||||||
jvirt_barray_ptr *coef_arrays)
|
jvirt_barray_ptr *coef_arrays)
|
||||||
{
|
{
|
||||||
/* Although we don't actually use input_components for transcoding,
|
/* Although we don't actually use input_components for transcoding,
|
||||||
* jcmaster.c's initial_setup will complain if input_components is 0.
|
* jcmaster.c's initial_setup will complain if input_components is 0.
|
||||||
@@ -197,7 +204,7 @@ transencode_master_selection(j_compress_ptr cinfo,
|
|||||||
jinit_marker_writer(cinfo);
|
jinit_marker_writer(cinfo);
|
||||||
|
|
||||||
/* We can now tell the memory manager to allocate virtual arrays. */
|
/* We can now tell the memory manager to allocate virtual arrays. */
|
||||||
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo);
|
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
||||||
|
|
||||||
/* Write the datastream header (SOI, JFIF) immediately.
|
/* Write the datastream header (SOI, JFIF) immediately.
|
||||||
* Frame and scan headers are postponed till later.
|
* Frame and scan headers are postponed till later.
|
||||||
@@ -236,10 +243,10 @@ typedef my_coef_controller *my_coef_ptr;
|
|||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
start_iMCU_row(j_compress_ptr cinfo)
|
start_iMCU_row (j_compress_ptr cinfo)
|
||||||
/* Reset within-iMCU-row counters for a new row */
|
/* Reset within-iMCU-row counters for a new row */
|
||||||
{
|
{
|
||||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
|
|
||||||
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
||||||
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
||||||
@@ -248,7 +255,7 @@ start_iMCU_row(j_compress_ptr cinfo)
|
|||||||
if (cinfo->comps_in_scan > 1) {
|
if (cinfo->comps_in_scan > 1) {
|
||||||
coef->MCU_rows_per_iMCU_row = 1;
|
coef->MCU_rows_per_iMCU_row = 1;
|
||||||
} else {
|
} else {
|
||||||
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows - 1))
|
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
||||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
||||||
else
|
else
|
||||||
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
||||||
@@ -264,9 +271,9 @@ start_iMCU_row(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
||||||
{
|
{
|
||||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
|
|
||||||
if (pass_mode != JBUF_CRANK_DEST)
|
if (pass_mode != JBUF_CRANK_DEST)
|
||||||
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
||||||
@@ -287,9 +294,9 @@ start_pass_coef(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
||||||
{
|
{
|
||||||
my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
|
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
||||||
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
||||||
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
||||||
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
||||||
@@ -304,9 +311,9 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
||||||
compptr = cinfo->cur_comp_info[ci];
|
compptr = cinfo->cur_comp_info[ci];
|
||||||
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
||||||
((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
|
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
||||||
coef->iMCU_row_num * compptr->v_samp_factor,
|
coef->iMCU_row_num * compptr->v_samp_factor,
|
||||||
(JDIMENSION)compptr->v_samp_factor, FALSE);
|
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loop to process one whole iMCU row */
|
/* Loop to process one whole iMCU row */
|
||||||
@@ -323,9 +330,9 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
compptr->last_col_width;
|
compptr->last_col_width;
|
||||||
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
||||||
if (coef->iMCU_row_num < last_iMCU_row ||
|
if (coef->iMCU_row_num < last_iMCU_row ||
|
||||||
yindex + yoffset < compptr->last_row_height) {
|
yindex+yoffset < compptr->last_row_height) {
|
||||||
/* Fill in pointers to real blocks in this row */
|
/* Fill in pointers to real blocks in this row */
|
||||||
buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
|
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
||||||
for (xindex = 0; xindex < blockcnt; xindex++)
|
for (xindex = 0; xindex < blockcnt; xindex++)
|
||||||
MCU_buffer[blkn++] = buffer_ptr++;
|
MCU_buffer[blkn++] = buffer_ptr++;
|
||||||
} else {
|
} else {
|
||||||
@@ -340,13 +347,13 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
*/
|
*/
|
||||||
for (; xindex < compptr->MCU_width; xindex++) {
|
for (; xindex < compptr->MCU_width; xindex++) {
|
||||||
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
||||||
MCU_buffer[blkn][0][0] = MCU_buffer[blkn - 1][0][0];
|
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
||||||
blkn++;
|
blkn++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Try to write the MCU. */
|
/* Try to write the MCU. */
|
||||||
if (!(*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
||||||
/* Suspension forced; update state counters and exit */
|
/* Suspension forced; update state counters and exit */
|
||||||
coef->MCU_vert_offset = yoffset;
|
coef->MCU_vert_offset = yoffset;
|
||||||
coef->mcu_ctr = MCU_col_num;
|
coef->mcu_ctr = MCU_col_num;
|
||||||
@@ -372,17 +379,17 @@ compress_output(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
transencode_coef_controller(j_compress_ptr cinfo,
|
transencode_coef_controller (j_compress_ptr cinfo,
|
||||||
jvirt_barray_ptr *coef_arrays)
|
jvirt_barray_ptr *coef_arrays)
|
||||||
{
|
{
|
||||||
my_coef_ptr coef;
|
my_coef_ptr coef;
|
||||||
JBLOCKROW buffer;
|
JBLOCKROW buffer;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
coef = (my_coef_ptr)
|
coef = (my_coef_ptr)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
sizeof(my_coef_controller));
|
sizeof(my_coef_controller));
|
||||||
cinfo->coef = (struct jpeg_c_coef_controller *)coef;
|
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
||||||
coef->pub.start_pass = start_pass_coef;
|
coef->pub.start_pass = start_pass_coef;
|
||||||
coef->pub.compress_data = compress_output;
|
coef->pub.compress_data = compress_output;
|
||||||
|
|
||||||
@@ -391,9 +398,9 @@ transencode_coef_controller(j_compress_ptr cinfo,
|
|||||||
|
|
||||||
/* Allocate and pre-zero space for dummy DCT blocks. */
|
/* Allocate and pre-zero space for dummy DCT blocks. */
|
||||||
buffer = (JBLOCKROW)
|
buffer = (JBLOCKROW)
|
||||||
(*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||||
jzero_far((void *)buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
jzero_far((void *) buffer, C_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
|
||||||
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
||||||
coef->dummy_buffer[i] = buffer + i;
|
coef->dummy_buffer[i] = buffer + i;
|
||||||
}
|
}
|
||||||
|
|||||||
42
jdapimin.c
42
jdapimin.c
@@ -31,7 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
|||||||
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
||||||
if (structsize != sizeof(struct jpeg_decompress_struct))
|
if (structsize != sizeof(struct jpeg_decompress_struct))
|
||||||
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
||||||
(int)sizeof(struct jpeg_decompress_struct), (int)structsize);
|
(int) sizeof(struct jpeg_decompress_struct), (int) structsize);
|
||||||
|
|
||||||
/* For debugging purposes, we zero the whole master structure.
|
/* For debugging purposes, we zero the whole master structure.
|
||||||
* But the application has already set the err pointer, and may have set
|
* But the application has already set the err pointer, and may have set
|
||||||
@@ -50,8 +50,8 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
|||||||
* complain here.
|
* complain here.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
struct jpeg_error_mgr *err = cinfo->err;
|
struct jpeg_error_mgr * err = cinfo->err;
|
||||||
void *client_data = cinfo->client_data; /* ignore Purify complaint here */
|
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
||||||
MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
|
MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct));
|
||||||
cinfo->err = err;
|
cinfo->err = err;
|
||||||
cinfo->client_data = client_data;
|
cinfo->client_data = client_data;
|
||||||
@@ -59,7 +59,7 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
|||||||
cinfo->is_decompressor = TRUE;
|
cinfo->is_decompressor = TRUE;
|
||||||
|
|
||||||
/* Initialize a memory manager instance for this object */
|
/* Initialize a memory manager instance for this object */
|
||||||
jinit_memory_mgr((j_common_ptr)cinfo);
|
jinit_memory_mgr((j_common_ptr) cinfo);
|
||||||
|
|
||||||
/* Zero out pointers to permanent structures. */
|
/* Zero out pointers to permanent structures. */
|
||||||
cinfo->progress = NULL;
|
cinfo->progress = NULL;
|
||||||
@@ -89,8 +89,8 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
|||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
cinfo->master = (struct jpeg_decomp_master *)
|
cinfo->master = (struct jpeg_decomp_master *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
sizeof(my_decomp_master));
|
sizeof(my_decomp_master));
|
||||||
MEMZERO(cinfo->master, sizeof(my_decomp_master));
|
MEMZERO(cinfo->master, sizeof(my_decomp_master));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +100,9 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_destroy_decompress(j_decompress_ptr cinfo)
|
jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
jpeg_destroy((j_common_ptr)cinfo); /* use common routine */
|
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,9 +112,9 @@ jpeg_destroy_decompress(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_abort_decompress(j_decompress_ptr cinfo)
|
jpeg_abort_decompress (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
jpeg_abort((j_common_ptr)cinfo); /* use common routine */
|
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ jpeg_abort_decompress(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
default_decompress_parms(j_decompress_ptr cinfo)
|
default_decompress_parms (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
/* Guess the input colorspace, and set output colorspace accordingly. */
|
/* Guess the input colorspace, and set output colorspace accordingly. */
|
||||||
/* (Wish JPEG committee had provided a real way to specify this...) */
|
/* (Wish JPEG committee had provided a real way to specify this...) */
|
||||||
@@ -250,7 +250,7 @@ default_decompress_parms(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(int)
|
GLOBAL(int)
|
||||||
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
|
jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
||||||
{
|
{
|
||||||
int retcode;
|
int retcode;
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
|
|||||||
* call jpeg_abort, but we can't change it now for compatibility reasons.
|
* call jpeg_abort, but we can't change it now for compatibility reasons.
|
||||||
* A side effect is to free any temporary memory (there shouldn't be any).
|
* A side effect is to free any temporary memory (there shouldn't be any).
|
||||||
*/
|
*/
|
||||||
jpeg_abort((j_common_ptr)cinfo); /* sets state = DSTATE_START */
|
jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */
|
||||||
retcode = JPEG_HEADER_TABLES_ONLY;
|
retcode = JPEG_HEADER_TABLES_ONLY;
|
||||||
break;
|
break;
|
||||||
case JPEG_SUSPENDED:
|
case JPEG_SUSPENDED:
|
||||||
@@ -296,7 +296,7 @@ jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(int)
|
GLOBAL(int)
|
||||||
jpeg_consume_input(j_decompress_ptr cinfo)
|
jpeg_consume_input (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
int retcode = JPEG_SUSPENDED;
|
int retcode = JPEG_SUSPENDED;
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ jpeg_consume_input(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(boolean)
|
GLOBAL(boolean)
|
||||||
jpeg_input_complete(j_decompress_ptr cinfo)
|
jpeg_input_complete (const j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
/* Check for valid jpeg object */
|
/* Check for valid jpeg object */
|
||||||
if (cinfo->global_state < DSTATE_START ||
|
if (cinfo->global_state < DSTATE_START ||
|
||||||
@@ -358,7 +358,7 @@ jpeg_input_complete(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(boolean)
|
GLOBAL(boolean)
|
||||||
jpeg_has_multiple_scans(j_decompress_ptr cinfo)
|
jpeg_has_multiple_scans (const j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
/* Only valid after jpeg_read_header completes */
|
/* Only valid after jpeg_read_header completes */
|
||||||
if (cinfo->global_state < DSTATE_READY ||
|
if (cinfo->global_state < DSTATE_READY ||
|
||||||
@@ -378,10 +378,10 @@ jpeg_has_multiple_scans(j_decompress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(boolean)
|
GLOBAL(boolean)
|
||||||
jpeg_finish_decompress(j_decompress_ptr cinfo)
|
jpeg_finish_decompress (j_decompress_ptr cinfo)
|
||||||
{
|
{
|
||||||
if ((cinfo->global_state == DSTATE_SCANNING ||
|
if ((cinfo->global_state == DSTATE_SCANNING ||
|
||||||
cinfo->global_state == DSTATE_RAW_OK) && !cinfo->buffered_image) {
|
cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {
|
||||||
/* Terminate final pass of non-buffered mode */
|
/* Terminate final pass of non-buffered mode */
|
||||||
if (cinfo->output_scanline < cinfo->output_height)
|
if (cinfo->output_scanline < cinfo->output_height)
|
||||||
ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
|
ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
|
||||||
@@ -395,13 +395,13 @@ jpeg_finish_decompress(j_decompress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
||||||
}
|
}
|
||||||
/* Read until EOI */
|
/* Read until EOI */
|
||||||
while (!cinfo->inputctl->eoi_reached) {
|
while (! cinfo->inputctl->eoi_reached) {
|
||||||
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
||||||
return FALSE; /* Suspend, come back later */
|
return FALSE; /* Suspend, come back later */
|
||||||
}
|
}
|
||||||
/* Do final cleanup */
|
/* Do final cleanup */
|
||||||
(*cinfo->src->term_source) (cinfo);
|
(*cinfo->src->term_source) (cinfo);
|
||||||
/* We can use jpeg_abort to release memory and reset global_state */
|
/* We can use jpeg_abort to release memory and reset global_state */
|
||||||
jpeg_abort((j_common_ptr)cinfo);
|
jpeg_abort((j_common_ptr) cinfo);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
17
jdapistd.c
17
jdapistd.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2015-2017, D. R. Commander.
|
* Copyright (C) 2010, 2015-2018, D. R. Commander.
|
||||||
* Copyright (C) 2015, Google, Inc.
|
* Copyright (C) 2015, Google, Inc.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
@@ -318,12 +318,15 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
|||||||
JDIMENSION n;
|
JDIMENSION n;
|
||||||
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
void (*color_convert) (j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
||||||
JDIMENSION input_row, JSAMPARRAY output_buf,
|
JDIMENSION input_row, JSAMPARRAY output_buf,
|
||||||
int num_rows);
|
int num_rows) = NULL;
|
||||||
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
void (*color_quantize) (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
|
||||||
JSAMPARRAY output_buf, int num_rows) = NULL;
|
JSAMPARRAY output_buf, int num_rows) = NULL;
|
||||||
|
|
||||||
color_convert = cinfo->cconvert->color_convert;
|
if (cinfo->cconvert && cinfo->cconvert->color_convert) {
|
||||||
cinfo->cconvert->color_convert = noop_convert;
|
color_convert = cinfo->cconvert->color_convert;
|
||||||
|
cinfo->cconvert->color_convert = noop_convert;
|
||||||
|
}
|
||||||
|
|
||||||
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
|
if (cinfo->cquantize && cinfo->cquantize->color_quantize) {
|
||||||
color_quantize = cinfo->cquantize->color_quantize;
|
color_quantize = cinfo->cquantize->color_quantize;
|
||||||
cinfo->cquantize->color_quantize = noop_quantize;
|
cinfo->cquantize->color_quantize = noop_quantize;
|
||||||
@@ -332,7 +335,9 @@ read_and_discard_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
|||||||
for (n = 0; n < num_lines; n++)
|
for (n = 0; n < num_lines; n++)
|
||||||
jpeg_read_scanlines(cinfo, NULL, 1);
|
jpeg_read_scanlines(cinfo, NULL, 1);
|
||||||
|
|
||||||
cinfo->cconvert->color_convert = color_convert;
|
if (color_convert)
|
||||||
|
cinfo->cconvert->color_convert = color_convert;
|
||||||
|
|
||||||
if (color_quantize)
|
if (color_quantize)
|
||||||
cinfo->cquantize->color_quantize = color_quantize;
|
cinfo->cquantize->color_quantize = color_quantize;
|
||||||
}
|
}
|
||||||
@@ -479,7 +484,7 @@ jpeg_skip_scanlines(j_decompress_ptr cinfo, JDIMENSION num_lines)
|
|||||||
if (cinfo->upsample->need_context_rows) {
|
if (cinfo->upsample->need_context_rows) {
|
||||||
cinfo->output_scanline += lines_to_skip;
|
cinfo->output_scanline += lines_to_skip;
|
||||||
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
|
cinfo->output_iMCU_row += lines_to_skip / lines_per_iMCU_row;
|
||||||
main_ptr->iMCU_row_ctr += lines_after_iMCU_row / lines_per_iMCU_row;
|
main_ptr->iMCU_row_ctr += lines_to_skip / lines_per_iMCU_row;
|
||||||
/* It is complex to properly move to the middle of a context block, so
|
/* It is complex to properly move to the middle of a context block, so
|
||||||
* read the remaining lines instead of skipping them.
|
* read the remaining lines instead of skipping them.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,16 +4,19 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Developed 1997-2015 by Guido Vollbeding.
|
* Developed 1997-2015 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015-2017, D. R. Commander.
|
* Copyright (C) 2015-2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* This file contains portable arithmetic entropy decoding routines for JPEG
|
* This file contains portable arithmetic entropy encoding routines for JPEG
|
||||||
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
|
* (implementing Recommendation ITU-T T.81 | ISO/IEC 10918-1).
|
||||||
*
|
*
|
||||||
* Both sequential and progressive modes are supported in this single module.
|
* Both sequential and progressive modes are supported in this single module.
|
||||||
*
|
*
|
||||||
* Suspension is not currently supported in this module.
|
* Suspension is not currently supported in this module.
|
||||||
|
*
|
||||||
|
* NOTE: All referenced figures are from
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2012 by Guido Vollbeding.
|
* Modified 2009-2012 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2011, 2014, 2016, D. R. Commander.
|
* Copyright (C) 2011, 2014, 2016, 2019, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -27,6 +27,8 @@
|
|||||||
extern void *malloc(size_t size);
|
extern void *malloc(size_t size);
|
||||||
extern void free(void *ptr);
|
extern void free(void *ptr);
|
||||||
#endif
|
#endif
|
||||||
|
void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||||
|
unsigned long *outsize, boolean alloc);
|
||||||
|
|
||||||
|
|
||||||
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
||||||
@@ -101,8 +103,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
||||||
|
|
||||||
if (dest->newbuffer != NULL)
|
free(dest->newbuffer);
|
||||||
free(dest->newbuffer);
|
|
||||||
|
|
||||||
dest->newbuffer = nextbuffer;
|
dest->newbuffer = nextbuffer;
|
||||||
|
|
||||||
|
|||||||
65
jdatadst.c
65
jdatadst.c
@@ -22,10 +22,11 @@
|
|||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jerror.h"
|
#include "jerror.h"
|
||||||
|
#include "jpegint.h"
|
||||||
|
|
||||||
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
||||||
extern void *malloc(size_t size);
|
extern void *malloc (size_t size);
|
||||||
extern void free(void *ptr);
|
extern void free (void *ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -66,14 +67,14 @@ typedef my_mem_destination_mgr *my_mem_dest_ptr;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
init_destination(j_compress_ptr cinfo)
|
init_destination (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||||
|
|
||||||
/* Allocate the output buffer --- it will be released when done with image */
|
/* Allocate the output buffer --- it will be released when done with image */
|
||||||
dest->buffer = (JOCTET *)
|
dest->buffer = (JOCTET *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
||||||
|
|
||||||
dest->pub.next_output_byte = dest->buffer;
|
dest->pub.next_output_byte = dest->buffer;
|
||||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||||
@@ -81,7 +82,7 @@ init_destination(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
init_mem_destination(j_compress_ptr cinfo)
|
init_mem_destination (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
/* no work necessary here */
|
/* no work necessary here */
|
||||||
}
|
}
|
||||||
@@ -112,12 +113,12 @@ init_mem_destination(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
empty_output_buffer(j_compress_ptr cinfo)
|
empty_output_buffer (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||||
|
|
||||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
||||||
(size_t)OUTPUT_BUF_SIZE)
|
(size_t) OUTPUT_BUF_SIZE)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
|
|
||||||
dest->pub.next_output_byte = dest->buffer;
|
dest->pub.next_output_byte = dest->buffer;
|
||||||
@@ -128,23 +129,22 @@ empty_output_buffer(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
METHODDEF(boolean)
|
METHODDEF(boolean)
|
||||||
empty_mem_output_buffer(j_compress_ptr cinfo)
|
empty_mem_output_buffer (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
size_t nextsize;
|
size_t nextsize;
|
||||||
JOCTET *nextbuffer;
|
JOCTET *nextbuffer;
|
||||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||||
|
|
||||||
/* Try to allocate new buffer with double size */
|
/* Try to allocate new buffer with double size */
|
||||||
nextsize = dest->bufsize * 2;
|
nextsize = dest->bufsize * 2;
|
||||||
nextbuffer = (JOCTET *)malloc(nextsize);
|
nextbuffer = (JOCTET *) malloc(nextsize);
|
||||||
|
|
||||||
if (nextbuffer == NULL)
|
if (nextbuffer == NULL)
|
||||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||||
|
|
||||||
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
|
||||||
|
|
||||||
if (dest->newbuffer != NULL)
|
free(dest->newbuffer);
|
||||||
free(dest->newbuffer);
|
|
||||||
|
|
||||||
dest->newbuffer = nextbuffer;
|
dest->newbuffer = nextbuffer;
|
||||||
|
|
||||||
@@ -169,9 +169,9 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
term_destination(j_compress_ptr cinfo)
|
term_destination (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||||
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
||||||
|
|
||||||
/* Write any data remaining in the buffer */
|
/* Write any data remaining in the buffer */
|
||||||
@@ -187,9 +187,9 @@ term_destination(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
term_mem_destination(j_compress_ptr cinfo)
|
term_mem_destination (j_compress_ptr cinfo)
|
||||||
{
|
{
|
||||||
my_mem_dest_ptr dest = (my_mem_dest_ptr)cinfo->dest;
|
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
||||||
|
|
||||||
*dest->outbuffer = dest->buffer;
|
*dest->outbuffer = dest->buffer;
|
||||||
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
*dest->outsize = (unsigned long)(dest->bufsize - dest->pub.free_in_buffer);
|
||||||
@@ -204,7 +204,7 @@ term_mem_destination(j_compress_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
||||||
{
|
{
|
||||||
my_dest_ptr dest;
|
my_dest_ptr dest;
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
|||||||
*/
|
*/
|
||||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
||||||
sizeof(my_destination_mgr));
|
sizeof(my_destination_mgr));
|
||||||
} else if (cinfo->dest->init_destination != init_destination) {
|
} else if (cinfo->dest->init_destination != init_destination) {
|
||||||
/* It is unsafe to reuse the existing destination manager unless it was
|
/* It is unsafe to reuse the existing destination manager unless it was
|
||||||
@@ -225,7 +225,7 @@ jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
|||||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest = (my_dest_ptr)cinfo->dest;
|
dest = (my_dest_ptr) cinfo->dest;
|
||||||
dest->pub.init_destination = init_destination;
|
dest->pub.init_destination = init_destination;
|
||||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||||
dest->pub.term_destination = term_destination;
|
dest->pub.term_destination = term_destination;
|
||||||
@@ -249,8 +249,8 @@ jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(void)
|
GLOBAL(void)
|
||||||
jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
jpeg_mem_dest_internal (j_compress_ptr cinfo,
|
||||||
unsigned long *outsize)
|
unsigned char **outbuffer, unsigned long *outsize, int pool_id)
|
||||||
{
|
{
|
||||||
my_mem_dest_ptr dest;
|
my_mem_dest_ptr dest;
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
|||||||
*/
|
*/
|
||||||
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
||||||
cinfo->dest = (struct jpeg_destination_mgr *)
|
cinfo->dest = (struct jpeg_destination_mgr *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, pool_id,
|
||||||
sizeof(my_mem_destination_mgr));
|
sizeof(my_mem_destination_mgr));
|
||||||
} else if (cinfo->dest->init_destination != init_mem_destination) {
|
} else if (cinfo->dest->init_destination != init_mem_destination) {
|
||||||
/* It is unsafe to reuse the existing destination manager unless it was
|
/* It is unsafe to reuse the existing destination manager unless it was
|
||||||
@@ -271,7 +271,7 @@ jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
|||||||
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest = (my_mem_dest_ptr)cinfo->dest;
|
dest = (my_mem_dest_ptr) cinfo->dest;
|
||||||
dest->pub.init_destination = init_mem_destination;
|
dest->pub.init_destination = init_mem_destination;
|
||||||
dest->pub.empty_output_buffer = empty_mem_output_buffer;
|
dest->pub.empty_output_buffer = empty_mem_output_buffer;
|
||||||
dest->pub.term_destination = term_mem_destination;
|
dest->pub.term_destination = term_mem_destination;
|
||||||
@@ -281,7 +281,7 @@ jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
|||||||
|
|
||||||
if (*outbuffer == NULL || *outsize == 0) {
|
if (*outbuffer == NULL || *outsize == 0) {
|
||||||
/* Allocate initial buffer */
|
/* Allocate initial buffer */
|
||||||
dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE);
|
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
|
||||||
if (dest->newbuffer == NULL)
|
if (dest->newbuffer == NULL)
|
||||||
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
|
||||||
*outsize = OUTPUT_BUF_SIZE;
|
*outsize = OUTPUT_BUF_SIZE;
|
||||||
@@ -290,4 +290,15 @@ jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
|||||||
dest->pub.next_output_byte = dest->buffer = *outbuffer;
|
dest->pub.next_output_byte = dest->buffer = *outbuffer;
|
||||||
dest->pub.free_in_buffer = dest->bufsize = *outsize;
|
dest->pub.free_in_buffer = dest->bufsize = *outsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLOBAL(void)
|
||||||
|
jpeg_mem_dest (j_compress_ptr cinfo,
|
||||||
|
unsigned char **outbuffer, unsigned long *outsize)
|
||||||
|
{
|
||||||
|
/* The destination object is made permanent so that multiple JPEG images
|
||||||
|
* can be written to the same file without re-executing jpeg_stdio_dest.
|
||||||
|
*/
|
||||||
|
jpeg_mem_dest_internal(cinfo, outbuffer, outsize, JPOOL_PERMANENT);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2011 by Guido Vollbeding.
|
* Modified 2009-2011 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2011, 2016, D. R. Commander.
|
* Copyright (C) 2011, 2016, 2019, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -23,6 +23,9 @@
|
|||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jerror.h"
|
#include "jerror.h"
|
||||||
|
|
||||||
|
void jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
|
||||||
|
unsigned long insize);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize source --- called by jpeg_read_header
|
* Initialize source --- called by jpeg_read_header
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ ycck_cmyk_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|||||||
/* Declarations for ordered dithering
|
/* Declarations for ordered dithering
|
||||||
*
|
*
|
||||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||||
* sufficent for dithering RGB888 to RGB565.
|
* sufficient for dithering RGB888 to RGB565.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DITHER_MASK 0x3
|
#define DITHER_MASK 0x3
|
||||||
|
|||||||
15
jddctmgr.c
15
jddctmgr.c
@@ -27,6 +27,7 @@
|
|||||||
#include "jdct.h" /* Private declarations for DCT subsystem */
|
#include "jdct.h" /* Private declarations for DCT subsystem */
|
||||||
#include "jsimddct.h"
|
#include "jsimddct.h"
|
||||||
#include "jpegcomp.h"
|
#include "jpegcomp.h"
|
||||||
|
#include "jdmaster.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -86,6 +87,11 @@ typedef union {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EXTERN(void) jpeg_set_idct_method_selector (j_decompress_ptr cinfo, jpeg_idct_method_selector selector){
|
||||||
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
master->custom_idct_selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for an output pass.
|
* Prepare for an output pass.
|
||||||
@@ -102,6 +108,7 @@ start_pass(j_decompress_ptr cinfo)
|
|||||||
int method = 0;
|
int method = 0;
|
||||||
inverse_DCT_method_ptr method_ptr = NULL;
|
inverse_DCT_method_ptr method_ptr = NULL;
|
||||||
JQUANT_TBL *qtbl;
|
JQUANT_TBL *qtbl;
|
||||||
|
my_master_ptr master;
|
||||||
|
|
||||||
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
||||||
ci++, compptr++) {
|
ci++, compptr++) {
|
||||||
@@ -225,6 +232,14 @@ start_pass(j_decompress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
|
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow custom idct function to be set dynamically
|
||||||
|
master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
|
if (master->custom_idct_selector != NULL) {
|
||||||
|
master->custom_idct_selector(cinfo, compptr, &method_ptr, &method);
|
||||||
|
}
|
||||||
|
|
||||||
idct->pub.inverse_DCT[ci] = method_ptr;
|
idct->pub.inverse_DCT[ci] = method_ptr;
|
||||||
/* Create multiplier table from quant table.
|
/* Create multiplier table from quant table.
|
||||||
* However, we can skip this if the component is uninteresting
|
* However, we can skip this if the component is uninteresting
|
||||||
|
|||||||
15
jdhuff.c
15
jdhuff.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, 2016, D. R. Commander.
|
* Copyright (C) 2009-2011, 2016, 2018-2019, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
* up to the start of the current MCU. To do this, we copy state variables
|
* up to the start of the current MCU. To do this, we copy state variables
|
||||||
* into local working storage, and update them back to the permanent
|
* into local working storage, and update them back to the permanent
|
||||||
* storage only upon successful completion of an MCU.
|
* storage only upon successful completion of an MCU.
|
||||||
|
*
|
||||||
|
* NOTE: All referenced figures are from
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
@@ -459,7 +462,7 @@ jpeg_huff_decode(bitread_working_state *state,
|
|||||||
code = GET_BITS(l);
|
code = GET_BITS(l);
|
||||||
|
|
||||||
/* Collect the rest of the Huffman code one bit at a time. */
|
/* Collect the rest of the Huffman code one bit at a time. */
|
||||||
/* This is per Figure F.16 in the JPEG spec. */
|
/* This is per Figure F.16. */
|
||||||
|
|
||||||
while (code > htbl->maxcode[l]) {
|
while (code > htbl->maxcode[l]) {
|
||||||
code <<= 1;
|
code <<= 1;
|
||||||
@@ -586,7 +589,11 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
if (entropy->dc_needed[blkn]) {
|
if (entropy->dc_needed[blkn]) {
|
||||||
/* Convert DC difference to actual value, update last_dc_val */
|
/* Convert DC difference to actual value, update last_dc_val */
|
||||||
int ci = cinfo->MCU_membership[blkn];
|
int ci = cinfo->MCU_membership[blkn];
|
||||||
s += state.last_dc_val[ci];
|
/* This is really just
|
||||||
|
* s += state.last_dc_val[ci];
|
||||||
|
* It is written this way in order to shut up UBSan.
|
||||||
|
*/
|
||||||
|
s = (int)((unsigned int)s + (unsigned int)state.last_dc_val[ci]);
|
||||||
state.last_dc_val[ci] = s;
|
state.last_dc_val[ci] = s;
|
||||||
if (block) {
|
if (block) {
|
||||||
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
|
/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
|
||||||
@@ -681,7 +688,7 @@ decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
|
|
||||||
if (entropy->dc_needed[blkn]) {
|
if (entropy->dc_needed[blkn]) {
|
||||||
int ci = cinfo->MCU_membership[blkn];
|
int ci = cinfo->MCU_membership[blkn];
|
||||||
s += state.last_dc_val[ci];
|
s = (int)((unsigned int)s + (unsigned int)state.last_dc_val[ci]);
|
||||||
state.last_dc_val[ci] = s;
|
state.last_dc_val[ci] = s;
|
||||||
if (block)
|
if (block)
|
||||||
(*block)[0] = (JCOEF)s;
|
(*block)[0] = (JCOEF)s;
|
||||||
|
|||||||
8
jdhuff.h
8
jdhuff.h
@@ -152,7 +152,7 @@ typedef struct { /* Bitreading working state within an MCU */
|
|||||||
if (bits_left < (nbits)) { \
|
if (bits_left < (nbits)) { \
|
||||||
if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
|
if (!jpeg_fill_bit_buffer(&(state), get_buffer, bits_left, nbits)) \
|
||||||
{ action; } \
|
{ action; } \
|
||||||
get_buffer = (state).get_buffer; bits_left = (state).bits_left; \
|
get_buffer = (state).get_buffer; bits_left = (state).bits_left; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,9 +193,9 @@ EXTERN(boolean) jpeg_fill_bit_buffer(bitread_working_state *state,
|
|||||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||||
if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
|
if (!jpeg_fill_bit_buffer(&state, get_buffer, bits_left, 0)) \
|
||||||
{ failaction; } \
|
{ failaction; } \
|
||||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||||
if (bits_left < HUFF_LOOKAHEAD) { \
|
if (bits_left < HUFF_LOOKAHEAD) { \
|
||||||
nb = 1; goto slowlabel; \
|
nb = 1; goto slowlabel; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
look = PEEK_BITS(HUFF_LOOKAHEAD); \
|
look = PEEK_BITS(HUFF_LOOKAHEAD); \
|
||||||
@@ -207,7 +207,7 @@ slowlabel: \
|
|||||||
if ((result = \
|
if ((result = \
|
||||||
jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
|
jpeg_huff_decode(&state, get_buffer, bits_left, htbl, nb)) < 0) \
|
||||||
{ failaction; } \
|
{ failaction; } \
|
||||||
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
get_buffer = state.get_buffer; bits_left = state.bits_left; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
jdinput.c
10
jdinput.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2016, D. R. Commander.
|
* Copyright (C) 2010, 2016, 2018, D. R. Commander.
|
||||||
* Copyright (C) 2015, Google, Inc.
|
* Copyright (C) 2015, Google, Inc.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
@@ -234,10 +234,10 @@ per_scan_setup(j_decompress_ptr cinfo)
|
|||||||
* means that we have to save away the table actually used for each component.
|
* means that we have to save away the table actually used for each component.
|
||||||
* We do this by copying the table at the start of the first scan containing
|
* We do this by copying the table at the start of the first scan containing
|
||||||
* the component.
|
* the component.
|
||||||
* The JPEG spec prohibits the encoder from changing the contents of a Q-table
|
* Rec. ITU-T T.81 | ISO/IEC 10918-1 prohibits the encoder from changing the
|
||||||
* slot between scans of a component using that slot. If the encoder does so
|
* contents of a Q-table slot between scans of a component using that slot. If
|
||||||
* anyway, this decoder will simply use the Q-table values that were current
|
* the encoder does so anyway, this decoder will simply use the Q-table values
|
||||||
* at the start of the first scan for the component.
|
* that were current at the start of the first scan for the component.
|
||||||
*
|
*
|
||||||
* The decompressor output side looks only at the saved quant tables,
|
* The decompressor output side looks only at the saved quant tables,
|
||||||
* not at the current Q-table slots.
|
* not at the current Q-table slots.
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
struct jpeg_color_quantizer *quantizer_1pass;
|
struct jpeg_color_quantizer *quantizer_1pass;
|
||||||
struct jpeg_color_quantizer *quantizer_2pass;
|
struct jpeg_color_quantizer *quantizer_2pass;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Permit users to replace the IDCT method
|
||||||
|
*/
|
||||||
|
jpeg_idct_method_selector custom_idct_selector;
|
||||||
} my_decomp_master;
|
} my_decomp_master;
|
||||||
|
|
||||||
typedef my_decomp_master *my_master_ptr;
|
typedef my_decomp_master *my_master_ptr;
|
||||||
|
|||||||
@@ -429,8 +429,6 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|||||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||||
|
|
||||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
|
||||||
|
|
||||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||||
((INT16 *)(addr))[0] = (INT16)(pixels); \
|
((INT16 *)(addr))[0] = (INT16)(pixels); \
|
||||||
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
|
((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
|
||||||
@@ -448,7 +446,7 @@ h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
|
|||||||
/* Declarations for ordered dithering
|
/* Declarations for ordered dithering
|
||||||
*
|
*
|
||||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||||
* sufficent for dithering RGB888 to RGB565.
|
* sufficient for dithering RGB888 to RGB565.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DITHER_MASK 0x3
|
#define DITHER_MASK 0x3
|
||||||
|
|||||||
10
jdphuff.c
10
jdphuff.c
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1995-1997, Thomas G. Lane.
|
* Copyright (C) 1995-1997, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015-2016, D. R. Commander.
|
* Copyright (C) 2015-2016, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -15,12 +15,16 @@
|
|||||||
* up to the start of the current MCU. To do this, we copy state variables
|
* up to the start of the current MCU. To do this, we copy state variables
|
||||||
* into local working storage, and update them back to the permanent
|
* into local working storage, and update them back to the permanent
|
||||||
* storage only upon successful completion of an MCU.
|
* storage only upon successful completion of an MCU.
|
||||||
|
*
|
||||||
|
* NOTE: All referenced figures are from
|
||||||
|
* Recommendation ITU-T T.81 (1992) | ISO/IEC 10918-1:1994.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPEG_INTERNALS
|
#define JPEG_INTERNALS
|
||||||
#include "jinclude.h"
|
#include "jinclude.h"
|
||||||
#include "jpeglib.h"
|
#include "jpeglib.h"
|
||||||
#include "jdhuff.h" /* Declarations shared with jdhuff.c */
|
#include "jdhuff.h" /* Declarations shared with jdhuff.c */
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef D_PROGRESSIVE_SUPPORTED
|
#ifdef D_PROGRESSIVE_SUPPORTED
|
||||||
@@ -340,6 +344,10 @@ decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert DC difference to actual value, update last_dc_val */
|
/* Convert DC difference to actual value, update last_dc_val */
|
||||||
|
if ((state.last_dc_val[ci] >= 0 &&
|
||||||
|
s > INT_MAX - state.last_dc_val[ci]) ||
|
||||||
|
(state.last_dc_val[ci] < 0 && s < INT_MIN - state.last_dc_val[ci]))
|
||||||
|
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
|
||||||
s += state.last_dc_val[ci];
|
s += state.last_dc_val[ci];
|
||||||
state.last_dc_val[ci] = s;
|
state.last_dc_val[ci] = s;
|
||||||
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
|
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
|
||||||
|
|||||||
14
jdsample.c
14
jdsample.c
@@ -8,6 +8,7 @@
|
|||||||
* Copyright (C) 2010, 2015-2016, D. R. Commander.
|
* Copyright (C) 2010, 2015-2016, D. R. Commander.
|
||||||
* Copyright (C) 2014, MIPS Technologies, Inc., California.
|
* Copyright (C) 2014, MIPS Technologies, Inc., California.
|
||||||
* Copyright (C) 2015, Google, Inc.
|
* Copyright (C) 2015, Google, Inc.
|
||||||
|
* Copyright (C) 2019, Arm Limited.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -315,9 +316,9 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
JSAMPARRAY output_data = *output_data_ptr;
|
JSAMPARRAY output_data = *output_data_ptr;
|
||||||
JSAMPROW inptr0, inptr1, outptr;
|
JSAMPROW inptr0, inptr1, outptr;
|
||||||
#if BITS_IN_JSAMPLE == 8
|
#if BITS_IN_JSAMPLE == 8
|
||||||
int thiscolsum;
|
int thiscolsum, bias;
|
||||||
#else
|
#else
|
||||||
JLONG thiscolsum;
|
JLONG thiscolsum, bias;
|
||||||
#endif
|
#endif
|
||||||
JDIMENSION colctr;
|
JDIMENSION colctr;
|
||||||
int inrow, outrow, v;
|
int inrow, outrow, v;
|
||||||
@@ -327,15 +328,18 @@ h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr,
|
|||||||
for (v = 0; v < 2; v++) {
|
for (v = 0; v < 2; v++) {
|
||||||
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
/* inptr0 points to nearest input row, inptr1 points to next nearest */
|
||||||
inptr0 = input_data[inrow];
|
inptr0 = input_data[inrow];
|
||||||
if (v == 0) /* next nearest is row above */
|
if (v == 0) { /* next nearest is row above */
|
||||||
inptr1 = input_data[inrow - 1];
|
inptr1 = input_data[inrow - 1];
|
||||||
else /* next nearest is row below */
|
bias = 1;
|
||||||
|
} else { /* next nearest is row below */
|
||||||
inptr1 = input_data[inrow + 1];
|
inptr1 = input_data[inrow + 1];
|
||||||
|
bias = 2;
|
||||||
|
}
|
||||||
outptr = output_data[outrow++];
|
outptr = output_data[outrow++];
|
||||||
|
|
||||||
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
for (colctr = 0; colctr < compptr->downsampled_width; colctr++) {
|
||||||
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
|
||||||
*outptr++ = (JSAMPLE)((thiscolsum + 1) >> 2);
|
*outptr++ = (JSAMPLE)((thiscolsum + bias) >> 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inrow++;
|
inrow++;
|
||||||
|
|||||||
84
jerror.h
84
jerror.h
@@ -28,7 +28,7 @@
|
|||||||
#define JMAKE_ENUM_LIST
|
#define JMAKE_ENUM_LIST
|
||||||
#else
|
#else
|
||||||
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
|
/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
|
||||||
#define JMESSAGE(code, string)
|
#define JMESSAGE(code,string)
|
||||||
#endif /* JERROR_H */
|
#endif /* JERROR_H */
|
||||||
#endif /* JMESSAGE */
|
#endif /* JMESSAGE */
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
||||||
#define JMESSAGE(code, string) code,
|
#define JMESSAGE(code,string) code ,
|
||||||
|
|
||||||
#endif /* JMAKE_ENUM_LIST */
|
#endif /* JMAKE_ENUM_LIST */
|
||||||
|
|
||||||
@@ -206,6 +206,10 @@ JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
|
|||||||
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
|
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
JMESSAGE(JERR_BAD_PARAM, "Bogus parameter")
|
||||||
|
JMESSAGE(JERR_BAD_PARAM_VALUE, "Bogus parameter value")
|
||||||
|
|
||||||
|
JMESSAGE(JERR_UNSUPPORTED_SUSPEND, "I/O suspension not supported in scan optimization")
|
||||||
JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
|
JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
|
||||||
|
|
||||||
#ifdef JMAKE_ENUM_LIST
|
#ifdef JMAKE_ENUM_LIST
|
||||||
@@ -227,90 +231,90 @@ JMESSAGE(JWRN_BOGUS_ICC, "Corrupt JPEG data: bad ICC marker")
|
|||||||
/* The first parameter is either type of cinfo pointer */
|
/* The first parameter is either type of cinfo pointer */
|
||||||
|
|
||||||
/* Fatal errors (print message and exit) */
|
/* Fatal errors (print message and exit) */
|
||||||
#define ERREXIT(cinfo, code) \
|
#define ERREXIT(cinfo,code) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
#define ERREXIT1(cinfo, code, p1) \
|
#define ERREXIT1(cinfo,code,p1) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
#define ERREXIT2(cinfo, code, p1, p2) \
|
#define ERREXIT2(cinfo,code,p1,p2) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
#define ERREXIT3(cinfo, code, p1, p2, p3) \
|
#define ERREXIT3(cinfo,code,p1,p2,p3) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
#define ERREXIT4(cinfo, code, p1, p2, p3, p4) \
|
#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||||
(cinfo)->err->msg_parm.i[2] = (p3), \
|
(cinfo)->err->msg_parm.i[2] = (p3), \
|
||||||
(cinfo)->err->msg_parm.i[3] = (p4), \
|
(cinfo)->err->msg_parm.i[3] = (p4), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
#define ERREXITS(cinfo, code, str) \
|
#define ERREXITS(cinfo,code,str) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||||
(*(cinfo)->err->error_exit) ((j_common_ptr)(cinfo)))
|
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
|
||||||
|
|
||||||
#define MAKESTMT(stuff) do { stuff } while (0)
|
#define MAKESTMT(stuff) do { stuff } while (0)
|
||||||
|
|
||||||
/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
|
/* Nonfatal errors (we can keep going, but the data is probably corrupt) */
|
||||||
#define WARNMS(cinfo, code) \
|
#define WARNMS(cinfo,code) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||||
#define WARNMS1(cinfo, code, p1) \
|
#define WARNMS1(cinfo,code,p1) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||||
#define WARNMS2(cinfo, code, p1, p2) \
|
#define WARNMS2(cinfo,code,p1,p2) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), -1))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
|
||||||
|
|
||||||
/* Informational/debugging messages */
|
/* Informational/debugging messages */
|
||||||
#define TRACEMS(cinfo, lvl, code) \
|
#define TRACEMS(cinfo,lvl,code) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||||
#define TRACEMS1(cinfo, lvl, code, p1) \
|
#define TRACEMS1(cinfo,lvl,code,p1) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||||
#define TRACEMS2(cinfo, lvl, code, p1, p2) \
|
#define TRACEMS2(cinfo,lvl,code,p1,p2) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
(cinfo)->err->msg_parm.i[0] = (p1), \
|
(cinfo)->err->msg_parm.i[0] = (p1), \
|
||||||
(cinfo)->err->msg_parm.i[1] = (p2), \
|
(cinfo)->err->msg_parm.i[1] = (p2), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||||
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3) \
|
#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \
|
||||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
|
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
|
||||||
(cinfo)->err->msg_code = (code); \
|
(cinfo)->err->msg_code = (code); \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||||
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4) \
|
#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \
|
||||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||||
(cinfo)->err->msg_code = (code); \
|
(cinfo)->err->msg_code = (code); \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||||
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5) \
|
#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \
|
||||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||||
_mp[4] = (p5); \
|
_mp[4] = (p5); \
|
||||||
(cinfo)->err->msg_code = (code); \
|
(cinfo)->err->msg_code = (code); \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||||
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8) \
|
#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \
|
||||||
MAKESTMT(int *_mp = (cinfo)->err->msg_parm.i; \
|
MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
|
||||||
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
_mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
|
||||||
_mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
|
_mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
|
||||||
(cinfo)->err->msg_code = (code); \
|
(cinfo)->err->msg_code = (code); \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)); )
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
|
||||||
#define TRACEMSS(cinfo, lvl, code, str) \
|
#define TRACEMSS(cinfo,lvl,code,str) \
|
||||||
((cinfo)->err->msg_code = (code), \
|
((cinfo)->err->msg_code = (code), \
|
||||||
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
|
||||||
(*(cinfo)->err->emit_message) ((j_common_ptr)(cinfo), (lvl)))
|
(*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
|
||||||
|
|
||||||
#endif /* JERROR_H */
|
#endif /* JERROR_H */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jfdctint.c
|
* jfdctint.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, D. R. Commander.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jidctint.c
|
* jidctint.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-1998, Thomas G. Lane.
|
* Copyright (C) 1991-1998, Thomas G. Lane.
|
||||||
* Modification developed 2002-2009 by Guido Vollbeding.
|
* Modification developed 2002-2009 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* jidctred.c
|
* jidctred.c
|
||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software.
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1994-1998, Thomas G. Lane.
|
* Copyright (C) 1994-1998, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015, D. R. Commander.
|
* Copyright (C) 2015, D. R. Commander.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1992-1996, Thomas G. Lane.
|
* Copyright (C) 1992-1996, Thomas G. Lane.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2017, D. R. Commander.
|
* Copyright (C) 2017-2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -72,7 +72,7 @@ jpeg_mem_available(j_common_ptr cinfo, size_t min_bytes_needed,
|
|||||||
size_t max_bytes_needed, size_t already_allocated)
|
size_t max_bytes_needed, size_t already_allocated)
|
||||||
{
|
{
|
||||||
if (cinfo->mem->max_memory_to_use) {
|
if (cinfo->mem->max_memory_to_use) {
|
||||||
if (cinfo->mem->max_memory_to_use > already_allocated)
|
if ((size_t)cinfo->mem->max_memory_to_use > already_allocated)
|
||||||
return cinfo->mem->max_memory_to_use - already_allocated;
|
return cinfo->mem->max_memory_to_use - already_allocated;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
16
jmorecfg.h
16
jmorecfg.h
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 1997-2009 by Guido Vollbeding.
|
* Modified 1997-2009 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
|
* Copyright (C) 2009, 2011, 2014-2015, 2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Maximum number of components (color channels) allowed in JPEG image.
|
* Maximum number of components (color channels) allowed in JPEG image.
|
||||||
* To meet the letter of the JPEG spec, set this to 255. However, darn
|
* To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
|
||||||
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
|
* However, darn few applications need more than 4 channels (maybe 5 for CMYK +
|
||||||
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
* alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
||||||
* really short on memory. (Each allowed component costs a hundred or so
|
* really short on memory. (Each allowed component costs a hundred or so
|
||||||
* bytes of storage, whether actually used in an image or not.)
|
* bytes of storage, whether actually used in an image or not.)
|
||||||
*/
|
*/
|
||||||
@@ -315,10 +315,10 @@ typedef int boolean;
|
|||||||
* with it. In reality, few people ever did this, because there were some
|
* with it. In reality, few people ever did this, because there were some
|
||||||
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
|
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
|
||||||
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
|
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
|
||||||
* quantizer wouldn't work with pixel sizes other than 3.) Further, since all
|
* quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
|
||||||
* of the O/S-supplied versions of libjpeg were built with the default values
|
* all of the O/S-supplied versions of libjpeg were built with the default
|
||||||
* of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
|
* values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
|
||||||
* come to regard these values as immutable.
|
* have come to regard these values as immutable.
|
||||||
*
|
*
|
||||||
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
|
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
|
||||||
* compressing from/decompressing to buffers with arbitrary component orders
|
* compressing from/decompressing to buffers with arbitrary component orders
|
||||||
|
|||||||
214
jpegint.h
214
jpegint.h
@@ -7,6 +7,8 @@
|
|||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015-2016, D. R. Commander.
|
* Copyright (C) 2015-2016, D. R. Commander.
|
||||||
* Copyright (C) 2015, Google, Inc.
|
* Copyright (C) 2015, Google, Inc.
|
||||||
|
* mozjpeg Modifications:
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -23,25 +25,26 @@ typedef enum { /* Operating modes for buffer controllers */
|
|||||||
/* Remaining modes require a full-image buffer to have been created */
|
/* Remaining modes require a full-image buffer to have been created */
|
||||||
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
|
JBUF_SAVE_SOURCE, /* Run source subobject only, save output */
|
||||||
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
|
JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */
|
||||||
JBUF_SAVE_AND_PASS /* Run both subobjects, save output */
|
JBUF_SAVE_AND_PASS, /* Run both subobjects, save output */
|
||||||
|
JBUF_REQUANT /* Requantize */
|
||||||
} J_BUF_MODE;
|
} J_BUF_MODE;
|
||||||
|
|
||||||
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
|
/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
|
||||||
#define CSTATE_START 100 /* after create_compress */
|
#define CSTATE_START 100 /* after create_compress */
|
||||||
#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
|
#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */
|
||||||
#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
|
#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */
|
||||||
#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
|
#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */
|
||||||
#define DSTATE_START 200 /* after create_decompress */
|
#define DSTATE_START 200 /* after create_decompress */
|
||||||
#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
|
#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */
|
||||||
#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
|
#define DSTATE_READY 202 /* found SOS, ready for start_decompress */
|
||||||
#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
|
#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/
|
||||||
#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
|
#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */
|
||||||
#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
|
#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */
|
||||||
#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
|
#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */
|
||||||
#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
|
#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */
|
||||||
#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
|
#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */
|
||||||
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
|
#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */
|
||||||
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
|
#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */
|
||||||
|
|
||||||
|
|
||||||
/* JLONG must hold at least signed 32-bit values. */
|
/* JLONG must hold at least signed 32-bit values. */
|
||||||
@@ -53,7 +56,7 @@ typedef long JLONG;
|
|||||||
* sanitizer warnings
|
* sanitizer warnings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
|
#define LEFT_SHIFT(a, b) ((JLONG)((unsigned long)(a) << (b)))
|
||||||
|
|
||||||
|
|
||||||
/* Declarations for compression modules */
|
/* Declarations for compression modules */
|
||||||
@@ -67,8 +70,67 @@ struct jpeg_comp_master {
|
|||||||
/* State variables made visible to other modules */
|
/* State variables made visible to other modules */
|
||||||
boolean call_pass_startup; /* True if pass_startup must be called */
|
boolean call_pass_startup; /* True if pass_startup must be called */
|
||||||
boolean is_last_pass; /* True during last pass */
|
boolean is_last_pass; /* True during last pass */
|
||||||
|
|
||||||
|
/* Extension parameters */
|
||||||
|
boolean optimize_scans; /* TRUE=optimize progressive coding scans */
|
||||||
|
boolean trellis_quant; /* TRUE=use trellis quantization */
|
||||||
|
boolean trellis_quant_dc; /* TRUE=use trellis quant for DC coefficient */
|
||||||
|
boolean trellis_eob_opt; /* TRUE=optimize for sequences of EOB */
|
||||||
|
boolean use_lambda_weight_tbl; /* TRUE=use lambda weighting table */
|
||||||
|
boolean use_scans_in_trellis; /* TRUE=use scans in trellis optimization */
|
||||||
|
boolean trellis_passes; /* TRUE=currently doing trellis-related passes [not exposed] */
|
||||||
|
boolean trellis_q_opt; /* TRUE=optimize quant table in trellis loop */
|
||||||
|
boolean overshoot_deringing; /* TRUE=preprocess input to reduce ringing of edges on white background */
|
||||||
|
|
||||||
|
double norm_src[NUM_QUANT_TBLS][DCTSIZE2];
|
||||||
|
double norm_coef[NUM_QUANT_TBLS][DCTSIZE2];
|
||||||
|
|
||||||
|
int compress_profile; /* compression profile */
|
||||||
|
int dc_scan_opt_mode; /* DC scan optimization mode */
|
||||||
|
int quant_tbl_master_idx; /* Quantization table master index */
|
||||||
|
int trellis_freq_split; /* splitting point for frequency in trellis quantization */
|
||||||
|
int trellis_num_loops; /* number of trellis loops */
|
||||||
|
|
||||||
|
int num_scans_luma; /* # of entries in scan_info array pertaining to luma (used when optimize_scans is TRUE */
|
||||||
|
int num_scans_luma_dc;
|
||||||
|
int num_scans_chroma_dc;
|
||||||
|
int num_frequency_splits;
|
||||||
|
|
||||||
|
int Al_max_luma; /* maximum value of Al tested when optimizing scans (luma) */
|
||||||
|
int Al_max_chroma; /* maximum value of Al tested when optimizing scans (chroma) */
|
||||||
|
|
||||||
|
float lambda_log_scale1;
|
||||||
|
float lambda_log_scale2;
|
||||||
|
|
||||||
|
float trellis_delta_dc_weight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
|
/* The following two definitions specify the allocation chunk size
|
||||||
|
* for the statistics area.
|
||||||
|
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
|
||||||
|
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
|
||||||
|
*
|
||||||
|
* We use a compact representation with 1 byte per statistics bin,
|
||||||
|
* thus the numbers directly represent byte sizes.
|
||||||
|
* This 1 byte per statistics bin contains the meaning of the MPS
|
||||||
|
* (more probable symbol) in the highest bit (mask 0x80), and the
|
||||||
|
* index into the probability estimation state machine table
|
||||||
|
* in the lower bits (mask 0x7F).
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DC_STAT_BINS 64
|
||||||
|
#define AC_STAT_BINS 256
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float rate_dc[DC_STAT_BINS][2];
|
||||||
|
float rate_ac[AC_STAT_BINS][2];
|
||||||
|
int arith_dc_L;
|
||||||
|
int arith_dc_U;
|
||||||
|
int arith_ac_K;
|
||||||
|
} arith_rates;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Main buffer control (downsampled-data buffer) */
|
/* Main buffer control (downsampled-data buffer) */
|
||||||
struct jpeg_c_main_controller {
|
struct jpeg_c_main_controller {
|
||||||
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
void (*start_pass) (j_compress_ptr cinfo, J_BUF_MODE pass_mode);
|
||||||
@@ -117,7 +179,7 @@ struct jpeg_forward_dct {
|
|||||||
void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
void (*forward_DCT) (j_compress_ptr cinfo, jpeg_component_info *compptr,
|
||||||
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
|
||||||
JDIMENSION start_row, JDIMENSION start_col,
|
JDIMENSION start_row, JDIMENSION start_col,
|
||||||
JDIMENSION num_blocks);
|
JDIMENSION num_blocks, JBLOCKROW dst);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Entropy encoding */
|
/* Entropy encoding */
|
||||||
@@ -274,9 +336,9 @@ struct jpeg_color_quantizer {
|
|||||||
/* Miscellaneous useful macros */
|
/* Miscellaneous useful macros */
|
||||||
|
|
||||||
#undef MAX
|
#undef MAX
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#undef MIN
|
#undef MIN
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
|
|
||||||
/* We assume that right shift corresponds to signed division by 2 with
|
/* We assume that right shift corresponds to signed division by 2 with
|
||||||
@@ -291,64 +353,80 @@ struct jpeg_color_quantizer {
|
|||||||
|
|
||||||
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
#ifdef RIGHT_SHIFT_IS_UNSIGNED
|
||||||
#define SHIFT_TEMPS JLONG shift_temp;
|
#define SHIFT_TEMPS JLONG shift_temp;
|
||||||
#define RIGHT_SHIFT(x, shft) \
|
#define RIGHT_SHIFT(x,shft) \
|
||||||
((shift_temp = (x)) < 0 ? \
|
((shift_temp = (x)) < 0 ? \
|
||||||
(shift_temp >> (shft)) | ((~((JLONG)0)) << (32 - (shft))) : \
|
(shift_temp >> (shft)) | ((~((JLONG) 0)) << (32-(shft))) : \
|
||||||
(shift_temp >> (shft)))
|
(shift_temp >> (shft)))
|
||||||
#else
|
#else
|
||||||
#define SHIFT_TEMPS
|
#define SHIFT_TEMPS
|
||||||
#define RIGHT_SHIFT(x, shft) ((x) >> (shft))
|
#define RIGHT_SHIFT(x,shft) ((x) >> (shft))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Compression module initialization routines */
|
/* Compression module initialization routines */
|
||||||
EXTERN(void) jinit_compress_master(j_compress_ptr cinfo);
|
EXTERN(void) jinit_compress_master (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_c_master_control(j_compress_ptr cinfo,
|
EXTERN(void) jinit_c_master_control (j_compress_ptr cinfo,
|
||||||
boolean transcode_only);
|
boolean transcode_only);
|
||||||
EXTERN(void) jinit_c_main_controller(j_compress_ptr cinfo,
|
EXTERN(void) jinit_c_main_controller (j_compress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_c_prep_controller(j_compress_ptr cinfo,
|
EXTERN(void) jinit_c_prep_controller (j_compress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_c_coef_controller(j_compress_ptr cinfo,
|
EXTERN(void) jinit_c_coef_controller (j_compress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_color_converter(j_compress_ptr cinfo);
|
EXTERN(void) jinit_color_converter (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_downsampler(j_compress_ptr cinfo);
|
EXTERN(void) jinit_downsampler (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_forward_dct(j_compress_ptr cinfo);
|
EXTERN(void) jinit_forward_dct (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_huff_encoder(j_compress_ptr cinfo);
|
EXTERN(void) jinit_huff_encoder (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_phuff_encoder(j_compress_ptr cinfo);
|
EXTERN(void) jinit_phuff_encoder (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_arith_encoder(j_compress_ptr cinfo);
|
EXTERN(void) jinit_arith_encoder (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jinit_marker_writer(j_compress_ptr cinfo);
|
EXTERN(void) jinit_marker_writer (j_compress_ptr cinfo);
|
||||||
/* Decompression module initialization routines */
|
/* Decompression module initialization routines */
|
||||||
EXTERN(void) jinit_master_decompress(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_master_decompress (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_d_main_controller(j_decompress_ptr cinfo,
|
EXTERN(void) jinit_d_main_controller (j_decompress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_d_coef_controller(j_decompress_ptr cinfo,
|
EXTERN(void) jinit_d_coef_controller (j_decompress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_d_post_controller(j_decompress_ptr cinfo,
|
EXTERN(void) jinit_d_post_controller (j_decompress_ptr cinfo,
|
||||||
boolean need_full_buffer);
|
boolean need_full_buffer);
|
||||||
EXTERN(void) jinit_input_controller(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_input_controller (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_marker_reader(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_marker_reader (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_huff_decoder(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_huff_decoder (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_phuff_decoder(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_phuff_decoder (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_arith_decoder(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_arith_decoder (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_inverse_dct(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_inverse_dct (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_upsampler(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_upsampler (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_color_deconverter(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_color_deconverter (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_1pass_quantizer(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_1pass_quantizer (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_2pass_quantizer(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_2pass_quantizer (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jinit_merged_upsampler(j_decompress_ptr cinfo);
|
EXTERN(void) jinit_merged_upsampler (j_decompress_ptr cinfo);
|
||||||
/* Memory manager initialization */
|
/* Memory manager initialization */
|
||||||
EXTERN(void) jinit_memory_mgr(j_common_ptr cinfo);
|
EXTERN(void) jinit_memory_mgr (j_common_ptr cinfo);
|
||||||
|
|
||||||
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
|
EXTERN(void)
|
||||||
|
jpeg_mem_dest_internal (j_compress_ptr cinfo,
|
||||||
|
unsigned char **outbuffer, unsigned long *outsize, int pool_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Utility routines in jutils.c */
|
/* Utility routines in jutils.c */
|
||||||
EXTERN(long) jdiv_round_up(long a, long b);
|
EXTERN(long) jdiv_round_up (long a, long b);
|
||||||
EXTERN(long) jround_up(long a, long b);
|
EXTERN(long) jround_up (long a, long b);
|
||||||
EXTERN(void) jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
|
EXTERN(void) jcopy_sample_rows (JSAMPARRAY input_array, int source_row,
|
||||||
JSAMPARRAY output_array, int dest_row,
|
JSAMPARRAY output_array, int dest_row,
|
||||||
int num_rows, JDIMENSION num_cols);
|
int num_rows, JDIMENSION num_cols);
|
||||||
EXTERN(void) jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
|
EXTERN(void) jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
|
||||||
JDIMENSION num_blocks);
|
JDIMENSION num_blocks);
|
||||||
EXTERN(void) jzero_far(void *target, size_t bytestozero);
|
EXTERN(void) jzero_far (void *target, size_t bytestozero);
|
||||||
|
|
||||||
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
|
EXTERN(void) jget_arith_rates (j_compress_ptr cinfo, int dc_tbl_no, int ac_tbl_no, arith_rates *r);
|
||||||
|
|
||||||
|
EXTERN(void) quantize_trellis_arith
|
||||||
|
(j_compress_ptr cinfo, arith_rates *r, JBLOCKROW coef_blocks, JBLOCKROW src, JDIMENSION num_blocks,
|
||||||
|
JQUANT_TBL * qtbl, double *norm_src, double *norm_coef, JCOEF *last_dc_val,
|
||||||
|
JBLOCKROW coef_blocks_above, JBLOCKROW src_above);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Constant tables in jutils.c */
|
/* Constant tables in jutils.c */
|
||||||
#if 0 /* This table is not actually needed in v6a */
|
#if 0 /* This table is not actually needed in v6a */
|
||||||
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
|
||||||
|
|||||||
272
jpeglib.h
272
jpeglib.h
@@ -7,6 +7,8 @@
|
|||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, D. R. Commander.
|
* Copyright (C) 2009-2011, 2013-2014, 2016-2017, D. R. Commander.
|
||||||
* Copyright (C) 2015, Google, Inc.
|
* Copyright (C) 2015, Google, Inc.
|
||||||
|
* mozjpeg Modifications:
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -211,8 +213,8 @@ struct jpeg_marker_struct {
|
|||||||
|
|
||||||
/* Known color spaces. */
|
/* Known color spaces. */
|
||||||
|
|
||||||
#define JCS_EXTENSIONS 1
|
#define JCS_EXTENSIONS 1
|
||||||
#define JCS_ALPHA_EXTENSIONS 1
|
#define JCS_ALPHA_EXTENSIONS 1
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
JCS_UNKNOWN, /* error/unspecified */
|
JCS_UNKNOWN, /* error/unspecified */
|
||||||
@@ -265,14 +267,60 @@ typedef enum {
|
|||||||
} J_DITHER_MODE;
|
} J_DITHER_MODE;
|
||||||
|
|
||||||
|
|
||||||
|
/* These 32-bit GUIDs and the corresponding jpeg_*_get_*_param()/
|
||||||
|
* jpeg_*_set_*_param() functions allow for extending the libjpeg API without
|
||||||
|
* breaking backward ABI compatibility. The actual parameters are stored in
|
||||||
|
* the opaque jpeg_comp_master and jpeg_decomp_master structs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Boolean extension parameters */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
JBOOLEAN_OPTIMIZE_SCANS = 0x680C061E, /* TRUE=optimize progressive coding scans */
|
||||||
|
JBOOLEAN_TRELLIS_QUANT = 0xC5122033, /* TRUE=use trellis quantization */
|
||||||
|
JBOOLEAN_TRELLIS_QUANT_DC = 0x339D4C0C, /* TRUE=use trellis quant for DC coefficient */
|
||||||
|
JBOOLEAN_TRELLIS_EOB_OPT = 0xD7F73780, /* TRUE=optimize for sequences of EOB */
|
||||||
|
JBOOLEAN_USE_LAMBDA_WEIGHT_TBL = 0x339DB65F, /* TRUE=use lambda weighting table */
|
||||||
|
JBOOLEAN_USE_SCANS_IN_TRELLIS = 0xFD841435, /* TRUE=use scans in trellis optimization */
|
||||||
|
JBOOLEAN_TRELLIS_Q_OPT = 0xE12AE269, /* TRUE=optimize quant table in trellis loop */
|
||||||
|
JBOOLEAN_OVERSHOOT_DERINGING = 0x3F4BBBF9 /* TRUE=preprocess input to reduce ringing of edges on white background */
|
||||||
|
} J_BOOLEAN_PARAM;
|
||||||
|
|
||||||
|
/* Floating point parameters */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
JFLOAT_LAMBDA_LOG_SCALE1 = 0x5B61A599,
|
||||||
|
JFLOAT_LAMBDA_LOG_SCALE2 = 0xB9BBAE03,
|
||||||
|
JFLOAT_TRELLIS_DELTA_DC_WEIGHT = 0x13775453
|
||||||
|
} J_FLOAT_PARAM;
|
||||||
|
|
||||||
|
/* Integer parameters */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
JINT_COMPRESS_PROFILE = 0xE9918625, /* compression profile */
|
||||||
|
JINT_TRELLIS_FREQ_SPLIT = 0x6FAFF127, /* splitting point for frequency in trellis quantization */
|
||||||
|
JINT_TRELLIS_NUM_LOOPS = 0xB63EBF39, /* number of trellis loops */
|
||||||
|
JINT_BASE_QUANT_TBL_IDX = 0x44492AB1, /* base quantization table index */
|
||||||
|
JINT_DC_SCAN_OPT_MODE = 0x0BE7AD3C /* DC scan optimization mode */
|
||||||
|
} J_INT_PARAM;
|
||||||
|
|
||||||
|
|
||||||
|
/* Values for the JINT_COMPRESS_PROFILE parameter (32-bit GUIDs) */
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JCP_MAX_COMPRESSION = 0x5D083AAD, /* best compression ratio (progressive, all mozjpeg extensions) */
|
||||||
|
JCP_FASTEST = 0x2AEA5CB4 /* libjpeg[-turbo] defaults (baseline, no mozjpeg extensions) */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Common fields between JPEG compression and decompression master structs. */
|
/* Common fields between JPEG compression and decompression master structs. */
|
||||||
|
|
||||||
#define jpeg_common_fields \
|
#define jpeg_common_fields \
|
||||||
struct jpeg_error_mgr *err; /* Error handler module */ \
|
struct jpeg_error_mgr *err; /* Error handler module */\
|
||||||
struct jpeg_memory_mgr *mem; /* Memory manager module */ \
|
struct jpeg_memory_mgr *mem; /* Memory manager module */\
|
||||||
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */ \
|
struct jpeg_progress_mgr *progress; /* Progress monitor, or NULL if none */\
|
||||||
void *client_data; /* Available for use by application */ \
|
void *client_data; /* Available for use by application */\
|
||||||
boolean is_decompressor; /* So common code can tell which is which */ \
|
boolean is_decompressor; /* So common code can tell which is which */\
|
||||||
int global_state /* For checking call sequence validity */
|
int global_state /* For checking call sequence validity */
|
||||||
|
|
||||||
/* Routines that are to be used by both halves of the library are declared
|
/* Routines that are to be used by both halves of the library are declared
|
||||||
@@ -466,6 +514,8 @@ struct jpeg_compress_struct {
|
|||||||
int script_space_size;
|
int script_space_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*jpeg_idct_method) (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||||
|
typedef void (*jpeg_idct_method_selector) (j_decompress_ptr cinfo, jpeg_component_info *compptr, jpeg_idct_method * set_idct_method, int * set_idct_category);
|
||||||
|
|
||||||
/* Master record for a decompression instance */
|
/* Master record for a decompression instance */
|
||||||
|
|
||||||
@@ -822,9 +872,9 @@ struct jpeg_source_mgr {
|
|||||||
* successful.
|
* successful.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
|
#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */
|
||||||
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
|
#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */
|
||||||
#define JPOOL_NUMPOOLS 2
|
#define JPOOL_NUMPOOLS 2
|
||||||
|
|
||||||
typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
|
typedef struct jvirt_sarray_control *jvirt_sarray_ptr;
|
||||||
typedef struct jvirt_barray_control *jvirt_barray_ptr;
|
typedef struct jvirt_barray_control *jvirt_barray_ptr;
|
||||||
@@ -888,7 +938,7 @@ typedef boolean (*jpeg_marker_parser_method) (j_decompress_ptr cinfo);
|
|||||||
|
|
||||||
|
|
||||||
/* Default error-management setup */
|
/* Default error-management setup */
|
||||||
EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
|
EXTERN(struct jpeg_error_mgr *) jpeg_std_error (struct jpeg_error_mgr *err);
|
||||||
|
|
||||||
/* Initialization of JPEG compression objects.
|
/* Initialization of JPEG compression objects.
|
||||||
* jpeg_create_compress() and jpeg_create_decompress() are the exported
|
* jpeg_create_compress() and jpeg_create_decompress() are the exported
|
||||||
@@ -898,82 +948,83 @@ EXTERN(struct jpeg_error_mgr *) jpeg_std_error(struct jpeg_error_mgr *err);
|
|||||||
* NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
|
* NB: you must set up the error-manager BEFORE calling jpeg_create_xxx.
|
||||||
*/
|
*/
|
||||||
#define jpeg_create_compress(cinfo) \
|
#define jpeg_create_compress(cinfo) \
|
||||||
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \
|
||||||
(size_t)sizeof(struct jpeg_compress_struct))
|
(size_t) sizeof(struct jpeg_compress_struct))
|
||||||
#define jpeg_create_decompress(cinfo) \
|
#define jpeg_create_decompress(cinfo) \
|
||||||
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \
|
||||||
(size_t)sizeof(struct jpeg_decompress_struct))
|
(size_t) sizeof(struct jpeg_decompress_struct))
|
||||||
EXTERN(void) jpeg_CreateCompress(j_compress_ptr cinfo, int version,
|
EXTERN(void) jpeg_CreateCompress (j_compress_ptr cinfo, int version,
|
||||||
size_t structsize);
|
size_t structsize);
|
||||||
EXTERN(void) jpeg_CreateDecompress(j_decompress_ptr cinfo, int version,
|
EXTERN(void) jpeg_CreateDecompress (j_decompress_ptr cinfo, int version,
|
||||||
size_t structsize);
|
size_t structsize);
|
||||||
/* Destruction of JPEG compression objects */
|
/* Destruction of JPEG compression objects */
|
||||||
EXTERN(void) jpeg_destroy_compress(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_destroy_compress (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jpeg_destroy_decompress(j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_destroy_decompress (j_decompress_ptr cinfo);
|
||||||
|
|
||||||
/* Standard data source and destination managers: stdio streams. */
|
/* Standard data source and destination managers: stdio streams. */
|
||||||
/* Caller is responsible for opening the file before and closing after. */
|
/* Caller is responsible for opening the file before and closing after. */
|
||||||
EXTERN(void) jpeg_stdio_dest(j_compress_ptr cinfo, FILE *outfile);
|
EXTERN(void) jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile);
|
||||||
EXTERN(void) jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile);
|
EXTERN(void) jpeg_stdio_src (j_decompress_ptr cinfo, FILE *infile);
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
/* Data source and destination managers: memory buffers. */
|
/* Data source and destination managers: memory buffers. */
|
||||||
EXTERN(void) jpeg_mem_dest(j_compress_ptr cinfo, unsigned char **outbuffer,
|
EXTERN(void) jpeg_mem_dest (j_compress_ptr cinfo, unsigned char **outbuffer,
|
||||||
unsigned long *outsize);
|
unsigned long *outsize);
|
||||||
EXTERN(void) jpeg_mem_src(j_decompress_ptr cinfo,
|
EXTERN(void) jpeg_mem_src (j_decompress_ptr cinfo,
|
||||||
const unsigned char *inbuffer, unsigned long insize);
|
const unsigned char *inbuffer, unsigned long insize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Default parameter setup for compression */
|
/* Default parameter setup for compression */
|
||||||
EXTERN(void) jpeg_set_defaults(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_set_defaults (j_compress_ptr cinfo);
|
||||||
/* Compression parameter setup aids */
|
/* Compression parameter setup aids */
|
||||||
EXTERN(void) jpeg_set_colorspace(j_compress_ptr cinfo,
|
EXTERN(void) jpeg_set_colorspace (j_compress_ptr cinfo,
|
||||||
J_COLOR_SPACE colorspace);
|
J_COLOR_SPACE colorspace);
|
||||||
EXTERN(void) jpeg_default_colorspace(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_default_colorspace (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jpeg_set_quality(j_compress_ptr cinfo, int quality,
|
EXTERN(void) jpeg_set_quality (j_compress_ptr cinfo, int quality,
|
||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
EXTERN(void) jpeg_set_linear_quality(j_compress_ptr cinfo, int scale_factor,
|
EXTERN(void) jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
EXTERN(void) jpeg_default_qtables(j_compress_ptr cinfo,
|
EXTERN(void) jpeg_default_qtables (j_compress_ptr cinfo,
|
||||||
boolean force_baseline);
|
boolean force_baseline);
|
||||||
#endif
|
#endif
|
||||||
EXTERN(void) jpeg_add_quant_table(j_compress_ptr cinfo, int which_tbl,
|
EXTERN(void) jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
|
||||||
const unsigned int *basic_table,
|
const unsigned int *basic_table,
|
||||||
int scale_factor, boolean force_baseline);
|
int scale_factor, boolean force_baseline);
|
||||||
EXTERN(int) jpeg_quality_scaling(int quality);
|
EXTERN(int) jpeg_quality_scaling (int quality);
|
||||||
EXTERN(void) jpeg_simple_progression(j_compress_ptr cinfo);
|
EXTERN(float) jpeg_float_quality_scaling (float quality);
|
||||||
EXTERN(void) jpeg_suppress_tables(j_compress_ptr cinfo, boolean suppress);
|
EXTERN(void) jpeg_simple_progression (j_compress_ptr cinfo);
|
||||||
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table(j_common_ptr cinfo);
|
EXTERN(void) jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress);
|
||||||
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table(j_common_ptr cinfo);
|
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table (j_common_ptr cinfo);
|
||||||
|
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table (j_common_ptr cinfo);
|
||||||
|
|
||||||
/* Main entry points for compression */
|
/* Main entry points for compression */
|
||||||
EXTERN(void) jpeg_start_compress(j_compress_ptr cinfo,
|
EXTERN(void) jpeg_start_compress (j_compress_ptr cinfo,
|
||||||
boolean write_all_tables);
|
boolean write_all_tables);
|
||||||
EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
|
EXTERN(JDIMENSION) jpeg_write_scanlines (j_compress_ptr cinfo,
|
||||||
JSAMPARRAY scanlines,
|
JSAMPARRAY scanlines,
|
||||||
JDIMENSION num_lines);
|
JDIMENSION num_lines);
|
||||||
EXTERN(void) jpeg_finish_compress(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_finish_compress (j_compress_ptr cinfo);
|
||||||
|
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
/* Precalculate JPEG dimensions for current compression parameters. */
|
/* Precalculate JPEG dimensions for current compression parameters. */
|
||||||
EXTERN(void) jpeg_calc_jpeg_dimensions(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
|
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */
|
||||||
EXTERN(JDIMENSION) jpeg_write_raw_data(j_compress_ptr cinfo, JSAMPIMAGE data,
|
EXTERN(JDIMENSION) jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
|
||||||
JDIMENSION num_lines);
|
JDIMENSION num_lines);
|
||||||
|
|
||||||
/* Write a special marker. See libjpeg.txt concerning safe usage. */
|
/* Write a special marker. See libjpeg.txt concerning safe usage. */
|
||||||
EXTERN(void) jpeg_write_marker(j_compress_ptr cinfo, int marker,
|
EXTERN(void) jpeg_write_marker (j_compress_ptr cinfo, int marker,
|
||||||
const JOCTET *dataptr, unsigned int datalen);
|
const JOCTET *dataptr, unsigned int datalen);
|
||||||
/* Same, but piecemeal. */
|
/* Same, but piecemeal. */
|
||||||
EXTERN(void) jpeg_write_m_header(j_compress_ptr cinfo, int marker,
|
EXTERN(void) jpeg_write_m_header (j_compress_ptr cinfo, int marker,
|
||||||
unsigned int datalen);
|
unsigned int datalen);
|
||||||
EXTERN(void) jpeg_write_m_byte(j_compress_ptr cinfo, int val);
|
EXTERN(void) jpeg_write_m_byte (j_compress_ptr cinfo, int val);
|
||||||
|
|
||||||
/* Alternate compression function: just write an abbreviated table file */
|
/* Alternate compression function: just write an abbreviated table file */
|
||||||
EXTERN(void) jpeg_write_tables(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_write_tables (j_compress_ptr cinfo);
|
||||||
|
|
||||||
/* Write ICC profile. See libjpeg.txt for usage information. */
|
/* Write ICC profile. See libjpeg.txt for usage information. */
|
||||||
EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
|
EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
|
||||||
@@ -982,11 +1033,11 @@ EXTERN(void) jpeg_write_icc_profile(j_compress_ptr cinfo,
|
|||||||
|
|
||||||
|
|
||||||
/* Decompression startup: read start of JPEG datastream to see what's there */
|
/* Decompression startup: read start of JPEG datastream to see what's there */
|
||||||
EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
|
EXTERN(int) jpeg_read_header (j_decompress_ptr cinfo, boolean require_image);
|
||||||
/* Return value is one of: */
|
/* Return value is one of: */
|
||||||
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */
|
||||||
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
#define JPEG_HEADER_OK 1 /* Found valid image datastream */
|
||||||
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
|
#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */
|
||||||
/* If you pass require_image = TRUE (normal case), you need not check for
|
/* If you pass require_image = TRUE (normal case), you need not check for
|
||||||
* a TABLES_ONLY return code; an abbreviated file will cause an error exit.
|
* a TABLES_ONLY return code; an abbreviated file will cause an error exit.
|
||||||
* JPEG_SUSPENDED is only possible if you use a data source module that can
|
* JPEG_SUSPENDED is only possible if you use a data source module that can
|
||||||
@@ -994,27 +1045,27 @@ EXTERN(int) jpeg_read_header(j_decompress_ptr cinfo, boolean require_image);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Main entry points for decompression */
|
/* Main entry points for decompression */
|
||||||
EXTERN(boolean) jpeg_start_decompress(j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_start_decompress (j_decompress_ptr cinfo);
|
||||||
EXTERN(JDIMENSION) jpeg_read_scanlines(j_decompress_ptr cinfo,
|
EXTERN(JDIMENSION) jpeg_read_scanlines (j_decompress_ptr cinfo,
|
||||||
JSAMPARRAY scanlines,
|
JSAMPARRAY scanlines,
|
||||||
JDIMENSION max_lines);
|
JDIMENSION max_lines);
|
||||||
EXTERN(JDIMENSION) jpeg_skip_scanlines(j_decompress_ptr cinfo,
|
EXTERN(JDIMENSION) jpeg_skip_scanlines (j_decompress_ptr cinfo,
|
||||||
JDIMENSION num_lines);
|
JDIMENSION num_lines);
|
||||||
EXTERN(void) jpeg_crop_scanline(j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
EXTERN(void) jpeg_crop_scanline (j_decompress_ptr cinfo, JDIMENSION *xoffset,
|
||||||
JDIMENSION *width);
|
JDIMENSION *width);
|
||||||
EXTERN(boolean) jpeg_finish_decompress(j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_finish_decompress (j_decompress_ptr cinfo);
|
||||||
|
|
||||||
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
|
/* Replaces jpeg_read_scanlines when reading raw downsampled data. */
|
||||||
EXTERN(JDIMENSION) jpeg_read_raw_data(j_decompress_ptr cinfo, JSAMPIMAGE data,
|
EXTERN(JDIMENSION) jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
|
||||||
JDIMENSION max_lines);
|
JDIMENSION max_lines);
|
||||||
|
|
||||||
/* Additional entry points for buffered-image mode. */
|
/* Additional entry points for buffered-image mode. */
|
||||||
EXTERN(boolean) jpeg_has_multiple_scans(j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_has_multiple_scans (const j_decompress_ptr cinfo);
|
||||||
EXTERN(boolean) jpeg_start_output(j_decompress_ptr cinfo, int scan_number);
|
EXTERN(boolean) jpeg_start_output (j_decompress_ptr cinfo, int scan_number);
|
||||||
EXTERN(boolean) jpeg_finish_output(j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_finish_output (j_decompress_ptr cinfo);
|
||||||
EXTERN(boolean) jpeg_input_complete(j_decompress_ptr cinfo);
|
EXTERN(boolean) jpeg_input_complete (const j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jpeg_new_colormap(j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_new_colormap (j_decompress_ptr cinfo);
|
||||||
EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
|
EXTERN(int) jpeg_consume_input (j_decompress_ptr cinfo);
|
||||||
/* Return value is one of: */
|
/* Return value is one of: */
|
||||||
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */
|
||||||
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
#define JPEG_REACHED_SOS 1 /* Reached start of new scan */
|
||||||
@@ -1024,25 +1075,25 @@ EXTERN(int) jpeg_consume_input(j_decompress_ptr cinfo);
|
|||||||
|
|
||||||
/* Precalculate output dimensions for current decompression parameters. */
|
/* Precalculate output dimensions for current decompression parameters. */
|
||||||
#if JPEG_LIB_VERSION >= 80
|
#if JPEG_LIB_VERSION >= 80
|
||||||
EXTERN(void) jpeg_core_output_dimensions(j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_core_output_dimensions (j_decompress_ptr cinfo);
|
||||||
#endif
|
#endif
|
||||||
EXTERN(void) jpeg_calc_output_dimensions(j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_calc_output_dimensions (j_decompress_ptr cinfo);
|
||||||
|
|
||||||
/* Control saving of COM and APPn markers into marker_list. */
|
/* Control saving of COM and APPn markers into marker_list. */
|
||||||
EXTERN(void) jpeg_save_markers(j_decompress_ptr cinfo, int marker_code,
|
EXTERN(void) jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
|
||||||
unsigned int length_limit);
|
unsigned int length_limit);
|
||||||
|
|
||||||
/* Install a special processing method for COM or APPn markers. */
|
/* Install a special processing method for COM or APPn markers. */
|
||||||
EXTERN(void) jpeg_set_marker_processor(j_decompress_ptr cinfo,
|
EXTERN(void) jpeg_set_marker_processor (j_decompress_ptr cinfo,
|
||||||
int marker_code,
|
int marker_code,
|
||||||
jpeg_marker_parser_method routine);
|
jpeg_marker_parser_method routine);
|
||||||
|
|
||||||
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
|
/* Read or write raw DCT coefficients --- useful for lossless transcoding. */
|
||||||
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients(j_decompress_ptr cinfo);
|
EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients (j_decompress_ptr cinfo);
|
||||||
EXTERN(void) jpeg_write_coefficients(j_compress_ptr cinfo,
|
EXTERN(void) jpeg_write_coefficients (j_compress_ptr cinfo,
|
||||||
jvirt_barray_ptr *coef_arrays);
|
jvirt_barray_ptr *coef_arrays);
|
||||||
EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
|
EXTERN(void) jpeg_copy_critical_parameters (const j_decompress_ptr srcinfo,
|
||||||
j_compress_ptr dstinfo);
|
j_compress_ptr dstinfo);
|
||||||
|
|
||||||
/* If you choose to abort compression or decompression before completing
|
/* If you choose to abort compression or decompression before completing
|
||||||
* jpeg_finish_(de)compress, then you need to clean up to release memory,
|
* jpeg_finish_(de)compress, then you need to clean up to release memory,
|
||||||
@@ -1050,23 +1101,50 @@ EXTERN(void) jpeg_copy_critical_parameters(j_decompress_ptr srcinfo,
|
|||||||
* if you're done with the JPEG object, but if you want to clean it up and
|
* if you're done with the JPEG object, but if you want to clean it up and
|
||||||
* reuse it, call this:
|
* reuse it, call this:
|
||||||
*/
|
*/
|
||||||
EXTERN(void) jpeg_abort_compress(j_compress_ptr cinfo);
|
EXTERN(void) jpeg_abort_compress (j_compress_ptr cinfo);
|
||||||
EXTERN(void) jpeg_abort_decompress(j_decompress_ptr cinfo);
|
EXTERN(void) jpeg_abort_decompress (j_decompress_ptr cinfo);
|
||||||
|
|
||||||
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
|
/* Generic versions of jpeg_abort and jpeg_destroy that work on either
|
||||||
* flavor of JPEG object. These may be more convenient in some places.
|
* flavor of JPEG object. These may be more convenient in some places.
|
||||||
*/
|
*/
|
||||||
EXTERN(void) jpeg_abort(j_common_ptr cinfo);
|
EXTERN(void) jpeg_abort (j_common_ptr cinfo);
|
||||||
EXTERN(void) jpeg_destroy(j_common_ptr cinfo);
|
EXTERN(void) jpeg_destroy (j_common_ptr cinfo);
|
||||||
|
|
||||||
/* Default restart-marker-resync procedure for use by data source modules */
|
/* Default restart-marker-resync procedure for use by data source modules */
|
||||||
EXTERN(boolean) jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired);
|
EXTERN(boolean) jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired);
|
||||||
|
|
||||||
|
/* Accessor functions for extension parameters */
|
||||||
|
#define JPEG_C_PARAM_SUPPORTED 1
|
||||||
|
EXTERN(boolean) jpeg_c_bool_param_supported (const j_compress_ptr cinfo,
|
||||||
|
J_BOOLEAN_PARAM param);
|
||||||
|
EXTERN(void) jpeg_c_set_bool_param (j_compress_ptr cinfo,
|
||||||
|
J_BOOLEAN_PARAM param, boolean value);
|
||||||
|
EXTERN(boolean) jpeg_c_get_bool_param (const j_compress_ptr cinfo,
|
||||||
|
J_BOOLEAN_PARAM param);
|
||||||
|
|
||||||
|
EXTERN(boolean) jpeg_c_float_param_supported (const j_compress_ptr cinfo,
|
||||||
|
J_FLOAT_PARAM param);
|
||||||
|
EXTERN(void) jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param,
|
||||||
|
float value);
|
||||||
|
EXTERN(float) jpeg_c_get_float_param (const j_compress_ptr cinfo,
|
||||||
|
J_FLOAT_PARAM param);
|
||||||
|
|
||||||
|
EXTERN(boolean) jpeg_c_int_param_supported (const j_compress_ptr cinfo,
|
||||||
|
J_INT_PARAM param);
|
||||||
|
EXTERN(void) jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param,
|
||||||
|
int value);
|
||||||
|
EXTERN(int) jpeg_c_get_int_param (const j_compress_ptr cinfo, J_INT_PARAM param);
|
||||||
/* Read ICC profile. See libjpeg.txt for usage information. */
|
/* Read ICC profile. See libjpeg.txt for usage information. */
|
||||||
EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
|
EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
|
||||||
JOCTET **icc_data_ptr,
|
JOCTET **icc_data_ptr,
|
||||||
unsigned int *icc_data_len);
|
unsigned int *icc_data_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Permit users to replace the IDCT method dynamically.
|
||||||
|
* The selector callback is called after the default idct implementation was choosen,
|
||||||
|
* and is able to override it.
|
||||||
|
*/
|
||||||
|
EXTERN(void) jpeg_set_idct_method_selector (j_decompress_ptr cinfo, jpeg_idct_method_selector selector);
|
||||||
|
|
||||||
/* These marker codes are exported since applications and data source modules
|
/* These marker codes are exported since applications and data source modules
|
||||||
* are likely to want to use them.
|
* are likely to want to use them.
|
||||||
|
|||||||
114
jpegtran.c
114
jpegtran.c
@@ -5,8 +5,9 @@
|
|||||||
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1995-2010, Thomas G. Lane, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2014, 2017, D. R. Commander.
|
* Copyright (C) 2010, 2014, 2017, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains a command-line user interface for JPEG transcoding.
|
* This file contains a command-line user interface for JPEG transcoding.
|
||||||
* It is very similar to cjpeg.c, and partly to djpeg.c, but provides
|
* It is very similar to cjpeg.c, and partly to djpeg.c, but provides
|
||||||
@@ -42,8 +43,11 @@
|
|||||||
static const char *progname; /* program name for error messages */
|
static const char *progname; /* program name for error messages */
|
||||||
static char *icc_filename; /* for -icc switch */
|
static char *icc_filename; /* for -icc switch */
|
||||||
static char *outfilename; /* for -outfile switch */
|
static char *outfilename; /* for -outfile switch */
|
||||||
|
static boolean prefer_smallest; /* use smallest of input or result file (if no image-changing options supplied) */
|
||||||
static JCOPY_OPTION copyoption; /* -copy switch */
|
static JCOPY_OPTION copyoption; /* -copy switch */
|
||||||
static jpeg_transform_info transformoption; /* image transformation options */
|
static jpeg_transform_info transformoption; /* image transformation options */
|
||||||
|
boolean memsrc = FALSE; /* for -memsrc switch */
|
||||||
|
#define INPUT_BUF_SIZE 4096
|
||||||
|
|
||||||
|
|
||||||
LOCAL(void)
|
LOCAL(void)
|
||||||
@@ -62,11 +66,13 @@ usage(void)
|
|||||||
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
|
fprintf(stderr, " -copy comments Copy only comment markers (default)\n");
|
||||||
fprintf(stderr, " -copy all Copy all extra markers\n");
|
fprintf(stderr, " -copy all Copy all extra markers\n");
|
||||||
#ifdef ENTROPY_OPT_SUPPORTED
|
#ifdef ENTROPY_OPT_SUPPORTED
|
||||||
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression)\n");
|
fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but slow compression, enabled by default)\n");
|
||||||
#endif
|
#endif
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
fprintf(stderr, " -progressive Create progressive JPEG file\n");
|
fprintf(stderr, " -progressive Create progressive JPEG file (enabled by default)\n");
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr, " -revert Revert to standard defaults (instead of mozjpeg defaults)\n");
|
||||||
|
fprintf(stderr, " -fastcrush Disable progressive scan optimization\n");
|
||||||
fprintf(stderr, "Switches for modifying the image:\n");
|
fprintf(stderr, "Switches for modifying the image:\n");
|
||||||
#if TRANSFORMS_SUPPORTED
|
#if TRANSFORMS_SUPPORTED
|
||||||
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
|
fprintf(stderr, " -crop WxH+X+Y Crop to a rectangular subarea\n");
|
||||||
@@ -139,7 +145,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
char *scansarg = NULL; /* saves -scans parm if any */
|
char *scansarg = NULL; /* saves -scans parm if any */
|
||||||
|
|
||||||
/* Set up default JPEG parameters. */
|
/* Set up default JPEG parameters. */
|
||||||
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
|
simple_progressive = cinfo->num_scans == 0 ? FALSE : TRUE;
|
||||||
|
#else
|
||||||
simple_progressive = FALSE;
|
simple_progressive = FALSE;
|
||||||
|
#endif
|
||||||
icc_filename = NULL;
|
icc_filename = NULL;
|
||||||
outfilename = NULL;
|
outfilename = NULL;
|
||||||
copyoption = JCOPYOPT_DEFAULT;
|
copyoption = JCOPYOPT_DEFAULT;
|
||||||
@@ -150,6 +160,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
transformoption.crop = FALSE;
|
transformoption.crop = FALSE;
|
||||||
transformoption.slow_hflip = FALSE;
|
transformoption.slow_hflip = FALSE;
|
||||||
cinfo->err->trace_level = 0;
|
cinfo->err->trace_level = 0;
|
||||||
|
prefer_smallest = TRUE;
|
||||||
|
|
||||||
/* Scan command line options, adjust parameters */
|
/* Scan command line options, adjust parameters */
|
||||||
|
|
||||||
@@ -169,6 +180,10 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Use arithmetic coding. */
|
/* Use arithmetic coding. */
|
||||||
#ifdef C_ARITH_CODING_SUPPORTED
|
#ifdef C_ARITH_CODING_SUPPORTED
|
||||||
cinfo->arith_code = TRUE;
|
cinfo->arith_code = TRUE;
|
||||||
|
|
||||||
|
/* No table optimization required for AC */
|
||||||
|
cinfo->optimize_coding = FALSE;
|
||||||
|
prefer_smallest = FALSE;
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
|
fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
|
||||||
progname);
|
progname);
|
||||||
@@ -198,6 +213,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
progname, argv[argn]);
|
progname, argv[argn]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
prefer_smallest = FALSE;
|
||||||
#else
|
#else
|
||||||
select_transform(JXFORM_NONE); /* force an error */
|
select_transform(JXFORM_NONE); /* force an error */
|
||||||
#endif
|
#endif
|
||||||
@@ -233,11 +249,16 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
} else if (keymatch(arg, "grayscale", 1) ||
|
prefer_smallest = FALSE;
|
||||||
keymatch(arg, "greyscale", 1)) {
|
|
||||||
|
} else if (keymatch(arg, "fastcrush", 4)) {
|
||||||
|
jpeg_c_set_bool_param(cinfo, JBOOLEAN_OPTIMIZE_SCANS, FALSE);
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "grayscale", 1) || keymatch(arg, "greyscale",1)) {
|
||||||
/* Force to grayscale. */
|
/* Force to grayscale. */
|
||||||
#if TRANSFORMS_SUPPORTED
|
#if TRANSFORMS_SUPPORTED
|
||||||
transformoption.force_grayscale = TRUE;
|
transformoption.force_grayscale = TRUE;
|
||||||
|
prefer_smallest = FALSE;
|
||||||
#else
|
#else
|
||||||
select_transform(JXFORM_NONE); /* force an error */
|
select_transform(JXFORM_NONE); /* force an error */
|
||||||
#endif
|
#endif
|
||||||
@@ -286,6 +307,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Select simple progressive mode. */
|
/* Select simple progressive mode. */
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
simple_progressive = TRUE;
|
simple_progressive = TRUE;
|
||||||
|
prefer_smallest = FALSE;
|
||||||
/* We must postpone execution until num_components is known. */
|
/* We must postpone execution until num_components is known. */
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
|
fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
|
||||||
@@ -312,6 +334,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* restart_interval will be computed during startup */
|
/* restart_interval will be computed during startup */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (keymatch(arg, "revert", 3)) {
|
||||||
|
/* revert to old JPEG default */
|
||||||
|
jpeg_c_set_int_param(cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
|
||||||
|
prefer_smallest = FALSE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "rotate", 2)) {
|
} else if (keymatch(arg, "rotate", 2)) {
|
||||||
/* Rotate 90, 180, or 270 degrees (measured clockwise). */
|
/* Rotate 90, 180, or 270 degrees (measured clockwise). */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
@@ -325,11 +352,14 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
prefer_smallest = FALSE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "scans", 1)) {
|
} else if (keymatch(arg, "scans", 1)) {
|
||||||
/* Set scan script. */
|
/* Set scan script. */
|
||||||
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
#ifdef C_MULTISCAN_FILES_SUPPORTED
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
usage();
|
usage();
|
||||||
|
prefer_smallest = FALSE;
|
||||||
scansarg = argv[argn];
|
scansarg = argv[argn];
|
||||||
/* We must postpone reading the file in case -progressive appears. */
|
/* We must postpone reading the file in case -progressive appears. */
|
||||||
#else
|
#else
|
||||||
@@ -341,14 +371,17 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
} else if (keymatch(arg, "transpose", 1)) {
|
} else if (keymatch(arg, "transpose", 1)) {
|
||||||
/* Transpose (across UL-to-LR axis). */
|
/* Transpose (across UL-to-LR axis). */
|
||||||
select_transform(JXFORM_TRANSPOSE);
|
select_transform(JXFORM_TRANSPOSE);
|
||||||
|
prefer_smallest = FALSE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "transverse", 6)) {
|
} else if (keymatch(arg, "transverse", 6)) {
|
||||||
/* Transverse transpose (across UR-to-LL axis). */
|
/* Transverse transpose (across UR-to-LL axis). */
|
||||||
select_transform(JXFORM_TRANSVERSE);
|
select_transform(JXFORM_TRANSVERSE);
|
||||||
|
prefer_smallest = FALSE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "trim", 3)) {
|
} else if (keymatch(arg, "trim", 3)) {
|
||||||
/* Trim off any partial edge MCUs that the transform can't handle. */
|
/* Trim off any partial edge MCUs that the transform can't handle. */
|
||||||
transformoption.trim = TRUE;
|
transformoption.trim = TRUE;
|
||||||
|
prefer_smallest = FALSE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
usage(); /* bogus switch */
|
usage(); /* bogus switch */
|
||||||
@@ -369,6 +402,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
if (!read_scan_script(cinfo, scansarg))
|
if (!read_scan_script(cinfo, scansarg))
|
||||||
usage();
|
usage();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return argn; /* return index of next arg (file name) */
|
return argn; /* return index of next arg (file name) */
|
||||||
@@ -395,6 +429,10 @@ main(int argc, char **argv)
|
|||||||
* single file pointer for sequential input and output operation.
|
* single file pointer for sequential input and output operation.
|
||||||
*/
|
*/
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
unsigned char *inbuffer = NULL;
|
||||||
|
unsigned long insize = 0;
|
||||||
|
unsigned char *outbuffer = NULL;
|
||||||
|
unsigned long outsize = 0;
|
||||||
FILE *icc_file;
|
FILE *icc_file;
|
||||||
JOCTET *icc_profile = NULL;
|
JOCTET *icc_profile = NULL;
|
||||||
long icc_len = 0;
|
long icc_len = 0;
|
||||||
@@ -497,6 +535,32 @@ main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Specify data source for decompression */
|
/* Specify data source for decompression */
|
||||||
|
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
|
||||||
|
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
|
||||||
|
== JCP_MAX_COMPRESSION)
|
||||||
|
memsrc = TRUE; /* needed to revert to original */
|
||||||
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
|
if (memsrc) {
|
||||||
|
size_t nbytes;
|
||||||
|
do {
|
||||||
|
inbuffer = (unsigned char *)realloc(inbuffer, insize + INPUT_BUF_SIZE);
|
||||||
|
if (inbuffer == NULL) {
|
||||||
|
fprintf(stderr, "%s: memory allocation failure\n", progname);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
nbytes = JFREAD(fp, &inbuffer[insize], INPUT_BUF_SIZE);
|
||||||
|
if (nbytes < INPUT_BUF_SIZE && ferror(fp)) {
|
||||||
|
if (file_index < argc)
|
||||||
|
fprintf(stderr, "%s: can't read from %s\n", progname,
|
||||||
|
argv[file_index]);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: can't read from stdin\n", progname);
|
||||||
|
}
|
||||||
|
insize += (unsigned long)nbytes;
|
||||||
|
} while (nbytes == INPUT_BUF_SIZE);
|
||||||
|
jpeg_mem_src(&srcinfo, inbuffer, insize);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
jpeg_stdio_src(&srcinfo, fp);
|
jpeg_stdio_src(&srcinfo, fp);
|
||||||
|
|
||||||
/* Enable saving of extra markers that we want to copy */
|
/* Enable saving of extra markers that we want to copy */
|
||||||
@@ -560,6 +624,13 @@ main(int argc, char **argv)
|
|||||||
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
|
file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);
|
||||||
|
|
||||||
/* Specify data destination for compression */
|
/* Specify data destination for compression */
|
||||||
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
|
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
|
||||||
|
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
|
||||||
|
== JCP_MAX_COMPRESSION)
|
||||||
|
jpeg_mem_dest(&dstinfo, &outbuffer, &outsize);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
jpeg_stdio_dest(&dstinfo, fp);
|
jpeg_stdio_dest(&dstinfo, fp);
|
||||||
|
|
||||||
/* Start compressor (note no image data is actually written here) */
|
/* Start compressor (note no image data is actually written here) */
|
||||||
@@ -579,6 +650,31 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Finish compression and release memory */
|
/* Finish compression and release memory */
|
||||||
jpeg_finish_compress(&dstinfo);
|
jpeg_finish_compress(&dstinfo);
|
||||||
|
|
||||||
|
#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
||||||
|
if (jpeg_c_int_param_supported(&dstinfo, JINT_COMPRESS_PROFILE) &&
|
||||||
|
jpeg_c_get_int_param(&dstinfo, JINT_COMPRESS_PROFILE)
|
||||||
|
== JCP_MAX_COMPRESSION) {
|
||||||
|
size_t nbytes;
|
||||||
|
|
||||||
|
unsigned char *buffer = outbuffer;
|
||||||
|
unsigned long size = outsize;
|
||||||
|
if (prefer_smallest && insize < size) {
|
||||||
|
size = insize;
|
||||||
|
buffer = inbuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbytes = JFWRITE(fp, buffer, size);
|
||||||
|
if (nbytes < size && ferror(fp)) {
|
||||||
|
if (file_index < argc)
|
||||||
|
fprintf(stderr, "%s: can't write to %s\n", progname,
|
||||||
|
argv[file_index]);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: can't write to stdout\n", progname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
jpeg_destroy_compress(&dstinfo);
|
jpeg_destroy_compress(&dstinfo);
|
||||||
(void)jpeg_finish_decompress(&srcinfo);
|
(void)jpeg_finish_decompress(&srcinfo);
|
||||||
jpeg_destroy_decompress(&srcinfo);
|
jpeg_destroy_decompress(&srcinfo);
|
||||||
@@ -591,8 +687,10 @@ main(int argc, char **argv)
|
|||||||
end_progress_monitor((j_common_ptr)&dstinfo);
|
end_progress_monitor((j_common_ptr)&dstinfo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (icc_profile != NULL)
|
free(inbuffer);
|
||||||
free(icc_profile);
|
free(outbuffer);
|
||||||
|
|
||||||
|
free(icc_profile);
|
||||||
|
|
||||||
/* All done. */
|
/* All done. */
|
||||||
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?
|
exit(jsrcerr.num_warnings + jdsterr.num_warnings ?
|
||||||
|
|||||||
172
jpegyuv.c
Normal file
172
jpegyuv.c
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* Written by Josh Aas and Tim Terriberry
|
||||||
|
* Copyright (c) 2013, Mozilla Corporation
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Mozilla Corporation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Input: JPEG YUV 4:2:0 */
|
||||||
|
/* Output: YUV 4:2:0 */
|
||||||
|
|
||||||
|
/* gcc -std=c99 jpegyuv.c -I/opt/local/include/ -L/opt/local/lib/ -ljpeg -o jpegyuv */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "jpeglib.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
const char *jpg_path;
|
||||||
|
const char *yuv_path;
|
||||||
|
struct jpeg_decompress_struct cinfo;
|
||||||
|
struct jpeg_error_mgr jerr;
|
||||||
|
FILE *jpg_fd;
|
||||||
|
int luma_width;
|
||||||
|
int luma_height;
|
||||||
|
int chroma_width;
|
||||||
|
int chroma_height;
|
||||||
|
int frame_width;
|
||||||
|
int yuv_size;
|
||||||
|
JSAMPLE *jpg_buffer;
|
||||||
|
JSAMPROW yrow_pointer[16];
|
||||||
|
JSAMPROW cbrow_pointer[8];
|
||||||
|
JSAMPROW crrow_pointer[8];
|
||||||
|
JSAMPROW *plane_pointer[3];
|
||||||
|
unsigned char *yuv_buffer;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
FILE *yuv_fd;
|
||||||
|
|
||||||
|
if (argc != 3) {
|
||||||
|
fprintf(stderr, "Required arguments:\n");
|
||||||
|
fprintf(stderr, "1. Path to JPG input file\n");
|
||||||
|
fprintf(stderr, "2. Path to YUV output file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Will check these for validity when opening via 'fopen'. */
|
||||||
|
jpg_path = argv[1];
|
||||||
|
yuv_path = argv[2];
|
||||||
|
|
||||||
|
cinfo.err = jpeg_std_error(&jerr);
|
||||||
|
jpeg_create_decompress(&cinfo);
|
||||||
|
|
||||||
|
jpg_fd = fopen(jpg_path, "rb");
|
||||||
|
if (!jpg_fd) {
|
||||||
|
fprintf(stderr, "Invalid path to JPEG file!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
jpeg_stdio_src(&cinfo, jpg_fd);
|
||||||
|
|
||||||
|
jpeg_read_header(&cinfo, TRUE);
|
||||||
|
|
||||||
|
cinfo.raw_data_out = TRUE;
|
||||||
|
cinfo.do_fancy_upsampling = FALSE;
|
||||||
|
|
||||||
|
jpeg_start_decompress(&cinfo);
|
||||||
|
|
||||||
|
luma_width = cinfo.output_width;
|
||||||
|
luma_height = cinfo.output_height;
|
||||||
|
|
||||||
|
chroma_width = (luma_width + 1) >> 1;
|
||||||
|
chroma_height = (luma_height + 1) >> 1;
|
||||||
|
|
||||||
|
yuv_size = luma_width*luma_height + 2*chroma_width*chroma_height;
|
||||||
|
yuv_buffer = malloc(yuv_size);
|
||||||
|
if (!yuv_buffer) {
|
||||||
|
fclose(jpg_fd);
|
||||||
|
fprintf(stderr, "Memory allocation failure!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame_width = (cinfo.output_width + (16 - 1)) & ~(16 - 1);
|
||||||
|
|
||||||
|
jpg_buffer = malloc(frame_width*16 + 2*(frame_width/2)*8);
|
||||||
|
if (!jpg_buffer) {
|
||||||
|
fclose(jpg_fd);
|
||||||
|
free(yuv_buffer);
|
||||||
|
fprintf(stderr, "Memory allocation failure!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
plane_pointer[0] = yrow_pointer;
|
||||||
|
plane_pointer[1] = cbrow_pointer;
|
||||||
|
plane_pointer[2] = crrow_pointer;
|
||||||
|
|
||||||
|
for (y = 0; y < 16; y++) {
|
||||||
|
yrow_pointer[y] = &jpg_buffer[frame_width*y];
|
||||||
|
}
|
||||||
|
for (y = 0; y < 8; y++) {
|
||||||
|
cbrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*y];
|
||||||
|
crrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*(8 + y)];
|
||||||
|
}
|
||||||
|
|
||||||
|
while (cinfo.output_scanline < cinfo.output_height) {
|
||||||
|
int luma_scanline;
|
||||||
|
int chroma_scanline;
|
||||||
|
|
||||||
|
luma_scanline = cinfo.output_scanline;
|
||||||
|
chroma_scanline = (luma_scanline + 1) >> 1;
|
||||||
|
|
||||||
|
jpeg_read_raw_data(&cinfo, plane_pointer, 16);
|
||||||
|
|
||||||
|
for (y = 0; y < 16 && luma_scanline + y < luma_height; y++) {
|
||||||
|
for (x = 0; x < luma_width; x++) {
|
||||||
|
yuv_buffer[luma_width*(luma_scanline + y) + x] = yrow_pointer[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (y = 0; y < 8 && chroma_scanline + y < chroma_height; y++) {
|
||||||
|
for (x = 0; x < chroma_width; x++) {
|
||||||
|
yuv_buffer[luma_width*luma_height +
|
||||||
|
chroma_width*(chroma_scanline + y) + x] = cbrow_pointer[y][x];
|
||||||
|
yuv_buffer[luma_width*luma_height + chroma_width*chroma_height +
|
||||||
|
chroma_width*(chroma_scanline + y) + x] = crrow_pointer[y][x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jpeg_finish_decompress(&cinfo);
|
||||||
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
|
||||||
|
fclose(jpg_fd);
|
||||||
|
free(jpg_buffer);
|
||||||
|
|
||||||
|
yuv_fd = fopen(yuv_path, "wb");
|
||||||
|
if (!yuv_fd) {
|
||||||
|
fprintf(stderr, "Invalid path to YUV file!");
|
||||||
|
free(yuv_buffer);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (fwrite(yuv_buffer, yuv_size, 1, yuv_fd) != 1) {
|
||||||
|
fprintf(stderr, "Error writing yuv file\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(yuv_fd);
|
||||||
|
free(yuv_buffer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -154,7 +154,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
boolean is_padded; /* is the colorindex padded for odither? */
|
boolean is_padded; /* is the colorindex padded for odither? */
|
||||||
|
|
||||||
int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */
|
int Ncolors[MAX_Q_COMPS]; /* # of values allocated to each component */
|
||||||
|
|
||||||
/* Variables for ordered dithering */
|
/* Variables for ordered dithering */
|
||||||
int row_index; /* cur row's vertical index in dither matrix */
|
int row_index; /* cur row's vertical index in dither matrix */
|
||||||
|
|||||||
14
jversion.h
14
jversion.h
@@ -4,9 +4,10 @@
|
|||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
* Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2010, 2012-2017, D. R. Commander.
|
* Copyright (C) 2010, 2012-2020, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* mozjpeg Modifications:
|
||||||
* file.
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
*
|
*
|
||||||
* This file contains software version identification.
|
* This file contains software version identification.
|
||||||
*/
|
*/
|
||||||
@@ -36,11 +37,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define JCOPYRIGHT \
|
#define JCOPYRIGHT \
|
||||||
"Copyright (C) 2009-2017 D. R. Commander\n" \
|
"Copyright (C) 2009-2020 D. R. Commander\n" \
|
||||||
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
"Copyright (C) 2011-2016 Siarhei Siamashka\n" \
|
||||||
"Copyright (C) 2015-2016 Matthieu Darbois\n" \
|
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
|
||||||
"Copyright (C) 2015 Intel Corporation\n" \
|
"Copyright (C) 2015 Intel Corporation\n" \
|
||||||
"Copyright (C) 2015 Google, Inc.\n" \
|
"Copyright (C) 2015 Google, Inc.\n" \
|
||||||
|
"Copyright (C) 2014 Mozilla Corporation\n" \
|
||||||
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
"Copyright (C) 2013-2014 MIPS Technologies, Inc.\n" \
|
||||||
"Copyright (C) 2013 Linaro Limited\n" \
|
"Copyright (C) 2013 Linaro Limited\n" \
|
||||||
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
"Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)\n" \
|
||||||
@@ -49,4 +51,4 @@
|
|||||||
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
|
"Copyright (C) 1991-2016 Thomas G. Lane, Guido Vollbeding"
|
||||||
|
|
||||||
#define JCOPYRIGHT_SHORT \
|
#define JCOPYRIGHT_SHORT \
|
||||||
"Copyright (C) 1991-2017 The libjpeg-turbo Project and many others"
|
"Copyright (C) 1991-2020 The libjpeg-turbo Project and many others"
|
||||||
|
|||||||
19
libjpeg.txt
19
libjpeg.txt
@@ -3,7 +3,7 @@ USING THE IJG JPEG LIBRARY
|
|||||||
This file was part of the Independent JPEG Group's software:
|
This file was part of the Independent JPEG Group's software:
|
||||||
Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
|
Copyright (C) 1994-2013, Thomas G. Lane, Guido Vollbeding.
|
||||||
libjpeg-turbo Modifications:
|
libjpeg-turbo Modifications:
|
||||||
Copyright (C) 2010, 2014-2017, D. R. Commander.
|
Copyright (C) 2010, 2014-2018, D. R. Commander.
|
||||||
Copyright (C) 2015, Google, Inc.
|
Copyright (C) 2015, Google, Inc.
|
||||||
For conditions of distribution and use, see the accompanying README.ijg file.
|
For conditions of distribution and use, see the accompanying README.ijg file.
|
||||||
|
|
||||||
@@ -388,13 +388,13 @@ to the total image height. In most applications it is convenient to pass
|
|||||||
just one or a few scanlines at a time. The expected format for the passed
|
just one or a few scanlines at a time. The expected format for the passed
|
||||||
data is discussed under "Data formats", above.
|
data is discussed under "Data formats", above.
|
||||||
|
|
||||||
Image data should be written in top-to-bottom scanline order. The JPEG spec
|
Image data should be written in top-to-bottom scanline order.
|
||||||
contains some weasel wording about how top and bottom are application-defined
|
Rec. ITU-T T.81 | ISO/IEC 10918-1 says, "Applications determine which edges of
|
||||||
terms (a curious interpretation of the English language...) but if you want
|
a source image are defined as top, bottom, left, and right." However, if you
|
||||||
your files to be compatible with everyone else's, you WILL use top-to-bottom
|
want your files to be compatible with everyone else's, then top-to-bottom order
|
||||||
order. If the source data must be read in bottom-to-top order, you can use
|
must be used. If the source data must be read in bottom-to-top order, then you
|
||||||
the JPEG library's virtual array mechanism to invert the data efficiently.
|
can use the JPEG library's virtual array mechanism to invert the data
|
||||||
Examples of this can be found in the sample application cjpeg.
|
efficiently. Examples of this can be found in the sample application cjpeg.
|
||||||
|
|
||||||
The library maintains a count of the number of scanlines written so far
|
The library maintains a count of the number of scanlines written so far
|
||||||
in the next_scanline field of the JPEG object. Usually you can just use
|
in the next_scanline field of the JPEG object. Usually you can just use
|
||||||
@@ -917,7 +917,8 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
|
|||||||
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
|
||||||
boolean force_baseline)
|
boolean force_baseline)
|
||||||
Same as jpeg_set_quality() except that the generated tables are the
|
Same as jpeg_set_quality() except that the generated tables are the
|
||||||
sample tables given in the JPEC spec section K.1, multiplied by the
|
sample tables given in Annex K (Clause K.1) of
|
||||||
|
Rec. ITU-T T.81 (1992) | ISO/IEC 10918-1:1994, multiplied by the
|
||||||
specified scale factor (which is expressed as a percentage; thus
|
specified scale factor (which is expressed as a percentage; thus
|
||||||
scale_factor = 100 reproduces the spec's tables). Note that larger
|
scale_factor = 100 reproduces the spec's tables). Note that larger
|
||||||
scale factors give lower quality. This entry point is useful for
|
scale factors give lower quality. This entry point is useful for
|
||||||
|
|||||||
489
md5/md5.c
489
md5/md5.c
@@ -1,322 +1,275 @@
|
|||||||
/*
|
/*
|
||||||
* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
|
* This code implements the MD5 message-digest algorithm.
|
||||||
|
* The algorithm is due to Ron Rivest. This code was
|
||||||
|
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||||
|
* This code is in the public domain; do with it what you wish.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
|
* Equivalent code is available from RSA Data Security, Inc.
|
||||||
* All rights reserved.
|
* This code has been tested against that, and is equivalent,
|
||||||
|
* except that you don't need to include two pages of legalese
|
||||||
|
* with every copy.
|
||||||
*
|
*
|
||||||
* License to copy and use this software is granted provided that it
|
* To compute the message digest of a chunk of bytes, declare an
|
||||||
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||||
* Algorithm" in all material mentioning or referencing this software
|
* needed on buffers full of bytes, and then call MD5Final, which
|
||||||
* or this function.
|
* will fill a supplied 16-byte array with the digest.
|
||||||
|
* ----------------------------------------------------------------------------
|
||||||
|
* libjpeg-turbo Modifications:
|
||||||
|
* Copyright (C)2018, D. R. Commander. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* License is also granted to make and use derivative works provided
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* that such works are identified as "derived from the RSA Data
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
||||||
* mentioning or referencing the derived work.
|
|
||||||
*
|
*
|
||||||
* RSA Data Security, Inc. makes no representations concerning either
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
* the merchantability of this software or the suitability of this
|
* this list of conditions and the following disclaimer.
|
||||||
* software for any particular purpose. It is provided "as is"
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
* without express or implied warranty of any kind.
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* - Neither the name of the libjpeg-turbo Project nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* These notices must be retained in any copies of any part of this
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||||
* documentation and/or software.
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
*
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* This code is the same as the code published by RSA Inc. It has been
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||||
* edited for clarity and style only.
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <string.h> /* for memcpy() */
|
||||||
#include <string.h>
|
#include "md5.h"
|
||||||
|
|
||||||
#include "./md5.h"
|
|
||||||
|
|
||||||
#ifdef __amigaos4__
|
|
||||||
#include <machine/endian.h>
|
|
||||||
#define le32toh(x) (((x & 0xff) << 24) | \
|
|
||||||
((x & 0xff00) << 8) | \
|
|
||||||
((x & 0xff0000) >> 8) | \
|
|
||||||
((x & 0xff000000) >> 24))
|
|
||||||
#define htole32(x) le32toh(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void MD5Transform(unsigned int [4], const unsigned char [64]);
|
|
||||||
|
|
||||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||||
#define Encode memcpy
|
#define byteReverse(buf, len) /* Nothing */
|
||||||
#define Decode memcpy
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OS X doesn't have le32toh() or htole32()
|
* Note: this code is harmless on little-endian machines.
|
||||||
*/
|
*/
|
||||||
#ifdef __APPLE__
|
static void byteReverse(unsigned char *buf, unsigned int longs)
|
||||||
#include <libkern/OSByteOrder.h>
|
{
|
||||||
#define le32toh(x) OSSwapLittleToHostInt32(x)
|
uint32 t;
|
||||||
#define htole32(x) OSSwapHostToLittleInt32(x)
|
do {
|
||||||
|
t = (uint32)((unsigned int)buf[3] << 8 | buf[2]) << 16 |
|
||||||
|
((unsigned int)buf[1] << 8 | buf[0]);
|
||||||
|
*(uint32 *)buf = t;
|
||||||
|
buf += 4;
|
||||||
|
} while (--longs);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encodes input (unsigned int) into output (unsigned char). Assumes len is
|
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||||
* a multiple of 4.
|
* initialization constants.
|
||||||
*/
|
*/
|
||||||
|
void MD5Init(struct MD5Context *ctx)
|
||||||
static void Encode(unsigned char *output, unsigned int *input,
|
|
||||||
unsigned int len)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
ctx->buf[0] = 0x67452301;
|
||||||
unsigned int *op = (unsigned int *)output;
|
ctx->buf[1] = 0xefcdab89;
|
||||||
|
ctx->buf[2] = 0x98badcfe;
|
||||||
|
ctx->buf[3] = 0x10325476;
|
||||||
|
|
||||||
for (i = 0; i < len / 4; i++)
|
ctx->bits[0] = 0;
|
||||||
op[i] = htole32(input[i]);
|
ctx->bits[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decodes input (unsigned char) into output (unsigned int). Assumes len is
|
* Update context to reflect the concatenation of another buffer full
|
||||||
* a multiple of 4.
|
* of bytes.
|
||||||
*/
|
*/
|
||||||
|
void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned int len)
|
||||||
static void Decode(unsigned int *output, const unsigned char *input,
|
|
||||||
unsigned int len)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint32 t;
|
||||||
const unsigned int *ip = (const unsigned int *)input;
|
|
||||||
|
|
||||||
for (i = 0; i < len / 4; i++)
|
/* Update bitcount */
|
||||||
output[i] = le32toh(ip[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static unsigned char PADDING[64] = {
|
t = ctx->bits[0];
|
||||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
if ((ctx->bits[0] = t + ((uint32)len << 3)) < t)
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
ctx->bits[1]++; /* Carry from low to high */
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
ctx->bits[1] += len >> 29;
|
||||||
};
|
|
||||||
|
|
||||||
/* F, G, H and I are basic MD5 functions. */
|
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
|
||||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
|
||||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
|
||||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
|
||||||
|
|
||||||
/* ROTATE_LEFT rotates x left n bits. */
|
/* Handle any leading odd-sized chunks */
|
||||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
|
||||||
|
|
||||||
/*
|
if (t) {
|
||||||
* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
unsigned char *p = (unsigned char *)ctx->in + t;
|
||||||
* Rotation is separate from addition to prevent recomputation.
|
|
||||||
*/
|
|
||||||
#define FF(a, b, c, d, x, s, ac) { \
|
|
||||||
(a) += F((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
|
||||||
(a) += (b); \
|
|
||||||
}
|
|
||||||
#define GG(a, b, c, d, x, s, ac) { \
|
|
||||||
(a) += G((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
|
||||||
(a) += (b); \
|
|
||||||
}
|
|
||||||
#define HH(a, b, c, d, x, s, ac) { \
|
|
||||||
(a) += H((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
|
||||||
(a) += (b); \
|
|
||||||
}
|
|
||||||
#define II(a, b, c, d, x, s, ac) { \
|
|
||||||
(a) += I((b), (c), (d)) + (x) + (unsigned int)(ac); \
|
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
|
||||||
(a) += (b); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
|
t = 64 - t;
|
||||||
|
if (len < t) {
|
||||||
|
memcpy(p, buf, len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy(p, buf, t);
|
||||||
|
byteReverse(ctx->in, 16);
|
||||||
|
MD5Transform(ctx->buf, (uint32 *)ctx->in);
|
||||||
|
buf += t;
|
||||||
|
len -= t;
|
||||||
|
}
|
||||||
|
/* Process data in 64-byte chunks */
|
||||||
|
|
||||||
void MD5Init(MD5_CTX *context)
|
while (len >= 64) {
|
||||||
{
|
memcpy(ctx->in, buf, 64);
|
||||||
context->count[0] = context->count[1] = 0;
|
byteReverse(ctx->in, 16);
|
||||||
|
MD5Transform(ctx->buf, (uint32 *)ctx->in);
|
||||||
|
buf += 64;
|
||||||
|
len -= 64;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load magic initialization constants. */
|
/* Handle any remaining bytes of data. */
|
||||||
context->state[0] = 0x67452301;
|
|
||||||
context->state[1] = 0xefcdab89;
|
memcpy(ctx->in, buf, len);
|
||||||
context->state[2] = 0x98badcfe;
|
|
||||||
context->state[3] = 0x10325476;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MD5 block update operation. Continues an MD5 message-digest
|
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||||
* operation, processing another message block, and updating the
|
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||||
* context.
|
|
||||||
*/
|
*/
|
||||||
|
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
||||||
void MD5Update(MD5_CTX *context, const void *in, unsigned int inputLen)
|
|
||||||
{
|
{
|
||||||
unsigned int i, idx, partLen;
|
unsigned int count;
|
||||||
const unsigned char *input = in;
|
unsigned char *p;
|
||||||
|
uint32 *in32 = (uint32 *)ctx->in;
|
||||||
|
|
||||||
/* Compute number of bytes mod 64 */
|
/* Compute number of bytes mod 64 */
|
||||||
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
|
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||||
|
|
||||||
/* Update number of bits */
|
/* Set the first char of padding to 0x80. This is safe since there is
|
||||||
if ((context->count[0] += ((unsigned int)inputLen << 3)) <
|
always at least one byte free */
|
||||||
((unsigned int)inputLen << 3))
|
p = ctx->in + count;
|
||||||
context->count[1]++;
|
*p++ = 0x80;
|
||||||
context->count[1] += ((unsigned int)inputLen >> 29);
|
|
||||||
|
|
||||||
partLen = 64 - idx;
|
/* Bytes of padding needed to make 64 bytes */
|
||||||
|
count = 64 - 1 - count;
|
||||||
|
|
||||||
/* Transform as many times as possible. */
|
/* Pad out to 56 mod 64 */
|
||||||
if (inputLen >= partLen) {
|
if (count < 8) {
|
||||||
memcpy((void *)&context->buffer[idx], (const void *)input, partLen);
|
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||||
MD5Transform(context->state, context->buffer);
|
memset(p, 0, count);
|
||||||
|
byteReverse(ctx->in, 16);
|
||||||
|
MD5Transform(ctx->buf, (uint32 *)ctx->in);
|
||||||
|
|
||||||
for (i = partLen; i + 63 < inputLen; i += 64)
|
/* Now fill the next block with 56 bytes */
|
||||||
MD5Transform(context->state, &input[i]);
|
memset(ctx->in, 0, 56);
|
||||||
|
} else {
|
||||||
|
/* Pad block to 56 bytes */
|
||||||
|
memset(p, 0, count - 8);
|
||||||
|
}
|
||||||
|
byteReverse(ctx->in, 14);
|
||||||
|
|
||||||
idx = 0;
|
/* Append length in bits and transform */
|
||||||
} else
|
in32[14] = ctx->bits[0];
|
||||||
i = 0;
|
in32[15] = ctx->bits[1];
|
||||||
|
|
||||||
/* Buffer remaining input */
|
MD5Transform(ctx->buf, (uint32 *)ctx->in);
|
||||||
memcpy((void *)&context->buffer[idx], (const void *)&input[i], inputLen - i);
|
byteReverse((unsigned char *)ctx->buf, 4);
|
||||||
|
memcpy(digest, ctx->buf, 16);
|
||||||
|
memset(ctx, 0, sizeof(struct MD5Context)); /* In case it's sensitive */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* The four core functions - F1 is optimized somewhat */
|
||||||
|
|
||||||
|
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||||
|
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||||
|
#define F2(x, y, z) F1(z, x, y)
|
||||||
|
#define F3(x, y, z) (x ^ y ^ z)
|
||||||
|
#define F4(x, y, z) (y ^ (x | ~z))
|
||||||
|
|
||||||
|
/* This is the central step in the MD5 algorithm. */
|
||||||
|
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||||
|
( w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MD5 padding. Adds padding followed by original length.
|
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||||
|
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||||
|
* the data and converts bytes into longwords for this routine.
|
||||||
*/
|
*/
|
||||||
|
void MD5Transform(uint32 buf[4], uint32 in[16])
|
||||||
void MD5Pad(MD5_CTX *context)
|
|
||||||
{
|
{
|
||||||
unsigned char bits[8];
|
register uint32 a, b, c, d;
|
||||||
unsigned int idx, padLen;
|
|
||||||
|
|
||||||
/* Save number of bits */
|
a = buf[0];
|
||||||
Encode(bits, context->count, 8);
|
b = buf[1];
|
||||||
|
c = buf[2];
|
||||||
|
d = buf[3];
|
||||||
|
|
||||||
/* Pad out to 56 mod 64. */
|
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||||
idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
|
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||||
padLen = (idx < 56) ? (56 - idx) : (120 - idx);
|
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||||
MD5Update(context, PADDING, padLen);
|
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||||
|
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||||
|
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||||
|
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||||
|
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||||
|
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||||
|
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||||
|
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||||
|
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||||
|
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||||
|
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||||
|
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||||
|
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||||
|
|
||||||
/* Append length (before padding) */
|
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||||
MD5Update(context, bits, 8);
|
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||||
}
|
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||||
|
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||||
/*
|
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||||
* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||||
* the message digest and zeroizing the context.
|
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||||
*/
|
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||||
|
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||||
void MD5Final(unsigned char digest[16], MD5_CTX *context)
|
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||||
{
|
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||||
/* Do padding. */
|
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||||
MD5Pad(context);
|
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||||
|
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||||
/* Store state in digest */
|
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||||
Encode(digest, context->state, 16);
|
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||||
|
|
||||||
/* Zeroize sensitive information. */
|
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||||
memset((void *)context, 0, sizeof(*context));
|
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||||
}
|
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||||
|
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||||
/* MD5 basic transformation. Transforms state based on block. */
|
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||||
|
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||||
static void MD5Transform(unsigned int state[4], const unsigned char block[64])
|
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||||
{
|
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||||
unsigned int a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||||
|
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||||
Decode(x, block, 64);
|
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||||
|
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||||
/* Round 1 */
|
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||||
#define S11 7
|
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||||
#define S12 12
|
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||||
#define S13 17
|
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||||
#define S14 22
|
|
||||||
FF(a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
|
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||||
FF(d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
|
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||||
FF(c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
|
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||||
FF(b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
|
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||||
FF(a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
|
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||||
FF(d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
|
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||||
FF(c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
|
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||||
FF(b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
|
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||||
FF(a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
|
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||||
FF(d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
|
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||||
FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
|
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||||
FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
|
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||||
FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
|
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||||
FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
|
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||||
FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
|
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||||
FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
|
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||||
|
|
||||||
/* Round 2 */
|
buf[0] += a;
|
||||||
#define S21 5
|
buf[1] += b;
|
||||||
#define S22 9
|
buf[2] += c;
|
||||||
#define S23 14
|
buf[3] += d;
|
||||||
#define S24 20
|
|
||||||
GG(a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
|
|
||||||
GG(d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
|
|
||||||
GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
|
|
||||||
GG(b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
|
|
||||||
GG(a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
|
|
||||||
GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */
|
|
||||||
GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
|
|
||||||
GG(b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
|
|
||||||
GG(a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
|
|
||||||
GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
|
|
||||||
GG(c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
|
|
||||||
GG(b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
|
|
||||||
GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
|
|
||||||
GG(d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
|
|
||||||
GG(c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
|
|
||||||
GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
|
|
||||||
|
|
||||||
/* Round 3 */
|
|
||||||
#define S31 4
|
|
||||||
#define S32 11
|
|
||||||
#define S33 16
|
|
||||||
#define S34 23
|
|
||||||
HH(a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
|
|
||||||
HH(d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
|
|
||||||
HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
|
|
||||||
HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
|
|
||||||
HH(a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
|
|
||||||
HH(d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
|
|
||||||
HH(c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
|
|
||||||
HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
|
|
||||||
HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
|
|
||||||
HH(d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
|
|
||||||
HH(c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
|
|
||||||
HH(b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
|
|
||||||
HH(a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
|
|
||||||
HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
|
|
||||||
HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
|
|
||||||
HH(b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
|
|
||||||
|
|
||||||
/* Round 4 */
|
|
||||||
#define S41 6
|
|
||||||
#define S42 10
|
|
||||||
#define S43 15
|
|
||||||
#define S44 21
|
|
||||||
II(a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
|
|
||||||
II(d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
|
|
||||||
II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
|
|
||||||
II(b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
|
|
||||||
II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
|
|
||||||
II(d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
|
|
||||||
II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
|
|
||||||
II(b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
|
|
||||||
II(a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
|
|
||||||
II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
|
|
||||||
II(c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
|
|
||||||
II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
|
|
||||||
II(a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
|
|
||||||
II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
|
|
||||||
II(c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
|
|
||||||
II(b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
|
|
||||||
|
|
||||||
state[0] += a;
|
|
||||||
state[1] += b;
|
|
||||||
state[2] += c;
|
|
||||||
state[3] += d;
|
|
||||||
|
|
||||||
/* Zeroize sensitive information. */
|
|
||||||
memset((void *)x, 0, sizeof(x));
|
|
||||||
}
|
}
|
||||||
|
|||||||
90
md5/md5.h
90
md5/md5.h
@@ -1,51 +1,57 @@
|
|||||||
/* MD5.H - header file for MD5C.C
|
/*
|
||||||
* $FreeBSD$
|
* libjpeg-turbo Modifications:
|
||||||
|
* Copyright (C)2018 D. R. Commander. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* - Neither the name of the libjpeg-turbo Project nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*-
|
#ifndef MD5_H
|
||||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
|
#define MD5_H
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
License to copy and use this software is granted provided that it
|
|
||||||
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
|
||||||
Algorithm" in all material mentioning or referencing this software
|
|
||||||
or this function.
|
|
||||||
|
|
||||||
License is also granted to make and use derivative works provided
|
|
||||||
that such works are identified as "derived from the RSA Data
|
|
||||||
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
||||||
mentioning or referencing the derived work.
|
|
||||||
|
|
||||||
RSA Data Security, Inc. makes no representations concerning either
|
|
||||||
the merchantability of this software or the suitability of this
|
|
||||||
software for any particular purpose. It is provided "as is"
|
|
||||||
without express or implied warranty of any kind.
|
|
||||||
|
|
||||||
These notices must be retained in any copies of any part of this
|
|
||||||
documentation and/or software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SYS_MD5_H_
|
|
||||||
#define _SYS_MD5_H_
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#ifdef __amigaos4__
|
||||||
|
#include <machine/endian.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MD5_BLOCK_LENGTH 64
|
/* On machines where "long" is 64 bits, we need to declare
|
||||||
#define MD5_DIGEST_LENGTH 16
|
uint32 as something guaranteed to be 32 bits. */
|
||||||
#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
|
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
|
||||||
/* MD5 context. */
|
|
||||||
typedef struct MD5Context {
|
typedef struct MD5Context {
|
||||||
unsigned int state[4]; /* state (ABCD) */
|
uint32 buf[4];
|
||||||
unsigned int count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
uint32 bits[2];
|
||||||
unsigned char buffer[64]; /* input buffer */
|
unsigned char in[64];
|
||||||
} MD5_CTX;
|
} MD5_CTX;
|
||||||
|
|
||||||
void MD5Init(MD5_CTX *);
|
extern void MD5Init(struct MD5Context *ctx);
|
||||||
void MD5Update(MD5_CTX *, const void *, unsigned int);
|
extern void MD5Update(struct MD5Context *ctx, unsigned char *buf,
|
||||||
void MD5Final(unsigned char [16], MD5_CTX *);
|
unsigned int len);
|
||||||
char *MD5End(MD5_CTX *, char *);
|
extern void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
|
||||||
char *MD5File(const char *, char *);
|
extern void MD5Transform(uint32 buf[4], uint32 in[16]);
|
||||||
char *MD5FileChunk(const char *, char *, off_t, off_t);
|
extern char *MD5File(const char *, char *);
|
||||||
char *MD5Data(const void *, unsigned int, char *);
|
extern char *MD5FileChunk(const char *, char *, off_t, off_t);
|
||||||
#endif /* _SYS_MD5_H_ */
|
|
||||||
|
#endif /* !MD5_H */
|
||||||
|
|||||||
40
md5/md5hl.c
40
md5/md5hl.c
@@ -6,8 +6,31 @@
|
|||||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2016, D. R. Commander.
|
* Copyright (C)2016, 2018-2019 D. R. Commander. All Rights Reserved.
|
||||||
* Modifications are under the same license as the original code (see above)
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* - Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* - Neither the name of the libjpeg-turbo Project nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -33,7 +56,7 @@
|
|||||||
|
|
||||||
#include "./md5.h"
|
#include "./md5.h"
|
||||||
|
|
||||||
char *MD5End(MD5_CTX *ctx, char *buf)
|
static char *MD5End(MD5_CTX *ctx, char *buf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char digest[LENGTH];
|
unsigned char digest[LENGTH];
|
||||||
@@ -66,7 +89,7 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
|||||||
off_t n;
|
off_t n;
|
||||||
|
|
||||||
MD5Init(&ctx);
|
MD5Init(&ctx);
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
f = _open(filename, O_RDONLY | O_BINARY);
|
f = _open(filename, O_RDONLY | O_BINARY);
|
||||||
#else
|
#else
|
||||||
f = open(filename, O_RDONLY);
|
f = open(filename, O_RDONLY);
|
||||||
@@ -100,12 +123,3 @@ char *MD5FileChunk(const char *filename, char *buf, off_t ofs, off_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
return (MD5End(&ctx, buf));
|
return (MD5End(&ctx, buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *MD5Data(const void *data, unsigned int len, char *buf)
|
|
||||||
{
|
|
||||||
MD5_CTX ctx;
|
|
||||||
|
|
||||||
MD5Init(&ctx);
|
|
||||||
MD5Update(&ctx, data, len);
|
|
||||||
return (MD5End(&ctx, buf));
|
|
||||||
}
|
|
||||||
|
|||||||
158
mozjpeg.podspec
Normal file
158
mozjpeg.podspec
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
Pod::Spec.new do |spec|
|
||||||
|
spec.name = "mozjpeg"
|
||||||
|
spec.version = "3.3.1"
|
||||||
|
spec.license = { :type => "BSD" }
|
||||||
|
spec.homepage = "https://github.com/mozilla/mozjpeg"
|
||||||
|
spec.summary = "Improved JPEG encoder."
|
||||||
|
spec.authors = "Mozilla"
|
||||||
|
spec.source = { :git => "https://github.com/mozilla/mozjpeg.git", :tag => "v#{spec.version}" }
|
||||||
|
spec.module_name = "mozjpeg"
|
||||||
|
spec.header_dir = "mozjpeg"
|
||||||
|
spec.platforms = { :ios => "8.0" }
|
||||||
|
spec.prepare_command = <<-CMD
|
||||||
|
cat << EOF > jconfig.h
|
||||||
|
#define JPEG_LIB_VERSION 80 /* Version 6b */
|
||||||
|
#define LIBJPEG_TURBO_VERSION 3.1.m
|
||||||
|
#define LIBJPEG_TURBO_VERSION_NUMBER 1
|
||||||
|
#define C_ARITH_CODING_SUPPORTED 1
|
||||||
|
#define D_ARITH_CODING_SUPPORTED 1
|
||||||
|
#define BITS_IN_JSAMPLE 8
|
||||||
|
#define HAVE_LOCALE_H 1
|
||||||
|
#define HAVE_STDDEF_H 1
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
#define HAVE_UNSIGNED_CHAR 1
|
||||||
|
#define HAVE_UNSIGNED_SHORT 1
|
||||||
|
#define NEED_SYS_TYPES_H 1
|
||||||
|
#define WITH_SIMD 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
cat << EOF > jconfigint.h
|
||||||
|
#define BUILD "20180328"
|
||||||
|
#define INLINE __attribute__((always_inline))
|
||||||
|
#define PACKAGE_NAME "mozjpeg"
|
||||||
|
#define VERSION "#{spec.version}"
|
||||||
|
#ifdef __SIZEOF_SIZE_T__
|
||||||
|
#define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
|
||||||
|
#else
|
||||||
|
#error Cannot determine the size of size_t
|
||||||
|
#endif
|
||||||
|
EOF
|
||||||
|
CMD
|
||||||
|
|
||||||
|
spec.private_header_files = "bmp.h",
|
||||||
|
"cderror.h",
|
||||||
|
"cdjpeg.h",
|
||||||
|
"jchuff.h",
|
||||||
|
"jcmaster.h",
|
||||||
|
"jconfigint.h",
|
||||||
|
"jdcoefct.h",
|
||||||
|
"jdct.h",
|
||||||
|
"jdhuff.h",
|
||||||
|
"jdmainct.h",
|
||||||
|
"jdmaster.h",
|
||||||
|
"jdsample.h",
|
||||||
|
"jmemsys.h",
|
||||||
|
"jpeg_nbits_table.h",
|
||||||
|
"jpegcomp.h",
|
||||||
|
"jsimd.h",
|
||||||
|
"jsimddct.h",
|
||||||
|
"jversion.h",
|
||||||
|
"wrppm.h"
|
||||||
|
|
||||||
|
spec.public_header_files = "jerror.h",
|
||||||
|
"jinclude.h",
|
||||||
|
"jconfig.h",
|
||||||
|
"jmorecfg.h",
|
||||||
|
"jpeglib.h",
|
||||||
|
"jpegint.h",
|
||||||
|
"transupp.h"
|
||||||
|
|
||||||
|
spec.source_files = "jcapimin.c",
|
||||||
|
"jcapistd.c",
|
||||||
|
"jccoefct.c",
|
||||||
|
"jccolor.c",
|
||||||
|
"jcdctmgr.c",
|
||||||
|
"jcext.c",
|
||||||
|
"jchuff.c",
|
||||||
|
"jcinit.c",
|
||||||
|
"jcmainct.c",
|
||||||
|
"jcmarker.c",
|
||||||
|
"jcmaster.c",
|
||||||
|
"jcomapi.c",
|
||||||
|
"jcparam.c",
|
||||||
|
"jcphuff.c",
|
||||||
|
"jcprepct.c",
|
||||||
|
"jcsample.c",
|
||||||
|
"jctrans.c",
|
||||||
|
"jdapimin.c",
|
||||||
|
"jdapistd.c",
|
||||||
|
"jdatadst.c",
|
||||||
|
"jdatasrc.c",
|
||||||
|
"jdcoefct.c",
|
||||||
|
"jdcolor.c",
|
||||||
|
"jddctmgr.c",
|
||||||
|
"jdhuff.c",
|
||||||
|
"jdinput.c",
|
||||||
|
"jdmainct.c",
|
||||||
|
"jdmarker.c",
|
||||||
|
"jdmaster.c",
|
||||||
|
"jdmerge.c",
|
||||||
|
"jdphuff.c",
|
||||||
|
"jdpostct.c",
|
||||||
|
"jdsample.c",
|
||||||
|
"jdtrans.c",
|
||||||
|
"jerror.c",
|
||||||
|
"jfdctflt.c",
|
||||||
|
"jfdctfst.c",
|
||||||
|
"jfdctint.c",
|
||||||
|
"jidctflt.c",
|
||||||
|
"jidctfst.c",
|
||||||
|
"jidctint.c",
|
||||||
|
"jidctred.c",
|
||||||
|
"jquant1.c",
|
||||||
|
"jquant2.c",
|
||||||
|
"jutils.c",
|
||||||
|
"jmemmgr.c",
|
||||||
|
"jaricom.c",
|
||||||
|
"jcarith.c",
|
||||||
|
"jdarith.c",
|
||||||
|
"transupp.c",
|
||||||
|
"jmemnobs.c",
|
||||||
|
"jsimd_none.c",
|
||||||
|
"jerror.h",
|
||||||
|
"jinclude.h",
|
||||||
|
"jconfig.h",
|
||||||
|
"jmorecfg.h",
|
||||||
|
"jpeglib.h",
|
||||||
|
"jpegint.h",
|
||||||
|
"transupp.h",
|
||||||
|
"bmp.h",
|
||||||
|
"cderror.h",
|
||||||
|
"cdjpeg.h",
|
||||||
|
"jchuff.h",
|
||||||
|
"jcmaster.h",
|
||||||
|
"jconfigint.h",
|
||||||
|
"jdcoefct.h",
|
||||||
|
"jdct.h",
|
||||||
|
"jdhuff.h",
|
||||||
|
"jdmainct.h",
|
||||||
|
"jdmaster.h",
|
||||||
|
"jdsample.h",
|
||||||
|
"jmemsys.h",
|
||||||
|
"jpeg_nbits_table.h",
|
||||||
|
"jpegcomp.h",
|
||||||
|
"jsimd.h",
|
||||||
|
"jsimddct.h",
|
||||||
|
"jversion.h",
|
||||||
|
"wrppm.h"
|
||||||
|
|
||||||
|
# Despite their extensions, these are header files that shouldn't be compiled
|
||||||
|
# on their own but should still be present for other files to include.
|
||||||
|
spec.preserve_path = "jdcolext.c",
|
||||||
|
"jstdhuff.c",
|
||||||
|
"jdcol565.c",
|
||||||
|
"jdmrgext.c",
|
||||||
|
"jdmrg565.c",
|
||||||
|
"jccolext.c"
|
||||||
|
end
|
||||||
15
rd_average.sh
Executable file
15
rd_average.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# == 0 ]; then
|
||||||
|
echo "usage: OUTPUT=<label> $0 *.out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOTAL=total.out
|
||||||
|
|
||||||
|
if [ -n "$OUTPUT" ]; then
|
||||||
|
TOTAL="$OUTPUT.out"
|
||||||
|
fi
|
||||||
|
|
||||||
|
awk '{size[FNR]+=$2;bytes[FNR]+=$3;psnr[FNR]+=$2*$4;psnrhvs[FNR]+=$2*$5;ssim[FNR]+=$2*$6;fastssim[FNR]+=$2*$7;}END{for(i=1;i<=FNR;i++)print i-1,size[i],bytes[i],psnr[i]/size[i],psnrhvs[i]/size[i],ssim[i]/size[i],fastssim[i]/size[i];}' $@ > $TOTAL
|
||||||
106
rd_collect.sh
Executable file
106
rd_collect.sh
Executable file
@@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# == 0 ]; then
|
||||||
|
echo "usage: DAALA_ROOT=<daala_root> MOZJPEG_ROOT=<mozjpeg_root> $0 *.y4m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $MOZJPEG_ROOT ]; then
|
||||||
|
MOZJPEG_ROOT=.
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z $DAALA_ROOT ]; then
|
||||||
|
echo "DAALA_ROOT not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PLANE" ]; then
|
||||||
|
export PLANE=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $PLANE != 0 ] && [ $PLANE != 1 ] && [ $PLANE != 2 ]; then
|
||||||
|
echo "Invalid plane $PLANE. Must be 0, 1 or 2."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$YUVJPEG" ]; then
|
||||||
|
export YUVJPEG=$MOZJPEG_ROOT/yuvjpeg
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$JPEGYUV" ]; then
|
||||||
|
export JPEGYUV=$MOZJPEG_ROOT/jpegyuv
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$YUVJPEG" ]; then
|
||||||
|
echo "Executable not found YUVJPEG=$YUVJPEG"
|
||||||
|
echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$JPEGYUV" ]; then
|
||||||
|
echo "Executable not found JPEGYUV=$JPEGYUV"
|
||||||
|
echo "Do you have the right MOZJPEG_ROOT=$MOZJPEG_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO refactor these out of the daala project into a metrics project
|
||||||
|
|
||||||
|
if [ -z "$YUV2YUV4MPEG" ]; then
|
||||||
|
export YUV2YUV4MPEG=$DAALA_ROOT/tools/yuv2yuv4mpeg
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DUMP_PSNR" ]; then
|
||||||
|
export DUMP_PSNR=$DAALA_ROOT/tools/dump_psnr
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DUMP_PSNRHVS" ]; then
|
||||||
|
export DUMP_PSNRHVS=$DAALA_ROOT/tools/dump_psnrhvs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DUMP_SSIM" ]; then
|
||||||
|
export DUMP_SSIM=$DAALA_ROOT/tools/dump_ssim
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DUMP_FASTSSIM" ]; then
|
||||||
|
export DUMP_FASTSSIM=$DAALA_ROOT/tools/dump_fastssim
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$YUV2YUV4MPEG" ]; then
|
||||||
|
echo "Executable not found YUV2YUV4MPEG=$YUV2YUV4MPEG"
|
||||||
|
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$DUMP_PSNR" ]; then
|
||||||
|
echo "Executable not found DUMP_PSNR=$DUMP_PSNR"
|
||||||
|
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$DUMP_PSNRHVS" ]; then
|
||||||
|
echo "Executable not found DUMP_PSNRHVS=$DUMP_PSNRHVS"
|
||||||
|
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$DUMP_SSIM" ]; then
|
||||||
|
echo "Executable not found DUMP_SSIM=$DUMP_SSIM"
|
||||||
|
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -x "$DUMP_FASTSSIM" ]; then
|
||||||
|
echo "Executable not found DUMP_FASTSSIM=$DUMP_FASTSSIM"
|
||||||
|
echo "Do you have the right DAALA_ROOT=$DAALA_ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
RD_COLLECT_SUB=$(dirname "$0")/rd_collect_sub.sh
|
||||||
|
|
||||||
|
if [ -z "$CORES" ]; then
|
||||||
|
CORES=`grep -i processor /proc/cpuinfo | wc -l`
|
||||||
|
#echo "CORES not set, using $CORES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find $@ -type f -name "*.y4m" -print0 | xargs -0 -n1 -P$CORES $RD_COLLECT_SUB
|
||||||
28
rd_collect_sub.sh
Executable file
28
rd_collect_sub.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
FILE=$1
|
||||||
|
|
||||||
|
BASENAME=$(basename $FILE)
|
||||||
|
rm $BASENAME.out 2> /dev/null || true
|
||||||
|
echo $BASENAME
|
||||||
|
tail -n+3 $FILE > $BASENAME-in.yuv
|
||||||
|
WIDTH=$(head -1 $FILE | cut -d\ -f 2 | tr -d 'W')
|
||||||
|
HEIGHT=$(head -1 $FILE | cut -d\ -f 3 | tr -d 'H')
|
||||||
|
|
||||||
|
for x in {0..100}; do
|
||||||
|
$YUVJPEG $x "$WIDTH"x$HEIGHT $BASENAME-in.yuv $BASENAME.jpeg
|
||||||
|
$JPEGYUV $BASENAME.jpeg $BASENAME.yuv
|
||||||
|
$YUV2YUV4MPEG $BASENAME -w$WIDTH -h$HEIGHT -an0 -ad0 -c420mpeg2
|
||||||
|
PIXELS=$(($WIDTH*$HEIGHT))
|
||||||
|
SIZE=$(wc -c $BASENAME.jpeg | awk '{ print $1 }')
|
||||||
|
PSNR=$($DUMP_PSNR $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
|
||||||
|
PSNRHVS=$($DUMP_PSNRHVS $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
|
||||||
|
SSIM=$($DUMP_SSIM $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
|
||||||
|
FASTSSIM=$($DUMP_FASTSSIM -c $FILE $BASENAME.y4m 2> /dev/null | grep Total | tr -s ' ' | cut -d\ -f $((4+$PLANE*2)))
|
||||||
|
rm $BASENAME.jpeg $BASENAME.yuv $BASENAME.y4m
|
||||||
|
echo $x $PIXELS $SIZE $PSNR $PSNRHVS $SSIM $FASTSSIM >> $BASENAME.out
|
||||||
|
#tail -1 $BASENAME.out
|
||||||
|
done
|
||||||
|
|
||||||
|
rm $BASENAME-in.yuv
|
||||||
47
rd_plot.sh
Executable file
47
rd_plot.sh
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Use this to average data from multiple runs
|
||||||
|
#awk '{size[FNR]+=$2;bytes[FNR]+=$3;psnr[FNR]+=$2*$4;psnrhvs[FNR]+=$2*$5;ssim[FNR]+=$2*$6;fastssim[FNR]+=$2*$7;}END{for(i=1;i<=FNR;i++)print i+1,size[i],bytes[i],psnr[i]/size[i],psnrhvs[i]/size[i],ssim[i]/size[i],fastssim[i]/size[i];}' *.out > total.out
|
||||||
|
|
||||||
|
if [ -n "$IMAGE" ]; then
|
||||||
|
IMAGE="$IMAGE-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# == 0 ]; then
|
||||||
|
echo "usage: IMAGE=<prefix> $0 *.out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$GNUPLOT" -a -n "`type -p gnuplot`" ]; then
|
||||||
|
GNUPLOT=`type -p gnuplot`
|
||||||
|
fi
|
||||||
|
if [ ! -x "$GNUPLOT" ]; then
|
||||||
|
echo "Executable not found GNUPLOT=$GNUPLOT"
|
||||||
|
echo "Please install it or set GNUPLOT to point to an installed copy"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMDS="$CMDS set term pngcairo dashed size 1024,768;"
|
||||||
|
CMDS="$CMDS set log x;"
|
||||||
|
CMDS="$CMDS set xlabel 'Bits/Pixel';"
|
||||||
|
CMDS="$CMDS set ylabel 'dB';"
|
||||||
|
CMDS="$CMDS set key bot right;"
|
||||||
|
|
||||||
|
for FILE in "$@"; do
|
||||||
|
BASENAME=$(basename $FILE)
|
||||||
|
PSNR="$PSNR $PREFIX '$FILE' using (\$3*8/\$2):4 with lines title '${BASENAME%.*} (PSNR)'"
|
||||||
|
PSNRHVS="$PSNRHVS $PREFIX '$FILE' using (\$3*8/\$2):5 with lines title '${BASENAME%.*} (PSNR-HVS)'"
|
||||||
|
SSIM="$SSIM $PREFIX '$FILE' using (\$3*8/\$2):6 with lines title '${BASENAME%.*} (SSIM)'"
|
||||||
|
FASTSSIM="$FASTSSIM $PREFIX '$FILE' using (\$3*8/\$2):7 with lines title '${BASENAME%.*} (FAST SSIM)'"
|
||||||
|
PREFIX=","
|
||||||
|
done
|
||||||
|
|
||||||
|
SUFFIX="psnr.png"
|
||||||
|
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNR;" 2> /dev/null
|
||||||
|
SUFFIX="psnrhvs.png"
|
||||||
|
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $PSNRHVS;" 2> /dev/null
|
||||||
|
SUFFIX="ssim.png"
|
||||||
|
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $SSIM;" 2> /dev/null
|
||||||
|
SUFFIX="fastssim.png"
|
||||||
|
$GNUPLOT -e "$CMDS set output \"$IMAGE$SUFFIX\"; plot $FASTSSIM;" 2> /dev/null
|
||||||
23
rdbmp.c
23
rdbmp.c
@@ -3,10 +3,10 @@
|
|||||||
*
|
*
|
||||||
* This file was part of the Independent JPEG Group's software:
|
* This file was part of the Independent JPEG Group's software:
|
||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2010 by Guido Vollbeding.
|
* Modified 2009-2017 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Modified 2011 by Siarhei Siamashka.
|
* Modified 2011 by Siarhei Siamashka.
|
||||||
* Copyright (C) 2015, 2017, D. R. Commander.
|
* Copyright (C) 2015, 2017-2018, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -72,6 +72,7 @@ typedef struct _bmp_source_struct {
|
|||||||
JDIMENSION row_width; /* Physical width of scanlines in file */
|
JDIMENSION row_width; /* Physical width of scanlines in file */
|
||||||
|
|
||||||
int bits_per_pixel; /* remembers 8- or 24-bit format */
|
int bits_per_pixel; /* remembers 8- or 24-bit format */
|
||||||
|
int cmap_length; /* colormap length */
|
||||||
|
|
||||||
boolean use_inversion_array; /* TRUE = preload the whole image, which is
|
boolean use_inversion_array; /* TRUE = preload the whole image, which is
|
||||||
stored in bottom-up order, and feed it to
|
stored in bottom-up order, and feed it to
|
||||||
@@ -155,6 +156,7 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
{
|
{
|
||||||
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
bmp_source_ptr source = (bmp_source_ptr)sinfo;
|
||||||
register JSAMPARRAY colormap = source->colormap;
|
register JSAMPARRAY colormap = source->colormap;
|
||||||
|
int cmaplen = source->cmap_length;
|
||||||
JSAMPARRAY image_ptr;
|
JSAMPARRAY image_ptr;
|
||||||
register int t;
|
register int t;
|
||||||
register JSAMPROW inptr, outptr;
|
register JSAMPROW inptr, outptr;
|
||||||
@@ -178,11 +180,15 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
if (cinfo->in_color_space == JCS_GRAYSCALE) {
|
if (cinfo->in_color_space == JCS_GRAYSCALE) {
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
t = GETJSAMPLE(*inptr++);
|
t = GETJSAMPLE(*inptr++);
|
||||||
|
if (t >= cmaplen)
|
||||||
|
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
|
||||||
*outptr++ = colormap[0][t];
|
*outptr++ = colormap[0][t];
|
||||||
}
|
}
|
||||||
} else if (cinfo->in_color_space == JCS_CMYK) {
|
} else if (cinfo->in_color_space == JCS_CMYK) {
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
t = GETJSAMPLE(*inptr++);
|
t = GETJSAMPLE(*inptr++);
|
||||||
|
if (t >= cmaplen)
|
||||||
|
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
|
||||||
rgb_to_cmyk(colormap[0][t], colormap[1][t], colormap[2][t], outptr,
|
rgb_to_cmyk(colormap[0][t], colormap[1][t], colormap[2][t], outptr,
|
||||||
outptr + 1, outptr + 2, outptr + 3);
|
outptr + 1, outptr + 2, outptr + 3);
|
||||||
outptr += 4;
|
outptr += 4;
|
||||||
@@ -197,6 +203,8 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
if (aindex >= 0) {
|
if (aindex >= 0) {
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
t = GETJSAMPLE(*inptr++);
|
t = GETJSAMPLE(*inptr++);
|
||||||
|
if (t >= cmaplen)
|
||||||
|
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
|
||||||
outptr[rindex] = colormap[0][t];
|
outptr[rindex] = colormap[0][t];
|
||||||
outptr[gindex] = colormap[1][t];
|
outptr[gindex] = colormap[1][t];
|
||||||
outptr[bindex] = colormap[2][t];
|
outptr[bindex] = colormap[2][t];
|
||||||
@@ -206,6 +214,8 @@ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
} else {
|
} else {
|
||||||
for (col = cinfo->image_width; col > 0; col--) {
|
for (col = cinfo->image_width; col > 0; col--) {
|
||||||
t = GETJSAMPLE(*inptr++);
|
t = GETJSAMPLE(*inptr++);
|
||||||
|
if (t >= cmaplen)
|
||||||
|
ERREXIT(cinfo, JERR_BMP_OUTOFRANGE);
|
||||||
outptr[rindex] = colormap[0][t];
|
outptr[rindex] = colormap[0][t];
|
||||||
outptr[gindex] = colormap[1][t];
|
outptr[gindex] = colormap[1][t];
|
||||||
outptr[bindex] = colormap[2][t];
|
outptr[bindex] = colormap[2][t];
|
||||||
@@ -522,7 +532,7 @@ start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biWidth <= 0 || biHeight <= 0)
|
if (biWidth <= 0 || biHeight <= 0 || biWidth > 0x7fffffffL || biHeight > 0x7fffffffL)
|
||||||
ERREXIT(cinfo, JERR_BMP_EMPTY);
|
ERREXIT(cinfo, JERR_BMP_EMPTY);
|
||||||
if (biPlanes != 1)
|
if (biPlanes != 1)
|
||||||
ERREXIT(cinfo, JERR_BMP_BADPLANES);
|
ERREXIT(cinfo, JERR_BMP_BADPLANES);
|
||||||
@@ -539,6 +549,7 @@ start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
/* Allocate space to store the colormap */
|
/* Allocate space to store the colormap */
|
||||||
source->colormap = (*cinfo->mem->alloc_sarray)
|
source->colormap = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
|
((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)biClrUsed, (JDIMENSION)3);
|
||||||
|
source->cmap_length = (int)biClrUsed;
|
||||||
/* and read it from the file */
|
/* and read it from the file */
|
||||||
read_colormap(source, (int)biClrUsed, mapentrysize);
|
read_colormap(source, (int)biClrUsed, mapentrysize);
|
||||||
/* account for size of colormap */
|
/* account for size of colormap */
|
||||||
@@ -623,6 +634,12 @@ start_input_bmp(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure that biWidth * cinfo->input_components doesn't exceed the maximum
|
||||||
|
value of the JDIMENSION type. This is only a danger with BMP files, since
|
||||||
|
their width and height fields are 32-bit integers. */
|
||||||
|
if ((unsigned long long)biWidth *
|
||||||
|
(unsigned long long)cinfo->input_components > 0xFFFFFFFFULL)
|
||||||
|
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
|
||||||
/* Allocate one-row buffer for returned data */
|
/* Allocate one-row buffer for returned data */
|
||||||
source->pub.buffer = (*cinfo->mem->alloc_sarray)
|
source->pub.buffer = (*cinfo->mem->alloc_sarray)
|
||||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||||
|
|||||||
160
rdjpeg.c
Normal file
160
rdjpeg.c
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* rdjpeg.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
|
* mozjpeg Modifications:
|
||||||
|
* Copyright (C) 2014, Mozilla Corporation.
|
||||||
|
* This file is part of the Independent JPEG Group's software.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||||
|
|
||||||
|
#if JPEG_RAW_READER
|
||||||
|
#define NUM_ROWS 32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Private version of data source object */
|
||||||
|
|
||||||
|
typedef struct _jpeg_source_struct * jpeg_source_ptr;
|
||||||
|
|
||||||
|
typedef struct _jpeg_source_struct {
|
||||||
|
struct cjpeg_source_struct pub; /* public fields */
|
||||||
|
|
||||||
|
j_compress_ptr cinfo; /* back link saves passing separate parm */
|
||||||
|
|
||||||
|
struct jpeg_decompress_struct dinfo;
|
||||||
|
struct jpeg_error_mgr jerr;
|
||||||
|
} jpeg_source_struct;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
METHODDEF(JDIMENSION)
|
||||||
|
get_rows (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
|
||||||
|
|
||||||
|
#if !JPEG_RAW_READER
|
||||||
|
return jpeg_read_scanlines(&source->dinfo, source->pub.buffer, source->pub.buffer_height);
|
||||||
|
#else
|
||||||
|
jpeg_read_raw_data(&source->dinfo, source->pub.plane_pointer, 8*cinfo->max_v_samp_factor);
|
||||||
|
|
||||||
|
return 8*cinfo->max_v_samp_factor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the file header; return image size and component count.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
start_input_jpeg (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
#if JPEG_RAW_READER
|
||||||
|
int i;
|
||||||
|
#endif
|
||||||
|
int m;
|
||||||
|
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
|
||||||
|
|
||||||
|
source->dinfo.err = jpeg_std_error(&source->jerr);
|
||||||
|
jpeg_create_decompress(&source->dinfo);
|
||||||
|
jpeg_stdio_src(&source->dinfo, source->pub.input_file);
|
||||||
|
|
||||||
|
jpeg_save_markers(&source->dinfo, JPEG_COM, 0xFFFF);
|
||||||
|
|
||||||
|
for (m = 0; m < 16; m++)
|
||||||
|
jpeg_save_markers(&source->dinfo, JPEG_APP0 + m, 0xFFFF);
|
||||||
|
|
||||||
|
jpeg_read_header(&source->dinfo, TRUE);
|
||||||
|
|
||||||
|
source->pub.marker_list = source->dinfo.marker_list;
|
||||||
|
|
||||||
|
#if !JPEG_RAW_READER
|
||||||
|
source->dinfo.raw_data_out = FALSE;
|
||||||
|
|
||||||
|
jpeg_start_decompress(&source->dinfo);
|
||||||
|
|
||||||
|
cinfo->in_color_space = source->dinfo.out_color_space;
|
||||||
|
cinfo->input_components = source->dinfo.output_components;
|
||||||
|
cinfo->data_precision = source->dinfo.data_precision;
|
||||||
|
cinfo->image_width = source->dinfo.image_width;
|
||||||
|
cinfo->image_height = source->dinfo.image_height;
|
||||||
|
|
||||||
|
cinfo->raw_data_in = FALSE;
|
||||||
|
|
||||||
|
source->pub.buffer = (*cinfo->mem->alloc_sarray)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(JDIMENSION) (cinfo->image_width * cinfo->input_components), (JDIMENSION) 1);
|
||||||
|
source->pub.buffer_height = 1;
|
||||||
|
#else
|
||||||
|
source->dinfo.raw_data_out = TRUE;
|
||||||
|
source->dinfo.do_fancy_upsampling = FALSE;
|
||||||
|
|
||||||
|
jpeg_start_decompress(&source->dinfo);
|
||||||
|
|
||||||
|
cinfo->in_color_space = source->dinfo.out_color_space;
|
||||||
|
cinfo->input_components = source->dinfo.output_components;
|
||||||
|
cinfo->data_precision = source->dinfo.data_precision;
|
||||||
|
cinfo->image_width = source->dinfo.image_width;
|
||||||
|
cinfo->image_height = source->dinfo.image_height;
|
||||||
|
|
||||||
|
jpeg_set_colorspace(cinfo, source->dinfo.jpeg_color_space);
|
||||||
|
|
||||||
|
cinfo->max_v_samp_factor = source->dinfo.max_v_samp_factor;
|
||||||
|
cinfo->max_h_samp_factor = source->dinfo.max_h_samp_factor;
|
||||||
|
|
||||||
|
cinfo->raw_data_in = TRUE;
|
||||||
|
#if JPEG_LIB_VERSION >= 70
|
||||||
|
cinfo->do_fancy_upsampling = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < cinfo->input_components; i++) {
|
||||||
|
cinfo->comp_info[i].h_samp_factor = source->dinfo.comp_info[i].h_samp_factor;
|
||||||
|
cinfo->comp_info[i].v_samp_factor = source->dinfo.comp_info[i].v_samp_factor;
|
||||||
|
|
||||||
|
source->pub.plane_pointer[i] = (*cinfo->mem->alloc_sarray)
|
||||||
|
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
(JDIMENSION) cinfo->image_width, (JDIMENSION) NUM_ROWS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
source->pub.get_pixel_rows = get_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish up at the end of the file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
finish_input_jpeg (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
jpeg_source_ptr source = (jpeg_source_ptr) sinfo;
|
||||||
|
|
||||||
|
jpeg_finish_decompress(&source->dinfo);
|
||||||
|
jpeg_destroy_decompress(&source->dinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The module selection routine for JPEG format input.
|
||||||
|
*/
|
||||||
|
|
||||||
|
GLOBAL(cjpeg_source_ptr)
|
||||||
|
jinit_read_jpeg (j_compress_ptr cinfo)
|
||||||
|
{
|
||||||
|
jpeg_source_ptr source;
|
||||||
|
|
||||||
|
/* Create module interface object */
|
||||||
|
source = (jpeg_source_ptr)
|
||||||
|
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
||||||
|
sizeof(jpeg_source_struct));
|
||||||
|
source->cinfo = cinfo; /* make back link for subroutines */
|
||||||
|
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
||||||
|
source->pub.start_input = start_input_jpeg;
|
||||||
|
source->pub.finish_input = finish_input_jpeg;
|
||||||
|
|
||||||
|
return (cjpeg_source_ptr) source;
|
||||||
|
}
|
||||||
@@ -301,7 +301,8 @@ process_SOFn(int marker)
|
|||||||
case M_SOF10: process = "Progressive, arithmetic coding"; break;
|
case M_SOF10: process = "Progressive, arithmetic coding"; break;
|
||||||
case M_SOF11: process = "Lossless, arithmetic coding"; break;
|
case M_SOF11: process = "Lossless, arithmetic coding"; break;
|
||||||
case M_SOF13: process = "Differential sequential, arithmetic coding"; break;
|
case M_SOF13: process = "Differential sequential, arithmetic coding"; break;
|
||||||
case M_SOF14: process = "Differential progressive, arithmetic coding"; break;
|
case M_SOF14:
|
||||||
|
process = "Differential progressive, arithmetic coding"; break;
|
||||||
case M_SOF15: process = "Differential lossless, arithmetic coding"; break;
|
case M_SOF15: process = "Differential lossless, arithmetic coding"; break;
|
||||||
default: process = "Unknown"; break;
|
default: process = "Unknown"; break;
|
||||||
}
|
}
|
||||||
|
|||||||
194
rdpng.c
Normal file
194
rdpng.c
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
|
||||||
|
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
|
||||||
|
|
||||||
|
#ifdef PNG_SUPPORTED
|
||||||
|
|
||||||
|
#include <png.h> /* if this fails, you need to install libpng-devel */
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct png_source_struct {
|
||||||
|
struct cjpeg_source_struct pub;
|
||||||
|
png_structp png_ptr;
|
||||||
|
png_infop info_ptr;
|
||||||
|
JDIMENSION current_row;
|
||||||
|
} png_source_struct;
|
||||||
|
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||||
|
|
||||||
|
METHODDEF(JDIMENSION)
|
||||||
|
get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL(cjpeg_source_ptr)
|
||||||
|
jinit_read_png(j_compress_ptr cinfo)
|
||||||
|
{
|
||||||
|
png_source_struct *source = (*cinfo->mem->alloc_small)((j_common_ptr) cinfo, JPOOL_IMAGE, sizeof(png_source_struct));
|
||||||
|
|
||||||
|
memset(source, 0, sizeof(*source));
|
||||||
|
|
||||||
|
/* Fill in method ptrs, except get_pixel_rows which start_input sets */
|
||||||
|
source->pub.start_input = start_input_png;
|
||||||
|
source->pub.finish_input = finish_input_png;
|
||||||
|
|
||||||
|
return &source->pub;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHODDEF(void) error_input_png(png_structp png_ptr, png_const_charp msg) {
|
||||||
|
j_compress_ptr cinfo = png_get_error_ptr(png_ptr);
|
||||||
|
ERREXITS(cinfo, JERR_PNG_ERROR, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is a small ICC profile for sRGB */
|
||||||
|
static unsigned char tiny_srgb[] = {0,0,2,24,108,99,109,115,2,16,0,0,109,110,
|
||||||
|
116,114,82,71,66,32,88,89,90,32,7,220,0,1,0,25,0,3,0,41,0,57,97,99,115,112,65,
|
||||||
|
80,80,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,214,0,1,0,0,0,
|
||||||
|
0,211,45,108,99,109,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,100,101,115,99,0,0,0,252,0,0,0,106,
|
||||||
|
99,112,114,116,0,0,1,104,0,0,0,11,119,116,112,116,0,0,1,116,0,0,0,20,98,107,
|
||||||
|
112,116,0,0,1,136,0,0,0,20,114,88,89,90,0,0,1,156,0,0,0,20,103,88,89,90,0,0,1,
|
||||||
|
176,0,0,0,20,98,88,89,90,0,0,1,196,0,0,0,20,114,84,82,67,0,0,1,216,0,0,0,64,98,
|
||||||
|
84,82,67,0,0,1,216,0,0,0,64,103,84,82,67,0,0,1,216,0,0,0,64,100,101,115,99,0,0,
|
||||||
|
0,0,0,0,0,13,115,82,71,66,32,77,111,122,74,80,69,71,0,0,0,0,0,0,0,0,1,0,0,0,0,
|
||||||
|
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,101,120,
|
||||||
|
116,0,0,0,0,80,68,0,0,88,89,90,32,0,0,0,0,0,0,246,214,0,1,0,0,0,0,211,45,88,89,
|
||||||
|
90,32,0,0,0,0,0,0,3,22,0,0,3,51,0,0,2,164,88,89,90,32,0,0,0,0,0,0,111,162,0,0,
|
||||||
|
56,245,0,0,3,144,88,89,90,32,0,0,0,0,0,0,98,153,0,0,183,133,0,0,24,218,88,89,
|
||||||
|
90,32,0,0,0,0,0,0,36,160,0,0,15,132,0,0,182,207,99,117,114,118,0,0,0,0,0,0,0,
|
||||||
|
26,0,0,0,203,1,201,3,99,5,146,8,107,11,246,16,63,21,81,27,52,33,241,41,144,50,
|
||||||
|
24,59,146,70,5,81,119,93,237,107,112,122,5,137,177,154,124,172,105,191,125,211,
|
||||||
|
195,233,48,255,255,};
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
png_source_struct *source = (png_source_struct *)sinfo;
|
||||||
|
png_uint_32 width, height;
|
||||||
|
int bit_depth, color_type;
|
||||||
|
int has_srgb_chunk;
|
||||||
|
double gamma;
|
||||||
|
png_bytep profile;
|
||||||
|
png_charp unused1;
|
||||||
|
int unused2;
|
||||||
|
png_uint_32 proflen;
|
||||||
|
int has_profile;
|
||||||
|
size_t datalen;
|
||||||
|
JOCTET *dataptr;
|
||||||
|
struct jpeg_marker_struct *marker;
|
||||||
|
png_size_t rowbytes;
|
||||||
|
|
||||||
|
source->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, cinfo, error_input_png, NULL);
|
||||||
|
source->info_ptr = png_create_info_struct(source->png_ptr);
|
||||||
|
|
||||||
|
if (!source->png_ptr || !source->info_ptr) {
|
||||||
|
ERREXITS(cinfo, JERR_PNG_ERROR, "Can't create read/info_struct");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_set_palette_to_rgb(source->png_ptr);
|
||||||
|
png_set_expand_gray_1_2_4_to_8(source->png_ptr);
|
||||||
|
png_set_strip_alpha(source->png_ptr);
|
||||||
|
png_set_interlace_handling(source->png_ptr);
|
||||||
|
|
||||||
|
png_init_io(source->png_ptr, source->pub.input_file);
|
||||||
|
png_read_info(source->png_ptr, source->info_ptr);
|
||||||
|
|
||||||
|
png_get_IHDR(source->png_ptr, source->info_ptr, &width, &height,
|
||||||
|
&bit_depth, &color_type, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (width > 65535 || height > 65535) {
|
||||||
|
ERREXITS(cinfo, JERR_PNG_ERROR, "Image too large");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
||||||
|
cinfo->in_color_space = JCS_GRAYSCALE;
|
||||||
|
cinfo->input_components = 1;
|
||||||
|
} else {
|
||||||
|
cinfo->in_color_space = JCS_RGB;
|
||||||
|
cinfo->input_components = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bit_depth == 16) {
|
||||||
|
png_set_strip_16(source->png_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
cinfo->data_precision = 8;
|
||||||
|
cinfo->image_width = width;
|
||||||
|
cinfo->image_height = height;
|
||||||
|
|
||||||
|
has_srgb_chunk = png_get_valid(source->png_ptr, source->info_ptr, PNG_INFO_sRGB);
|
||||||
|
|
||||||
|
gamma = 0.45455;
|
||||||
|
if (!has_srgb_chunk) {
|
||||||
|
png_get_gAMA(source->png_ptr, source->info_ptr, &gamma);
|
||||||
|
}
|
||||||
|
cinfo->input_gamma = gamma;
|
||||||
|
sinfo->get_pixel_rows = get_pixel_rows_png;
|
||||||
|
|
||||||
|
source->pub.marker_list = NULL;
|
||||||
|
profile = NULL;
|
||||||
|
unused1 = NULL;
|
||||||
|
unused2 = 0;
|
||||||
|
proflen = 0;
|
||||||
|
has_profile = 0;
|
||||||
|
|
||||||
|
if (has_srgb_chunk) {
|
||||||
|
/* PNG can declare use of an sRGB profile without embedding an ICC file, but JPEG doesn't have such feature */
|
||||||
|
has_profile = 1;
|
||||||
|
profile = tiny_srgb;
|
||||||
|
proflen = sizeof(tiny_srgb);
|
||||||
|
} else {
|
||||||
|
has_profile = png_get_iCCP(source->png_ptr, source->info_ptr, &unused1, &unused2, &profile, &proflen); /* your libpng is out of date if you get a warning here */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_profile && profile && proflen) {
|
||||||
|
if (proflen < 65535-14) {
|
||||||
|
datalen = proflen + 14;
|
||||||
|
dataptr = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, datalen);
|
||||||
|
memcpy(dataptr, "ICC_PROFILE\0\x01\x01", 14);
|
||||||
|
memcpy(dataptr + 14, profile, proflen);
|
||||||
|
marker = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, sizeof(struct jpeg_marker_struct));
|
||||||
|
marker->next = NULL;
|
||||||
|
marker->marker = JPEG_APP0+2;
|
||||||
|
marker->original_length = 0;
|
||||||
|
marker->data_length = datalen;
|
||||||
|
marker->data = dataptr;
|
||||||
|
source->pub.marker_list = marker;
|
||||||
|
} else {
|
||||||
|
WARNMS(cinfo, JERR_PNG_PROFILETOOLARGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_read_update_info(source->png_ptr, source->info_ptr);
|
||||||
|
|
||||||
|
rowbytes = png_get_rowbytes(source->png_ptr, source->info_ptr);
|
||||||
|
|
||||||
|
source->pub.buffer = (*cinfo->mem->alloc_sarray)((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)rowbytes, 1);
|
||||||
|
source->pub.buffer_height = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHODDEF(JDIMENSION)
|
||||||
|
get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
png_source_struct *source = (png_source_struct *)sinfo;
|
||||||
|
|
||||||
|
png_read_row(source->png_ptr, source->pub.buffer[0], NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
METHODDEF(void)
|
||||||
|
finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
||||||
|
{
|
||||||
|
png_source_struct *source = (png_source_struct *)sinfo;
|
||||||
|
|
||||||
|
png_read_end(source->png_ptr, source->info_ptr);
|
||||||
|
png_destroy_read_struct(&source->png_ptr, &source->info_ptr, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
16
rdppm.c
16
rdppm.c
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
* Modified 2009 by Bill Allombert, Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2015-2017, D. R. Commander.
|
* Copyright (C) 2015-2017, 2020, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -75,7 +75,7 @@ typedef struct {
|
|||||||
JSAMPROW pixrow; /* compressor input buffer */
|
JSAMPROW pixrow; /* compressor input buffer */
|
||||||
size_t buffer_width; /* width of I/O buffer */
|
size_t buffer_width; /* width of I/O buffer */
|
||||||
JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
|
JSAMPLE *rescale; /* => maxval-remapping array, or NULL */
|
||||||
int maxval;
|
unsigned int maxval;
|
||||||
} ppm_source_struct;
|
} ppm_source_struct;
|
||||||
|
|
||||||
typedef ppm_source_struct *ppm_source_ptr;
|
typedef ppm_source_struct *ppm_source_ptr;
|
||||||
@@ -125,7 +125,7 @@ read_pbm_integer(j_compress_ptr cinfo, FILE *infile, unsigned int maxval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (val > maxval)
|
if (val > maxval)
|
||||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -509,7 +509,7 @@ get_word_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||||
*ptr++ = rescale[temp];
|
*ptr++ = rescale[temp];
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -536,17 +536,17 @@ get_word_rgb_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||||
*ptr++ = rescale[temp];
|
*ptr++ = rescale[temp];
|
||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||||
*ptr++ = rescale[temp];
|
*ptr++ = rescale[temp];
|
||||||
temp = UCH(*bufferptr++) << 8;
|
temp = UCH(*bufferptr++) << 8;
|
||||||
temp |= UCH(*bufferptr++);
|
temp |= UCH(*bufferptr++);
|
||||||
if (temp > maxval)
|
if (temp > maxval)
|
||||||
ERREXIT(cinfo, JERR_PPM_TOOLARGE);
|
ERREXIT(cinfo, JERR_PPM_OUTOFRANGE);
|
||||||
*ptr++ = rescale[temp];
|
*ptr++ = rescale[temp];
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -720,7 +720,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
|
|||||||
/* On 16-bit-int machines we have to be careful of maxval = 65535 */
|
/* On 16-bit-int machines we have to be careful of maxval = 65535 */
|
||||||
source->rescale = (JSAMPLE *)
|
source->rescale = (JSAMPLE *)
|
||||||
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||||
(size_t)(((long)maxval + 1L) *
|
(size_t)(((long)MAX(maxval, 255) + 1L) *
|
||||||
sizeof(JSAMPLE)));
|
sizeof(JSAMPLE)));
|
||||||
half_maxval = maxval / 2;
|
half_maxval = maxval / 2;
|
||||||
for (val = 0; val <= (long)maxval; val++) {
|
for (val = 0; val <= (long)maxval; val++) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user