Compare commits
694 Commits
v1.2.0
...
webpack-de
Author | SHA1 | Date | |
---|---|---|---|
dc2f2e48c9 | |||
e691860999 | |||
fd87ae7d2a | |||
5df7dd7590 | |||
013946b137 | |||
81c183b0d6 | |||
f523db6403 | |||
cc6ea9e11c | |||
bd4b67037b | |||
8c5c97e106 | |||
a9d3bd71b5 | |||
0d0a9b4cdf | |||
f583770696 | |||
bae243ccdb | |||
02c113a68f | |||
600eead007 | |||
05416768d5 | |||
35d31f2324 | |||
82fadac70e | |||
47f9d22dd8 | |||
9420dba3bc | |||
e462875807 | |||
0747d2c419 | |||
4c658b79ef | |||
685558847f | |||
63ac34a662 | |||
42f9e4aed2 | |||
e14790f0b9 | |||
dfee848a39 | |||
a437afdf2b | |||
4768bc17ba | |||
0934c6c00f | |||
9d81a9cd57 | |||
239ffeb7a7 | |||
95570c8b3c | |||
6e52ac2a73 | |||
fd5c557065 | |||
0abb6f18ba | |||
4e5a810770 | |||
8a81792bd5 | |||
3f57f9fef1 | |||
549e1fc50a | |||
f3749a4e24 | |||
e316b0d667 | |||
8f2dcb5f48 | |||
5715fb7b1b | |||
cd33a2f759 | |||
ee561bb00e | |||
75275a5596 | |||
8cd811cafd | |||
4e090ea2f8 | |||
6b007a0235 | |||
c23d1091e7 | |||
d4f8b7f38b | |||
2c923e5239 | |||
fe52c9b307 | |||
3745a3fff1 | |||
d89e846896 | |||
db6dea846a | |||
8036579a3c | |||
0807fa4b9a | |||
3cda8285a1 | |||
0218d0aac5 | |||
cfba6e7bd5 | |||
c6015e2e8d | |||
94a2a7b32f | |||
03f33847a3 | |||
563b558204 | |||
3c92f2d531 | |||
f5ab9a9a59 | |||
7893660679 | |||
15dac42a7f | |||
53298a23ad | |||
7ffa45ba86 | |||
ee99cf6e0b | |||
2edb8cbd7e | |||
0ac3d17969 | |||
1baa823d77 | |||
368ad9505e | |||
08c267a98b | |||
0c3ef3fdf5 | |||
17dcc9c7d4 | |||
ac9a7767d2 | |||
c29006d593 | |||
e1ab43b76f | |||
409df481db | |||
02807aab32 | |||
34cb55978f | |||
d0f5d5a644 | |||
37f09245a6 | |||
c43f75f1f2 | |||
227d32be7b | |||
87955ab9a0 | |||
ecb0b15cdc | |||
ed451e4dfa | |||
1a26057452 | |||
98b930abde | |||
ddbeaa0870 | |||
b69dc4c7f4 | |||
ed6b8b89c6 | |||
2580f1e292 | |||
2ac684f98f | |||
b8d921ec16 | |||
9c0a375f01 | |||
d1cff7d84e | |||
9c2b582986 | |||
e342766cbf | |||
f1cd6a87da | |||
39e5741cb2 | |||
93cbe557cd | |||
97931bad22 | |||
1f35c40d3f | |||
c39383333f | |||
4fc18de5f9 | |||
aac30e6fd3 | |||
45785bcca3 | |||
f36cb5d3ef | |||
b7f7a5ac0a | |||
dd895f026b | |||
548c126521 | |||
ca00a22303 | |||
1ce6dd73d8 | |||
ff7dc2c4cf | |||
117b87132e | |||
42e7a7e165 | |||
796324ad71 | |||
cf1a718534 | |||
718427badb | |||
c5c520a71d | |||
17ffa57a8b | |||
005d5180b4 | |||
ce9b96994c | |||
a1fb445b06 | |||
8a516131ea | |||
9816be83ab | |||
63f607a3ea | |||
57418034c4 | |||
3892490023 | |||
5bedff583b | |||
d94835402f | |||
b7e45ab843 | |||
8313246fd1 | |||
2b3cafb1f4 | |||
d52698f005 | |||
6ad28c0b5c | |||
c76dabf063 | |||
e6d8bac9c5 | |||
42e43730c8 | |||
5c17fba349 | |||
85eb94b725 | |||
4fa73be842 | |||
7c89d09139 | |||
079e56f1e1 | |||
6065ceabfe | |||
265e6db2bd | |||
3a5c0aa30c | |||
f0c3ec9d51 | |||
1ae93b527c | |||
a95cb740bf | |||
de543b3206 | |||
1542bfb7fd | |||
f95954a9f1 | |||
bc8d75128f | |||
d3252bb1bb | |||
83d9d2c764 | |||
476268fe19 | |||
74492af675 | |||
bd4179aff2 | |||
27ae47117e | |||
7da3f07333 | |||
eeb3d3562a | |||
2d73c24e09 | |||
ed666dd381 | |||
6f18f08a8e | |||
eae808cb6f | |||
0ae99c9228 | |||
f4a16022ef | |||
12153c72dc | |||
ae7782031d | |||
7cd6487a28 | |||
62c53c9fed | |||
53a38b2ba1 | |||
f3dfcae3f0 | |||
3f7274a6ac | |||
f5bc715bc0 | |||
22b7e36c01 | |||
a0e6a377cd | |||
22b04c159d | |||
5b496ad85f | |||
92249ac711 | |||
629d64326d | |||
4621cbcae9 | |||
164191d746 | |||
b22adc9957 | |||
6b0a675469 | |||
d7fb0d9b40 | |||
bc1bf8542c | |||
309947a08f | |||
6aeaae6160 | |||
71b3c7dda2 | |||
48c06e86fa | |||
e8f4e82cf8 | |||
1b7d3fa394 | |||
650db99818 | |||
7638bb795e | |||
570e604be0 | |||
a056d1c363 | |||
fce61c8c89 | |||
d60d0ae47d | |||
9a838f1d55 | |||
8bf741ed4e | |||
9f660e5178 | |||
ef2318bcc1 | |||
364a5db5d5 | |||
4a01d0d548 | |||
4a9c28f89f | |||
3aed873467 | |||
2b7f059b8f | |||
33726e9c68 | |||
3d29f486e7 | |||
79e8a26f06 | |||
e8efd54766 | |||
edcc774c16 | |||
746b33a590 | |||
8a264efc67 | |||
f0af6e97a0 | |||
043107c101 | |||
e9e3b923e0 | |||
aea6e91b1d | |||
9c4717a13d | |||
559cabce9e | |||
7f6a3de7ca | |||
f3adc87f52 | |||
6499e9f63d | |||
ac1f104e49 | |||
87f89e6b2f | |||
7f6404d5a8 | |||
8e857cd393 | |||
b8f801333d | |||
499956e216 | |||
3932ee2c00 | |||
68177b7590 | |||
0a2a4122dc | |||
e6299569d0 | |||
578ad8c291 | |||
eaa294b689 | |||
6e97cfb8d5 | |||
80a68c48b2 | |||
98865f8141 | |||
78da9fd144 | |||
94c50a989b | |||
3e525e767c | |||
dfcc1e24e4 | |||
f3aa8edfca | |||
ffd7ee6013 | |||
64bb09dbc5 | |||
35fcbc40ed | |||
1b55a48680 | |||
88fbb19d29 | |||
3dc1501ff7 | |||
b7576c559a | |||
69ed2e1d56 | |||
55f7f3d72a | |||
055d0b4ea1 | |||
7735346ed0 | |||
2a06fdbbe0 | |||
19169199e9 | |||
76f3c39b78 | |||
8da52acc4c | |||
9253522a3a | |||
cf39a3e5a5 | |||
a08877f0ac | |||
2f0dc1c067 | |||
535d8c9142 | |||
6dc2ba3bef | |||
93cfdc8f98 | |||
671544349e | |||
d3c1939692 | |||
99642aef96 | |||
ac4942b640 | |||
23cb004a86 | |||
4b6de60978 | |||
de204aa56a | |||
976f811b36 | |||
855fc9e602 | |||
a8848e717c | |||
90b99faf8b | |||
d3cfffbbcf | |||
fade7f9be8 | |||
b10dd055d3 | |||
7532f01222 | |||
2df09efdee | |||
bed4f49a12 | |||
2b7fefff8b | |||
bdcf2519ce | |||
3f8afb72a6 | |||
2f834db224 | |||
3541ce7492 | |||
b6fae0eb4c | |||
fbaa282f07 | |||
6136ae7411 | |||
f024747299 | |||
66feffcc49 | |||
24254df7db | |||
cae73f1f1b | |||
073a52213e | |||
0d34485a00 | |||
65519d539e | |||
ec44a8e817 | |||
920f225cb0 | |||
d5d4bd61ff | |||
5656d10b67 | |||
adb4b6468b | |||
0a293d7f63 | |||
27cb5afd5b | |||
5e58fc6b04 | |||
e820adfc96 | |||
5a8a114dcb | |||
a1c685e820 | |||
377dcfcc1b | |||
913e67ca93 | |||
fb1a97c7d4 | |||
42eef6945d | |||
d04b08d640 | |||
c547dd10d3 | |||
f4579da9c9 | |||
37dc585d80 | |||
bc0a425a0f | |||
b696f246a1 | |||
e6e197e140 | |||
1c0e8a1fd3 | |||
e3e154fa1a | |||
73b7c437f9 | |||
719168be77 | |||
a2021b175c | |||
9a388fbd13 | |||
1ba0452540 | |||
73df9f18f0 | |||
0e7521877b | |||
120b37c192 | |||
5f3502b838 | |||
33f99432c5 | |||
85756ff5df | |||
84e567ad6a | |||
39281331fa | |||
438ce2ce63 | |||
a13e17e256 | |||
cd6db2d776 | |||
a08662b617 | |||
003ec9de35 | |||
e7f76ca0b8 | |||
21111e2927 | |||
445c3ef32c | |||
9df5542ee1 | |||
fffc4a0cd1 | |||
50a8743be3 | |||
8480bc7dbd | |||
72e4546922 | |||
11be5babca | |||
17e5db2427 | |||
465093eb07 | |||
b430ac1041 | |||
ea96847c1e | |||
3b5106a61d | |||
9f611b0b52 | |||
18a6b3c3e5 | |||
d9ed4e18ea | |||
9e757aa896 | |||
89b58bb446 | |||
e80ca583cc | |||
2ecc81b34f | |||
60e98ee34f | |||
538ea89ea9 | |||
3990e11e0a | |||
0251f88fe5 | |||
bbcb959b11 | |||
b5e928bac9 | |||
6592dee4a9 | |||
9b3d72191e | |||
a92e5b48ff | |||
e355764ab0 | |||
c5efd5a8bf | |||
385461944b | |||
8385ba3274 | |||
6ca6a77595 | |||
14c837e894 | |||
33346d7cb6 | |||
05d4f531e2 | |||
ede2c49b12 | |||
16acd32c68 | |||
cc90192860 | |||
3607005fa8 | |||
7646a64f94 | |||
c8ce6ce27b | |||
1240474c4b | |||
f5e84441c0 | |||
6bc19d78bc | |||
a4437d2873 | |||
cd19650748 | |||
253315b3b1 | |||
4203ad9a13 | |||
6958202f9d | |||
386fef063f | |||
d7246ca427 | |||
fd024853b6 | |||
bd53d17876 | |||
3f87f571f4 | |||
1c69a6f1b7 | |||
82419cbb6e | |||
db65630c8d | |||
b8e54b947f | |||
f23897108d | |||
1efe5b21f0 | |||
fc71b4d249 | |||
dc81d46556 | |||
56c2080f43 | |||
4cc50fcaa5 | |||
2d67562576 | |||
76f2d7afa7 | |||
80fa9c4f21 | |||
8f215a5b4b | |||
bffd9cb52a | |||
74b1ff5b10 | |||
3c0079fea0 | |||
c0a9723d20 | |||
a4f0a76200 | |||
eb57b0130b | |||
f8c37c7abc | |||
72373f8812 | |||
b285e99e7d | |||
f9a6b88bb6 | |||
4a65d506f2 | |||
3bc03c90fd | |||
c35dfa4ac5 | |||
1d2a9a9dde | |||
925220bb13 | |||
16d088bfe3 | |||
b8e22ee435 | |||
60dea4b932 | |||
8ae1a42e4b | |||
cfdc7a46e6 | |||
afb23adcbf | |||
3b84a474b8 | |||
e96bb04e88 | |||
2e3b8507b2 | |||
e12c69f1a6 | |||
d049a23469 | |||
2633f427c8 | |||
ff920f1d7b | |||
fd69560025 | |||
ba51e47e05 | |||
409f552274 | |||
69a7c184bd | |||
3039c84738 | |||
bfa5cd085d | |||
7c282b30b1 | |||
06fa3c541e | |||
c9e31ac1f7 | |||
e248486d3d | |||
b32a52d236 | |||
a24b4d6d4d | |||
b831aa0075 | |||
bf4d4b78cb | |||
496896e36e | |||
6b88ec1f8a | |||
3af5f3a96d | |||
ddc5564515 | |||
bc5da7ef06 | |||
45221c0b03 | |||
d29cf2ffa7 | |||
f6c0b89d1f | |||
ecd9e06665 | |||
9e5b66d5f4 | |||
8c35c3cdaa | |||
828a6240fe | |||
eaad0eaee0 | |||
db76d4417c | |||
7a6c6ec210 | |||
8e034f183b | |||
5a01b34cce | |||
1399a9bffe | |||
653c6ed85a | |||
ebbb7b58cb | |||
7164e4e315 | |||
23398d07f9 | |||
ec2bc3efa2 | |||
86d78763c1 | |||
fb5ae36d7e | |||
51f812625b | |||
479bfee647 | |||
a3501a56cd | |||
c353e286b0 | |||
8ed01e8a87 | |||
36ed21b9f4 | |||
cca41bb449 | |||
8f787ad0e6 | |||
9c1170f100 | |||
5432be4a3f | |||
7cae821db5 | |||
19ebb24f03 | |||
d07512566e | |||
61929666f3 | |||
792ffbfcd7 | |||
9685271bb4 | |||
5b1a6cc95e | |||
bf34075e6a | |||
f1859eeef2 | |||
fa12b37e53 | |||
520a5dc9f2 | |||
7af949b5a5 | |||
300612b09b | |||
6f00e9825c | |||
6ca9c5300e | |||
cdeb31051b | |||
ba90517ad7 | |||
7aff949f47 | |||
0e8c0da3dd | |||
3132a207e1 | |||
88dd0e06c5 | |||
f507a2464f | |||
14baa6ebf8 | |||
5d32126565 | |||
484ff7ab4c | |||
36f86385a2 | |||
436faa17af | |||
d205ae206f | |||
6baa5900fc | |||
fadb53f075 | |||
1a63387408 | |||
a316120b69 | |||
0d1e5ef119 | |||
b49cfca39d | |||
ab58df4c2c | |||
db20f10bd2 | |||
444cc5a193 | |||
6c253bc9b4 | |||
2fd28e174e | |||
a188692c88 | |||
b263419e08 | |||
826e06c727 | |||
dfcdfb105f | |||
0508bbb16f | |||
dfbfa85fd3 | |||
b99ad4bdc3 | |||
e801170496 | |||
91e7c9c5ad | |||
ca5162ed32 | |||
0bf87d0c87 | |||
ce91eb5bae | |||
8d68056bca | |||
d0de8e444a | |||
dfef1f21cc | |||
2440ac4e87 | |||
e90db78697 | |||
5ae15d429c | |||
89d6b46f3e | |||
e086f64779 | |||
9ed3b4f11e | |||
ece3fa12b4 | |||
9a35224535 | |||
ef3faa58bc | |||
b6a8f7eeba | |||
d1203d9c42 | |||
a834b6ae38 | |||
e7982a73ad | |||
717342c80c | |||
075f0e62fd | |||
bcca31fbed | |||
007891fc11 | |||
f8e41952d1 | |||
e4d64f8a79 | |||
1654f69ec1 | |||
cb16fb5437 | |||
36f5fa2c47 | |||
51ad22e72c | |||
1a355c0c16 | |||
fe5ba08963 | |||
7fc994d4af | |||
a0a8285e02 | |||
da2e35f613 | |||
09bdc25352 | |||
ad263a9c36 | |||
c8d8d4e43d | |||
94249b8a93 | |||
edd2c51eb6 | |||
1d24e9399f | |||
3a0062276d | |||
1993cf3f6c | |||
c97aac31c6 | |||
507921cbe8 | |||
887db675c8 | |||
3917618e4e | |||
3c42d2e6a4 | |||
db8777b7f7 | |||
18c2cddee2 | |||
3ff9d3a1fa | |||
6503667c78 | |||
0fa95f84d4 | |||
cf91a90270 | |||
690052f989 | |||
b3e935f7e4 | |||
17314ebd29 | |||
adc437cd51 | |||
0e97b74510 | |||
9ffb475cac | |||
faa2b030c5 | |||
e3b3b10e2a | |||
b569cf268c | |||
b154b77556 | |||
84c0f30a7c | |||
16463ff76d | |||
8314e9e24b | |||
a33c557818 | |||
6fbdc65ad0 | |||
9c9b6c4711 | |||
46278d04c3 | |||
c1c16508b5 | |||
ed1b983711 | |||
ec23e28eda | |||
d48b49e8e4 | |||
14308970c6 | |||
38e86e1012 | |||
e9a33af831 | |||
6a63e5dbb2 | |||
1e1892a3d5 | |||
8bff9a2973 | |||
cbe753dd29 | |||
b047845b43 | |||
1bebc75381 | |||
93c46bfc8d | |||
a3d0f5963e | |||
006b82bf05 | |||
c36e37ac6b | |||
3cf6d7385a | |||
9045b2fa97 | |||
be6f3b9c6d | |||
5a699b7ce9 | |||
f366a78e87 | |||
c63c7ead51 | |||
ecfa5902cd | |||
444027b496 | |||
9c5dcb93c7 | |||
9594221271 | |||
01823d3b75 | |||
db07a90139 | |||
962d0928d3 | |||
e67d50c8e6 | |||
f9b2f17852 | |||
9746a9f5ed | |||
be0877ecb0 | |||
d2fcdfae43 | |||
2c9eb46941 | |||
d30a85fd48 | |||
9260bed1b1 | |||
f6d12985a9 | |||
10c9b1db7c | |||
4fb17be8de | |||
b592b1a088 | |||
0544a6507e | |||
1e20ff15ed | |||
04a0ec0645 | |||
f355292fe3 | |||
32e4d813de | |||
f960f5ea87 | |||
aa6f83e2fa | |||
c09e1f1895 | |||
7c311928dd | |||
5f1c8bcb6b | |||
93bc20f014 | |||
d29d9571c6 | |||
3d47dfc820 | |||
d7846c9add | |||
4d6fe9d641 | |||
205feba75d | |||
ca7663b94a | |||
83e45f054b | |||
783e893a67 | |||
0a941866a9 | |||
04edfe0085 | |||
6cae634eca | |||
8c7bf278dc | |||
f6106650b5 | |||
166e606034 | |||
c997e6a3e4 | |||
2a1b6dc9da | |||
129c33fa12 | |||
3245987113 | |||
593ad62cbb | |||
a625a76e9e | |||
c2a305304b | |||
7389c507fb | |||
68f0f23016 | |||
dc809dde30 | |||
80dfa03b94 |
2
.clang-format
Normal file
2
.clang-format
Normal file
@ -0,0 +1,2 @@
|
||||
BasedOnStyle: Chromium
|
||||
ColumnLimit: 100
|
@ -7,3 +7,6 @@ end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
@ -1,7 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
- 10
|
||||
- 8
|
||||
cache: npm
|
||||
script: npm run build
|
||||
after_success: npm run sizereport
|
||||
os:
|
||||
- linux
|
||||
- windows
|
||||
|
@ -10,6 +10,7 @@ Google Analytics is used to record the following:
|
||||
* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
|
||||
* Before and after image size once an image is downloaded. These values are rounded to the nearest
|
||||
kilobyte.
|
||||
* If install is available, when Squoosh is installed, and what method was used to install Squoosh.
|
||||
|
||||
Image compression is handled locally; no additional data is sent to the server.
|
||||
|
||||
|
@ -16,3 +16,8 @@
|
||||
# But it isn't a big deal if the user gets an old version.
|
||||
/assets/*
|
||||
Cache-Control: must-revalidate, max-age=3600
|
||||
|
||||
# COOP+COEP for WebAssembly threads.
|
||||
/*
|
||||
Cross-Origin-Embedder-Policy: require-corp
|
||||
Cross-Origin-Opener-Policy: same-origin
|
||||
|
2
_redirects.ejs
Normal file
2
_redirects.ejs
Normal file
@ -0,0 +1,2 @@
|
||||
/index.html / 301
|
||||
/* /index.html 301
|
84
codecs/avif/Makefile
Normal file
84
codecs/avif/Makefile
Normal file
@ -0,0 +1,84 @@
|
||||
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/31d7c6d1e32cf467ac24fb8c7a76c4902a4c00db.tar.gz
|
||||
CODEC_PACKAGE = node_modules/libavif.tar.gz
|
||||
|
||||
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/v2.0.0.tar.gz
|
||||
LIBAOM_PACKAGE = node_modules/libaom.tar.gz
|
||||
|
||||
export CODEC_DIR = node_modules/libavif
|
||||
BUILD_DIR := node_modules/build
|
||||
ENC_BUILD_DIR := $(BUILD_DIR)/enc
|
||||
ENC_MT_BUILD_DIR := $(BUILD_DIR)/enc-mt
|
||||
DEC_BUILD_DIR := $(BUILD_DIR)/dec
|
||||
export LIBAOM_DIR = node_modules/libaom
|
||||
|
||||
OUT_ENC_JS = enc/avif_enc.js
|
||||
OUT_ENC_MT_JS = enc/avif_enc_mt.js
|
||||
OUT_DEC_JS = dec/avif_dec.js
|
||||
|
||||
OUT_ENC_CPP = enc/avif_enc.cpp
|
||||
OUT_DEC_CPP = dec/avif_dec.cpp
|
||||
|
||||
HELPER_MAKEFLAGS := -f helper.Makefile
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_ENC_JS) $(OUT_DEC_JS) $(OUT_ENC_MT_JS)
|
||||
|
||||
$(OUT_ENC_JS): $(OUT_ENC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMakeLists.txt
|
||||
$(MAKE) \
|
||||
$(HELPER_MAKEFLAGS) \
|
||||
BUILD_DIR=$(ENC_BUILD_DIR) \
|
||||
OUT_JS=$@ \
|
||||
OUT_CPP=$< \
|
||||
LIBAOM_FLAGS="\
|
||||
-DCONFIG_AV1_DECODER=0 \
|
||||
-DCONFIG_MULTITHREAD=0 \
|
||||
-DCONFIG_AV1_HIGHBITDEPTH=0 \
|
||||
" \
|
||||
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_DECODE=0"
|
||||
|
||||
$(OUT_ENC_MT_JS): $(OUT_ENC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMakeLists.txt
|
||||
$(MAKE) \
|
||||
$(HELPER_MAKEFLAGS) \
|
||||
BUILD_DIR=$(ENC_MT_BUILD_DIR) \
|
||||
OUT_JS=$@ \
|
||||
OUT_CPP=$< \
|
||||
LIBAOM_FLAGS="\
|
||||
-DCONFIG_AV1_DECODER=0 \
|
||||
-DCONFIG_AV1_HIGHBITDEPTH=0 \
|
||||
" \
|
||||
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_DECODE=0" \
|
||||
OUT_FLAGS="-pthread"
|
||||
|
||||
$(OUT_DEC_JS): $(OUT_DEC_CPP) $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_DIR)/CMakeLists.txt
|
||||
$(MAKE) \
|
||||
$(HELPER_MAKEFLAGS) \
|
||||
BUILD_DIR=$(DEC_BUILD_DIR) \
|
||||
OUT_JS=$@ \
|
||||
OUT_CPP=$< \
|
||||
LIBAOM_FLAGS="\
|
||||
-DCONFIG_AV1_ENCODER=0 \
|
||||
-DCONFIG_MULTITHREAD=0 \
|
||||
" \
|
||||
LIBAVIF_FLAGS="-DAVIF_CODEC_AOM_ENCODE=0"
|
||||
|
||||
$(CODEC_PACKAGE):
|
||||
mkdir -p $(@D)
|
||||
curl -sL $(CODEC_URL) -o $@
|
||||
|
||||
$(LIBAOM_PACKAGE):
|
||||
mkdir -p $(@D)
|
||||
curl -sL $(LIBAOM_URL) -o $@
|
||||
|
||||
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_PACKAGE)
|
||||
mkdir -p $(@D)
|
||||
tar xzm --strip 1 -C $(@D) -f $(CODEC_PACKAGE)
|
||||
|
||||
$(LIBAOM_DIR)/CMakeLists.txt: $(LIBAOM_PACKAGE)
|
||||
mkdir -p $(@D)
|
||||
tar xzm -C $(@D) -f $(LIBAOM_PACKAGE)
|
||||
|
||||
clean:
|
||||
$(MAKE) $(HELPER_MAKEFLAGS) BUILD_DIR=$(ENC_BUILD_DIR) OUT_JS=$(OUT_ENC_JS) clean
|
||||
$(MAKE) $(HELPER_MAKEFLAGS) BUILD_DIR=$(ENC_MT_BUILD_DIR) OUT_JS=$(OUT_ENC_MT_JS) clean
|
||||
$(MAKE) $(HELPER_MAKEFLAGS) BUILD_DIR=$(DEC_BUILD_DIR) OUT_JS=$(OUT_DEC_JS) clean
|
14
codecs/avif/dec/README.md
Normal file
14
codecs/avif/dec/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# AVIF decoder
|
||||
|
||||
- Source: <https://github.com/AOMediaCodec/libavif>
|
||||
- Version: v0.5.4
|
||||
|
||||
## Example
|
||||
|
||||
See `example.html`
|
||||
|
||||
## API
|
||||
|
||||
### `RawImage decode(std::string buffer)`
|
||||
|
||||
Decodes the given avif buffer into raw RGBA. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.
|
48
codecs/avif/dec/avif_dec.cpp
Normal file
48
codecs/avif/dec/avif_dec.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include "avif/avif.h"
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
|
||||
thread_local const val ImageData = val::global("ImageData");
|
||||
|
||||
val decode(std::string avifimage) {
|
||||
avifImage* image = avifImageCreateEmpty();
|
||||
avifDecoder* decoder = avifDecoderCreate();
|
||||
avifResult decodeResult =
|
||||
avifDecoderReadMemory(decoder, image, (uint8_t*)avifimage.c_str(), avifimage.length());
|
||||
// image is an independent copy of decoded data, decoder may be destroyed here
|
||||
avifDecoderDestroy(decoder);
|
||||
|
||||
val result = val::null();
|
||||
|
||||
if (decodeResult == AVIF_RESULT_OK) {
|
||||
// Convert to interleaved RGB(A)/BGR(A) using a libavif-allocated buffer.
|
||||
avifRGBImage rgb;
|
||||
avifRGBImageSetDefaults(&rgb,
|
||||
image); // Defaults to AVIF_RGB_FORMAT_RGBA which is what we want.
|
||||
rgb.depth = 8; // Does not need to match image->depth. We always want 8-bit pixels.
|
||||
|
||||
avifRGBImageAllocatePixels(&rgb);
|
||||
avifImageYUVToRGB(image, &rgb);
|
||||
|
||||
// We want to create a *copy* of the decoded data to be owned by the JavaScript side.
|
||||
// For that, we perform `new Uint8Array(wasmMemBuffer, wasmPtr, wasmSize).slice()`:
|
||||
result = ImageData.new_(
|
||||
Uint8ClampedArray.new_(typed_memory_view(rgb.rowBytes * rgb.height, rgb.pixels)), rgb.width,
|
||||
rgb.height);
|
||||
|
||||
// Now we can safely free the RGB pixels:
|
||||
avifRGBImageFreePixels(&rgb);
|
||||
}
|
||||
|
||||
// Image has been converted to RGB, we don't need the original anymore.
|
||||
avifImageDestroy(image);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
function("decode", &decode);
|
||||
}
|
6
codecs/avif/dec/avif_dec.d.ts
vendored
Normal file
6
codecs/avif/dec/avif_dec.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
interface AVIFModule extends EmscriptenWasm.Module {
|
||||
decode(data: BufferSource): ImageData | null;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<AVIFModule>;
|
||||
|
71
codecs/avif/dec/avif_dec.js
Normal file
71
codecs/avif/dec/avif_dec.js
Normal file
@ -0,0 +1,71 @@
|
||||
|
||||
var avif_dec = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(avif_dec) {
|
||||
avif_dec = avif_dec || {};
|
||||
|
||||
|
||||
var d;d||(d=typeof avif_dec !== 'undefined' ? avif_dec : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var u=!1,v=!1,ca=!1,da=!1;u="object"===typeof window;v="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!u&&!ca&&!v;var w="",x,z,ea,fa;
|
||||
if(ca)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){ea||(ea=require("fs"));fa||(fa=require("path"));a=fa.normalize(a);return ea.readFileSync(a,b?null:"utf8")},z=function(a){a=x(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",A),d.inspect=function(){return"[Emscripten Module object]"};
|
||||
else if(da)"undefined"!=typeof read&&(x=function(a){return read(a)}),z=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||A("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(u||v)v?w=self.location.href:document.currentScript&&(w=document.currentScript.src),_scriptDir&&
|
||||
(w=_scriptDir),0!==w.indexOf("blob:")?w=w.substr(0,w.lastIndexOf("/")+1):w="",x=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},v&&(z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ha=d.print||console.log.bind(console),B=d.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;var ia=0,D;d.wasmBinary&&(D=d.wasmBinary);var noExitRuntime;
|
||||
d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&A("no native wasm support detected");var E,ja=new WebAssembly.Table({initial:645,maximum:645,element:"anyfunc"}),ka=!1,la="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function ma(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&la)return la.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var h=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|h:(f&7)<<18|g<<12|h<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
|
||||
function na(a,b,c){var e=F;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var oa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
|
||||
function pa(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&G[c];)++c;c<<=1;if(32<c-a&&oa)return oa.decode(F.subarray(a,c));c=0;for(e="";;){var f=H[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function qa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-e}function ra(a){return 2*a.length}
|
||||
function sa(a,b){for(var c=0,e="";!(c>=b/4);){var f=I[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function ta(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}I[b>>2]=g;b+=4;if(b+4>c)break}I[b>>2]=0;return b-e}
|
||||
function ua(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var J,va,F,H,G,I,L,wa,xa;function ya(a){J=a;d.HEAP8=va=new Int8Array(a);d.HEAP16=H=new Int16Array(a);d.HEAP32=I=new Int32Array(a);d.HEAPU8=F=new Uint8Array(a);d.HEAPU16=G=new Uint16Array(a);d.HEAPU32=L=new Uint32Array(a);d.HEAPF32=wa=new Float32Array(a);d.HEAPF64=xa=new Float64Array(a)}var za=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:za/65536,maximum:32768});
|
||||
E&&(J=E.buffer);za=J.byteLength;ya(J);I[153920]=5858720;function Aa(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.fa;"number"===typeof c?void 0===b.ba?d.dynCall_v(c):d.dynCall_vi(c,b.ba):c(void 0===b.ba?null:b.ba)}}}var Ba=[],Ca=[],Da=[],Ea=[];function Fa(){var a=d.preRun.shift();Ba.unshift(a)}var M=0,Ga=null,N=null;d.preloadedImages={};d.preloadedAudios={};
|
||||
function A(a){if(d.onAbort)d.onAbort(a);B(a);ka=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ha(a){var b=O;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ia(){return Ha("data:application/octet-stream;base64,")}var O="avif_dec.wasm";if(!Ia()){var Ja=O;O=d.locateFile?d.locateFile(Ja,w):w+Ja}
|
||||
function Ka(){try{if(D)return new Uint8Array(D);if(z)return z(O);throw"both async and sync fetching of the wasm failed";}catch(a){A(a)}}function La(){return D||!u&&!v||"function"!==typeof fetch||Ha("file://")?new Promise(function(a){a(Ka())}):fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Ca.push({fa:function(){Ma()}});
|
||||
function Na(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Oa=void 0;function Q(a){for(var b="";F[a];)b+=Oa[F[a++]];return b}var R={},S={},Pa={};function Qa(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
|
||||
function Ra(a,b){a=Qa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Sa(a){var b=Error,c=Ra(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
|
||||
var Ta=void 0;function T(a){throw new Ta(a);}var Ua=void 0;function Va(a,b){function c(l){l=b(l);if(l.length!==e.length)throw new Ua("Mismatched type converter count");for(var k=0;k<e.length;++k)U(e[k],l[k])}var e=[];e.forEach(function(l){Pa[l]=a});var f=Array(a.length),g=[],h=0;a.forEach(function(l,k){S.hasOwnProperty(l)?f[k]=S[l]:(g.push(l),R.hasOwnProperty(l)||(R[l]=[]),R[l].push(function(){f[k]=S[l];++h;h===g.length&&c(f)}))});0===g.length&&c(f)}
|
||||
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||T('type "'+e+'" must have a positive integer typeid pointer');if(S.hasOwnProperty(a)){if(c.ga)return;T("Cannot register type '"+e+"' twice")}S[a]=b;delete Pa[a];R.hasOwnProperty(a)&&(b=R[a],delete R[a],b.forEach(function(f){f()}))}var Wa=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Xa(a){4<a&&0===--V[a].da&&(V[a]=void 0,Wa.push(a))}function $a(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Wa.length?Wa.pop():V.length;V[b]={da:1,value:a};return b}}function ab(a){return this.fromWireType(L[a>>2])}function bb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function cb(a,b){switch(b){case 2:return function(c){return this.fromWireType(wa[c>>2])};case 3:return function(c){return this.fromWireType(xa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function db(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ra(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function eb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function fb(a,b){var c=d;if(void 0===c[a].$){var e=c[a];c[a]=function(){c[a].$.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].$+")!");return c[a].$[arguments.length].apply(this,arguments)};c[a].$=[];c[a].$[e.ea]=e}}
|
||||
function gb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].$&&void 0!==d[a].$[c])&&T("Cannot register public name '"+a+"' twice"),fb(a,a),d.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].$[c]=b):(d[a]=b,void 0!==c&&(d[a].ia=c))}function hb(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e]);return c}
|
||||
function ib(a,b){a=Q(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var jb=void 0;function kb(a){a=lb(a);var b=Q(a);W(a);return b}
|
||||
function mb(a,b){function c(g){f[g]||S[g]||(Pa[g]?Pa[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new jb(a+": "+e.map(kb).join([", "]));}function nb(a,b,c){switch(b){case 0:return c?function(e){return va[e]}:function(e){return F[e]};case 1:return c?function(e){return H[e>>1]}:function(e){return G[e>>1]};case 2:return c?function(e){return I[e>>2]}:function(e){return L[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ob={};
|
||||
function pb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function qb(a,b){var c=S[a];void 0===c&&T(b+" has unknown type "+kb(a));return c}for(var rb={},sb=[null,[],[]],tb=Array(256),ub=0;256>ub;++ub)tb[ub]=String.fromCharCode(ub);Oa=tb;Ta=d.BindingError=Sa("BindingError");Ua=d.InternalError=Sa("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};
|
||||
d.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};jb=d.UnboundTypeError=Sa("UnboundTypeError");
|
||||
var Ab={k:function(){},s:function(a,b,c,e,f){var g=Na(c);b=Q(b);U(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,l){return l?e:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var l=va;else if(2===c)l=H;else if(4===c)l=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(l[h>>g])},aa:null})},A:function(a,b){b=Q(b);U(a,{name:b,fromWireType:function(c){var e=V[c].value;Xa(c);return e},toWireType:function(c,e){return $a(e)},argPackAdvance:8,
|
||||
readValueFromPointer:ab,aa:null})},r:function(a,b,c){c=Na(c);b=Q(b);U(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+bb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,c),aa:null})},u:function(a,b,c,e,f,g){var h=hb(b,c);a=Q(a);f=ib(e,f);gb(a,function(){mb("Cannot call "+a+" due to unbound types",h)},b-1);Va(h,function(l){var k=[l[0],null].concat(l.slice(1)),m=l=a,p=
|
||||
f,q=k.length;2>q&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==k[1]&&!1,C=!1,n=1;n<k.length;++n)if(null!==k[n]&&void 0===k[n].aa){C=!0;break}var Ya="void"!==k[0].name,K="",P="";for(n=0;n<q-2;++n)K+=(0!==n?", ":"")+"arg"+n,P+=(0!==n?", ":"")+"arg"+n+"Wired";m="return function "+Qa(m)+"("+K+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";
|
||||
C&&(m+="var destructors = [];\n");var Za=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[T,p,g,eb,k[0],k[1]];y&&(m+="var thisWired = classParam.toWireType("+Za+", this);\n");for(n=0;n<q-2;++n)m+="var arg"+n+"Wired = argType"+n+".toWireType("+Za+", arg"+n+"); // "+k[n+2].name+"\n",K.push("argType"+n),p.push(k[n+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);m+=(Ya?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";if(C)m+="runDestructors(destructors);\n";
|
||||
else for(n=y?1:2;n<k.length;++n)q=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==k[n].aa&&(m+=q+"_dtor("+q+"); // "+k[n].name+"\n",K.push(q+"_dtor"),p.push(k[n].aa));Ya&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(m+"}\n");k=db(K).apply(null,p);n=b-1;if(!d.hasOwnProperty(l))throw new Ua("Replacing nonexistant public symbol");void 0!==d[l].$&&void 0!==n?d[l].$[n]=k:(d[l]=k,d[l].ea=n);return[]})},e:function(a,b,c,e,f){function g(m){return m}b=Q(b);-1===f&&(f=4294967295);var h=Na(c);
|
||||
if(0===e){var l=32-8*c;g=function(m){return m<<l>>>l}}var k=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(m,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+bb(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+bb(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return k?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:nb(b,h,0!==e),aa:null})},
|
||||
d:function(a,b,c){function e(g){g>>=2;var h=L;return new f(J,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=Q(c);U(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{ga:!0})},m:function(a,b){b=Q(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(e){var f=L[e>>2];if(c)for(var g=e+4,h=0;h<=f;++h){var l=e+4+h;if(h==f||0==F[l]){g=g?ma(F,g,l-g):"";if(void 0===k)var k=g;else k+=String.fromCharCode(0),k+=g;
|
||||
g=l+1}}else{k=Array(f);for(h=0;h<f;++h)k[h]=String.fromCharCode(F[e+4+h]);k=k.join("")}W(e);return k},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||T("Cannot pass non-string to std::string");var h=(c&&g?function(){for(var m=0,p=0;p<f.length;++p){var q=f.charCodeAt(p);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++p)&1023);127>=q?++m:m=2047>=q?m+2:65535>=
|
||||
q?m+3:m+4}return m}:function(){return f.length})(),l=vb(4+h+1);L[l>>2]=h;if(c&&g)na(f,l+4,h+1);else if(g)for(g=0;g<h;++g){var k=f.charCodeAt(g);255<k&&(W(l),T("String has UTF-16 code units that do not fit in 8 bits"));F[l+4+g]=k}else for(g=0;g<h;++g)F[l+4+g]=f[g];null!==e&&e.push(W,l);return l},argPackAdvance:8,readValueFromPointer:ab,aa:function(e){W(e)}})},l:function(a,b,c){c=Q(c);if(2===b){var e=pa;var f=qa;var g=ra;var h=function(){return G};var l=1}else 4===b&&(e=sa,f=ta,g=ua,h=function(){return L},
|
||||
l=2);U(a,{name:c,fromWireType:function(k){for(var m=L[k>>2],p=h(),q,y=k+4,C=0;C<=m;++C){var n=k+4+C*b;if(C==m||0==p[n>>l])y=e(y,n-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=n+b}W(k);return q},toWireType:function(k,m){"string"!==typeof m&&T("Cannot pass non-string to C++ string type "+c);var p=g(m),q=vb(4+p+b);L[q>>2]=p>>l;f(m,q+4,p+b);null!==k&&k.push(W,q);return q},argPackAdvance:8,readValueFromPointer:ab,aa:function(k){W(k)}})},t:function(a,b){b=Q(b);U(a,{ha:!0,name:b,argPackAdvance:0,
|
||||
fromWireType:function(){},toWireType:function(){}})},i:Xa,j:function(a){if(0===a)return $a(pb());var b=ob[a];a=void 0===b?Q(a):b;return $a(pb()[a])},n:function(a){4<a&&(V[a].da+=1)},o:function(a,b,c,e){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=rb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+
|
||||
g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",h+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(qb,d,$a);rb[b]=f}return f(a,c,e)},c:function(){A()},h:function(a,b){X(a,b||1);throw"longjmp";},y:function(a,b,c){F.copyWithin(a,b,b+c)},g:function(a){a>>>=0;var b=F.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*
|
||||
(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(2147483648,e)-J.byteLength+65535>>>16);ya(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},z:function(){return 0},v:function(){},q:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var h=I[b+8*g>>2],l=I[b+(8*g+4)>>2],k=0;k<l;k++){var m=F[h+k],p=sb[a];0===m||10===m?((1===a?ha:B)(ma(p,0)),p.length=0):p.push(m)}f+=l}I[e>>2]=f;return 0},a:function(){return ia|0},f:wb,w:xb,
|
||||
p:yb,x:zb,memory:E,b:function(a){ia=a|0},table:ja};
|
||||
(function(){function a(f){d.asm=f.exports;M--;d.monitorRunDependencies&&d.monitorRunDependencies(M);0==M&&(null!==Ga&&(clearInterval(Ga),Ga=null),N&&(f=N,N=null,f()))}function b(f){a(f.instance)}function c(f){return La().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var e={a:Ab};M++;d.monitorRunDependencies&&d.monitorRunDependencies(M);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){if(D||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||Ha("file://")||"function"!==typeof fetch)return c(b);fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var Ma=d.___wasm_call_ctors=function(){return(Ma=d.___wasm_call_ctors=d.asm.B).apply(null,arguments)},vb=d._malloc=function(){return(vb=d._malloc=d.asm.C).apply(null,arguments)},W=d._free=function(){return(W=d._free=d.asm.D).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.E).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.F).apply(null,arguments)};
|
||||
var X=d._setThrew=function(){return(X=d._setThrew=d.asm.G).apply(null,arguments)},Y=d.stackSave=function(){return(Y=d.stackSave=d.asm.H).apply(null,arguments)},Z=d.stackRestore=function(){return(Z=d.stackRestore=d.asm.I).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.J).apply(null,arguments)};
|
||||
var Bb=d.dynCall_viiii=function(){return(Bb=d.dynCall_viiii=d.asm.K).apply(null,arguments)},Cb=d.dynCall_viiiiiii=function(){return(Cb=d.dynCall_viiiiiii=d.asm.L).apply(null,arguments)},Db=d.dynCall_iii=function(){return(Db=d.dynCall_iii=d.asm.M).apply(null,arguments)},Eb=d.dynCall_iiiii=function(){return(Eb=d.dynCall_iiiii=d.asm.N).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.O).apply(null,arguments)};
|
||||
d.dynCall_iiijii=function(){return(d.dynCall_iiijii=d.asm.P).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.Q).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.R).apply(null,arguments)};d.dynCall_viiiiiiiiiii=function(){return(d.dynCall_viiiiiiiiiii=d.asm.S).apply(null,arguments)};d.dynCall_viiiiiiiiiiii=function(){return(d.dynCall_viiiiiiiiiiii=d.asm.T).apply(null,arguments)};
|
||||
d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.U).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.V).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.W).apply(null,arguments)};d.dynCall_iidiiii=function(){return(d.dynCall_iidiiii=d.asm.X).apply(null,arguments)};d.dynCall_viiiiiiiiii=function(){return(d.dynCall_viiiiiiiiii=d.asm.Y).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.Z).apply(null,arguments)};
|
||||
function zb(a,b,c,e,f,g,h,l){var k=Y();try{Cb(a,b,c,e,f,g,h,l)}catch(m){Z(k);if(m!==m+0&&"longjmp"!==m)throw m;X(1,0)}}function yb(a,b,c,e,f){var g=Y();try{Bb(a,b,c,e,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function wb(a,b,c){var e=Y();try{return Db(a,b,c)}catch(f){Z(e);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function xb(a,b,c,e,f){var g=Y();try{return Eb(a,b,c,e,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}var Fb;N=function Gb(){Fb||Hb();Fb||(N=Gb)};
|
||||
function Hb(){function a(){if(!Fb&&(Fb=!0,d.calledRun=!0,!ka)){Aa(Ca);Aa(Da);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Ea.unshift(b)}Aa(Ea)}}if(!(0<M)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Fa();Aa(Ba);0<M||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
|
||||
d.run=Hb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Hb();
|
||||
|
||||
|
||||
return avif_dec.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = avif_dec;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return avif_dec; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["avif_dec"] = avif_dec;
|
||||
|
BIN
codecs/avif/dec/avif_dec.wasm
Normal file
BIN
codecs/avif/dec/avif_dec.wasm
Normal file
Binary file not shown.
37
codecs/avif/enc/README.md
Normal file
37
codecs/avif/enc/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
# AVIF encoder
|
||||
|
||||
- Source: <https://github.com/AOMediaCodec/libavif>
|
||||
- Version: v0.5.4
|
||||
|
||||
## Example
|
||||
|
||||
Run example.js
|
||||
|
||||
## API
|
||||
|
||||
### `Uint8Array encode(std::string image_in, int image_width, int image_height, AvifOptions opts)`
|
||||
|
||||
Encodes the given image with given dimension to AVIF. Options looks like this:
|
||||
|
||||
```c++
|
||||
struct AvifOptions {
|
||||
// 0 = lossless
|
||||
// 63 = worst quality
|
||||
int minQuantizer;
|
||||
int maxQuantizer;
|
||||
|
||||
// [0 - 6]
|
||||
// Creates 2^n tiles in that dimension
|
||||
int tileRowsLog2;
|
||||
int tileColsLog2;
|
||||
|
||||
// 0 = slowest
|
||||
// 10 = fastest
|
||||
int speed;
|
||||
|
||||
// 0 = 4:2:0
|
||||
// 1 = 4:2:2
|
||||
// 2 = 4:4:4
|
||||
int subsample;
|
||||
};
|
||||
```
|
107
codecs/avif/enc/avif_enc.cpp
Normal file
107
codecs/avif/enc/avif_enc.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include <emscripten/threading.h>
|
||||
#include "avif/avif.h"
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
struct AvifOptions {
|
||||
// [0 - 63]
|
||||
// 0 = lossless
|
||||
// 63 = worst quality
|
||||
int minQuantizer;
|
||||
int maxQuantizer;
|
||||
int minQuantizerAlpha;
|
||||
int maxQuantizerAlpha;
|
||||
// [0 - 6]
|
||||
// Creates 2^n tiles in that dimension
|
||||
int tileRowsLog2;
|
||||
int tileColsLog2;
|
||||
// [0 - 10]
|
||||
// 0 = slowest
|
||||
// 10 = fastest
|
||||
int speed;
|
||||
// 0 = 4:0:0
|
||||
// 1 = 4:2:0
|
||||
// 2 = 4:2:2
|
||||
// 3 = 4:4:4
|
||||
int subsample;
|
||||
};
|
||||
|
||||
thread_local const val Uint8Array = val::global("Uint8Array");
|
||||
|
||||
val encode(std::string buffer, int width, int height, AvifOptions options) {
|
||||
avifRWData output = AVIF_DATA_EMPTY;
|
||||
int depth = 8;
|
||||
avifPixelFormat format;
|
||||
switch (options.subsample) {
|
||||
case 0:
|
||||
format = AVIF_PIXEL_FORMAT_YUV400;
|
||||
break;
|
||||
case 1:
|
||||
format = AVIF_PIXEL_FORMAT_YUV420;
|
||||
break;
|
||||
case 2:
|
||||
format = AVIF_PIXEL_FORMAT_YUV422;
|
||||
break;
|
||||
case 3:
|
||||
format = AVIF_PIXEL_FORMAT_YUV444;
|
||||
break;
|
||||
}
|
||||
|
||||
avifImage* image = avifImageCreate(width, height, depth, format);
|
||||
|
||||
if (
|
||||
options.maxQuantizer == AVIF_QUANTIZER_LOSSLESS &&
|
||||
options.minQuantizer == AVIF_QUANTIZER_LOSSLESS &&
|
||||
options.minQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS &&
|
||||
options.maxQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS &&
|
||||
format == AVIF_PIXEL_FORMAT_YUV444
|
||||
) {
|
||||
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY;
|
||||
} else {
|
||||
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT709;
|
||||
}
|
||||
|
||||
uint8_t* rgba = (uint8_t*)buffer.c_str();
|
||||
|
||||
avifRGBImage srcRGB;
|
||||
avifRGBImageSetDefaults(&srcRGB, image);
|
||||
srcRGB.pixels = rgba;
|
||||
srcRGB.rowBytes = width * 4;
|
||||
avifImageRGBToYUV(image, &srcRGB);
|
||||
|
||||
avifEncoder* encoder = avifEncoderCreate();
|
||||
encoder->maxThreads = emscripten_num_logical_cores();
|
||||
encoder->minQuantizer = options.minQuantizer;
|
||||
encoder->maxQuantizer = options.maxQuantizer;
|
||||
encoder->minQuantizerAlpha = options.minQuantizerAlpha;
|
||||
encoder->maxQuantizerAlpha = options.maxQuantizerAlpha;
|
||||
encoder->tileRowsLog2 = options.tileRowsLog2;
|
||||
encoder->tileColsLog2 = options.tileColsLog2;
|
||||
encoder->speed = options.speed;
|
||||
avifResult encodeResult = avifEncoderWrite(encoder, image, &output);
|
||||
auto js_result = val::null();
|
||||
if (encodeResult == AVIF_RESULT_OK) {
|
||||
js_result = Uint8Array.new_(typed_memory_view(output.size, output.data));
|
||||
}
|
||||
|
||||
avifImageDestroy(image);
|
||||
avifEncoderDestroy(encoder);
|
||||
avifRWDataFree(&output);
|
||||
return js_result;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
value_object<AvifOptions>("AvifOptions")
|
||||
.field("minQuantizer", &AvifOptions::minQuantizer)
|
||||
.field("maxQuantizer", &AvifOptions::maxQuantizer)
|
||||
.field("minQuantizerAlpha", &AvifOptions::minQuantizerAlpha)
|
||||
.field("maxQuantizerAlpha", &AvifOptions::maxQuantizerAlpha)
|
||||
.field("tileRowsLog2", &AvifOptions::tileRowsLog2)
|
||||
.field("tileColsLog2", &AvifOptions::tileColsLog2)
|
||||
.field("speed", &AvifOptions::speed)
|
||||
.field("subsample", &AvifOptions::subsample);
|
||||
|
||||
function("encode", &encode);
|
||||
}
|
7
codecs/avif/enc/avif_enc.d.ts
vendored
Normal file
7
codecs/avif/enc/avif_enc.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { EncodeOptions } from '../../../src/codecs/avif/encoder-meta';
|
||||
|
||||
interface AVIFModule extends EmscriptenWasm.Module {
|
||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<AVIFModule>;
|
113
codecs/avif/enc/avif_enc.js
Normal file
113
codecs/avif/enc/avif_enc.js
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
var avif_enc = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(avif_enc) {
|
||||
avif_enc = avif_enc || {};
|
||||
|
||||
|
||||
var f;f||(f=typeof avif_enc !== 'undefined' ? avif_enc : {});var aa,ba;f.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},m;for(m in f)f.hasOwnProperty(m)&&(ca[m]=f[m]);var da=!1,r=!1,ea=!1,fa=!1;da="object"===typeof window;r="function"===typeof importScripts;ea="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;fa=!da&&!ea&&!r;var v="",ha,ia,ja,ka;
|
||||
if(ea)v=r?require("path").dirname(v)+"/":__dirname+"/",ha=function(a,b){ja||(ja=require("fs"));ka||(ka=require("path"));a=ka.normalize(a);return ja.readFileSync(a,b?null:"utf8")},ia=function(a){a=ha(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",x),f.inspect=function(){return"[Emscripten Module object]"};else if(fa)"undefined"!=
|
||||
typeof read&&(ha=function(a){return read(a)}),ia=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(da||r)r?v=self.location.href:document.currentScript&&(v=document.currentScript.src),_scriptDir&&(v=_scriptDir),0!==v.indexOf("blob:")?v=v.substr(0,
|
||||
v.lastIndexOf("/")+1):v="",ha=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},r&&(ia=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var la=f.print||console.log.bind(console),z=f.printErr||console.warn.bind(console);for(m in ca)ca.hasOwnProperty(m)&&(f[m]=ca[m]);ca=null;var ma=0,na;f.wasmBinary&&(na=f.wasmBinary);var noExitRuntime;f.noExitRuntime&&(noExitRuntime=f.noExitRuntime);
|
||||
"object"!==typeof WebAssembly&&x("no native wasm support detected");var A,oa=new WebAssembly.Table({initial:862,maximum:862,element:"anyfunc"}),pa=!1;function assert(a,b){a||x("Assertion failed: "+b)}var ra="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function B(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&ra)return ra.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var g=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|g);else{var h=a[b++]&63;e=224==(e&240)?(e&15)<<12|g<<6|h:(e&7)<<18|g<<12|h<<6|a[b++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d}
|
||||
function sa(a,b,c,d){if(!(0<d))return 0;var e=c;d=c+d-1;for(var g=0;g<a.length;++g){var h=a.charCodeAt(g);if(55296<=h&&57343>=h){var k=a.charCodeAt(++g);h=65536+((h&1023)<<10)|k&1023}if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(c+3>=d)break;b[c++]=240|h>>18;b[c++]=128|h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-e}
|
||||
function ta(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var ua="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function va(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&wa[c];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(C.subarray(a,c));c=0;for(d="";;){var e=E[a+2*c>>1];if(0==e||c==b/2)return d;++c;d+=String.fromCharCode(e)}}
|
||||
function xa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var e=0;e<c;++e)E[b>>1]=a.charCodeAt(e),b+=2;E[b>>1]=0;return b-d}function ya(a){return 2*a.length}function za(a,b){for(var c=0,d="";!(c>=b/4);){var e=F[a+4*c>>2];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d}
|
||||
function Aa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e<a.length;++e){var g=a.charCodeAt(e);if(55296<=g&&57343>=g){var h=a.charCodeAt(++e);g=65536+((g&1023)<<10)|h&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function Ba(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var G,H,C,E,wa,F,I,Ca,Da;
|
||||
function Ea(a){G=a;f.HEAP8=H=new Int8Array(a);f.HEAP16=E=new Int16Array(a);f.HEAP32=F=new Int32Array(a);f.HEAPU8=C=new Uint8Array(a);f.HEAPU16=wa=new Uint16Array(a);f.HEAPU32=I=new Uint32Array(a);f.HEAPF32=Ca=new Float32Array(a);f.HEAPF64=Da=new Float64Array(a)}var Fa=f.INITIAL_MEMORY||16777216;f.wasmMemory?A=f.wasmMemory:A=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});A&&(G=A.buffer);Fa=G.byteLength;Ea(G);F[219532]=6121168;
|
||||
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(f);else{var c=b.ib;"number"===typeof c?void 0===b.Pa?f.dynCall_v(c):f.dynCall_vi(c,b.Pa):c(void 0===b.Pa?null:b.Pa)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=f.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;f.preloadedImages={};f.preloadedAudios={};
|
||||
function x(a){if(f.onAbort)f.onAbort(a);z(a);pa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=K;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var K="avif_enc.wasm";if(!Ta()){var Ua=K;K=f.locateFile?f.locateFile(Ua,v):v+Ua}
|
||||
function Va(){try{if(na)return new Uint8Array(na);if(ia)return ia(K);throw"both async and sync fetching of the wasm failed";}catch(a){x(a)}}function Wa(){return na||!da&&!r||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(K,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+K+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var Xa,Ya;Ia.push({ib:function(){Za()}});
|
||||
function $a(a,b){for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function ab(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
|
||||
function bb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function cb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
|
||||
function db(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var eb=[];function fb(a,b){eb[a]={input:[],output:[],Ma:b};gb(a,hb)}
|
||||
var hb={open:function(a){var b=eb[a.node.rdev];if(!b)throw new L(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ma.flush(a.tty)},flush:function(a){a.tty.Ma.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ma.$a)throw new L(60);for(var e=0,g=0;g<d;g++){try{var h=a.tty.Ma.$a(a.tty)}catch(k){throw new L(29);}if(void 0===h&&0===e)throw new L(6);if(null===h||void 0===h)break;e++;b[c+g]=h}e&&(a.node.timestamp=Date.now());return e},write:function(a,b,c,d){if(!a.tty||!a.tty.Ma.Ra)throw new L(60);
|
||||
try{for(var e=0;e<d;e++)a.tty.Ma.Ra(a.tty,b[c+e])}catch(g){throw new L(29);}d&&(a.node.timestamp=Date.now());return e}},ib={$a:function(a){if(!a.input.length){var b=null;if(ea){var c=Buffer.eb?Buffer.eb(256):new Buffer(256),d=0;try{d=ja.readSync(process.stdin.fd,c,0,256,null)}catch(e){if(-1!=e.toString().indexOf("EOF"))d=0;else throw e;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
|
||||
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;c=Array(ta(b)+1);b=sa(b,c,0,c.length);c.length=b;a.input=c}return a.input.shift()},Ra:function(a,b){null===b||10===b?(la(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(la(B(a.output,0)),a.output=[])}},jb={Ra:function(a,b){null===b||10===b?(z(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(z(B(a.output,0)),a.output=[])}},M={Ea:null,
|
||||
Ia:function(){return M.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new L(63);M.Ea||(M.Ea={dir:{node:{Ja:M.Ba.Ja,Ga:M.Ba.Ga,lookup:M.Ba.lookup,Na:M.Ba.Na,rename:M.Ba.rename,unlink:M.Ba.unlink,rmdir:M.Ba.rmdir,readdir:M.Ba.readdir,symlink:M.Ba.symlink},stream:{La:M.Ca.La}},file:{node:{Ja:M.Ba.Ja,Ga:M.Ba.Ga},stream:{La:M.Ca.La,read:M.Ca.read,write:M.Ca.write,Ua:M.Ca.Ua,ab:M.Ca.ab,cb:M.Ca.cb}},link:{node:{Ja:M.Ba.Ja,Ga:M.Ba.Ga,readlink:M.Ba.readlink},
|
||||
stream:{}},Va:{node:{Ja:M.Ba.Ja,Ga:M.Ba.Ga},stream:kb}});c=lb(a,b,c,d);16384===(c.mode&61440)?(c.Ba=M.Ea.dir.node,c.Ca=M.Ea.dir.stream,c.Aa={}):32768===(c.mode&61440)?(c.Ba=M.Ea.file.node,c.Ca=M.Ea.file.stream,c.Da=0,c.Aa=null):40960===(c.mode&61440)?(c.Ba=M.Ea.link.node,c.Ca=M.Ea.link.stream):8192===(c.mode&61440)&&(c.Ba=M.Ea.Va.node,c.Ca=M.Ea.Va.stream);c.timestamp=Date.now();a&&(a.Aa[b]=c);return c},zb:function(a){if(a.Aa&&a.Aa.subarray){for(var b=[],c=0;c<a.Da;++c)b.push(a.Aa[c]);return b}return a.Aa},
|
||||
Ab:function(a){return a.Aa?a.Aa.subarray?a.Aa.subarray(0,a.Da):new Uint8Array(a.Aa):new Uint8Array(0)},Wa:function(a,b){var c=a.Aa?a.Aa.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Aa,a.Aa=new Uint8Array(b),0<a.Da&&a.Aa.set(c.subarray(0,a.Da),0))},sb:function(a,b){if(a.Da!=b)if(0==b)a.Aa=null,a.Da=0;else{if(!a.Aa||a.Aa.subarray){var c=a.Aa;a.Aa=new Uint8Array(b);c&&a.Aa.set(c.subarray(0,Math.min(b,a.Da)))}else if(a.Aa||(a.Aa=[]),a.Aa.length>b)a.Aa.length=b;
|
||||
else for(;a.Aa.length<b;)a.Aa.push(0);a.Da=b}},Ba:{Ja:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.Da:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.gb=4096;b.blocks=Math.ceil(b.size/b.gb);return b},Ga:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
|
||||
(a.timestamp=b.timestamp);void 0!==b.size&&M.sb(a,b.size)},lookup:function(){throw mb[44];},Na:function(a,b,c,d){return M.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=nb(b,c)}catch(g){}if(d)for(var e in d.Aa)throw new L(55);}delete a.parent.Aa[a.name];a.name=c;b.Aa[c]=a;a.parent=b},unlink:function(a,b){delete a.Aa[b]},rmdir:function(a,b){var c=nb(a,b),d;for(d in c.Aa)throw new L(55);delete a.Aa[b]},readdir:function(a){var b=[".",".."],c;for(c in a.Aa)a.Aa.hasOwnProperty(c)&&
|
||||
b.push(c);return b},symlink:function(a,b,c){a=M.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new L(28);return a.link}},Ca:{read:function(a,b,c,d,e){var g=a.node.Aa;if(e>=a.node.Da)return 0;a=Math.min(a.node.Da-e,d);if(8<a&&g.subarray)b.set(g.subarray(e,e+a),c);else for(d=0;d<a;d++)b[c+d]=g[e+d];return a},write:function(a,b,c,d,e,g){b.buffer===H.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Aa||a.Aa.subarray)){if(g)return a.Aa=
|
||||
b.subarray(c,c+d),a.Da=d;if(0===a.Da&&0===e)return a.Aa=b.slice(c,c+d),a.Da=d;if(e+d<=a.Da)return a.Aa.set(b.subarray(c,c+d),e),d}M.Wa(a,e+d);if(a.Aa.subarray&&b.subarray)a.Aa.set(b.subarray(c,c+d),e);else for(g=0;g<d;g++)a.Aa[e+g]=b[c+g];a.Da=Math.max(a.Da,e+d);return d},La:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Da);if(0>b)throw new L(28);return b},Ua:function(a,b,c){M.Wa(a.node,b+c);a.node.Da=Math.max(a.node.Da,b+c)},ab:function(a,b,c,d,e,g){assert(0===
|
||||
b);if(32768!==(a.node.mode&61440))throw new L(43);a=a.node.Aa;if(g&2||a.buffer!==G){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=ob(g);c<g;)H[b+c++]=0;c=b;if(!c)throw new L(48);H.set(a,c)}else d=!1,c=a.byteOffset;return{Eb:c,yb:d}},cb:function(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new L(43);if(e&2)return 0;M.Ca.write(a,b,0,d,c,!1);return 0}}},pb=null,qb={},rb=[],sb=1,tb=null,ub=!0,vb={},L=null,mb={};
|
||||
function N(a,b){a=db("/",a);b=b||{};if(!a)return{path:"",node:null};var c={Za:!0,Sa:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.Sa)throw new L(32);a=$a(a.split("/").filter(function(h){return!!h}),!1);var e=pb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;e=nb(e,a[d]);c=ab(c+"/"+a[d]);e.Oa&&(!g||g&&b.Za)&&(e=e.Oa.root);if(!g||b.Ya)for(g=0;40960===(e.mode&61440);)if(e=wb(c),c=db(bb(c),e),e=N(c,{Sa:b.Sa}).node,40<g++)throw new L(32);}return{path:c,node:e}}
|
||||
function xb(a){for(var b;;){if(a===a.parent)return a=a.Ia.bb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function yb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%tb.length}function nb(a,b){var c;if(c=(c=zb(a,"x"))?c:a.Ba.lookup?0:2)throw new L(c,a);for(c=tb[yb(a.id,b)];c;c=c.pb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Ba.lookup(a,b)}
|
||||
function lb(a,b,c,d){a=new Ab(a,b,c,d);b=yb(a.parent.id,a.name);a.pb=tb[b];return tb[b]=a}var Bb={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Cb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function zb(a,b){if(ub)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
|
||||
function Db(a,b){try{return nb(a,b),20}catch(c){}return zb(a,"wx")}function Eb(a){var b=4096;for(a=a||0;a<=b;a++)if(!rb[a])return a;throw new L(33);}function Fb(a,b){Gb||(Gb=function(){},Gb.prototype={});var c=new Gb,d;for(d in a)c[d]=a[d];a=c;b=Eb(b);a.fd=b;return rb[b]=a}var kb={open:function(a){a.Ca=qb[a.node.rdev].Ca;a.Ca.open&&a.Ca.open(a)},La:function(){throw new L(70);}};function gb(a,b){qb[a]={Ca:b}}
|
||||
function Hb(a,b){var c="/"===b,d=!b;if(c&&pb)throw new L(10);if(!c&&!d){var e=N(b,{Za:!1});b=e.path;e=e.node;if(e.Oa)throw new L(10);if(16384!==(e.mode&61440))throw new L(54);}b={type:a,Db:{},bb:b,ob:[]};a=a.Ia(b);a.Ia=b;b.root=a;c?pb=a:e&&(e.Oa=b,e.Ia&&e.Ia.ob.push(b))}function Ib(a,b,c){var d=N(a,{parent:!0}).node;a=cb(a);if(!a||"."===a||".."===a)throw new L(28);var e=Db(d,a);if(e)throw new L(e);if(!d.Ba.Na)throw new L(63);return d.Ba.Na(d,a,b,c)}function O(a){Ib(a,16895,0)}
|
||||
function Jb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Ib(a,b|8192,c)}function Kb(a,b){if(!db(a))throw new L(44);var c=N(b,{parent:!0}).node;if(!c)throw new L(44);b=cb(b);var d=Db(c,b);if(d)throw new L(d);if(!c.Ba.symlink)throw new L(63);c.Ba.symlink(c,b,a)}function wb(a){a=N(a).node;if(!a)throw new L(44);if(!a.Ba.readlink)throw new L(28);return db(xb(a.parent),a.Ba.readlink(a))}
|
||||
function Lb(a,b,c,d){if(""===a)throw new L(44);if("string"===typeof b){var e=Bb[b];if("undefined"===typeof e)throw Error("Unknown file open mode: "+b);b=e}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=ab(a);try{g=N(a,{Ya:!(b&131072)}).node}catch(k){}}e=!1;if(b&64)if(g){if(b&128)throw new L(20);}else g=Ib(a,c,0),e=!0;if(!g)throw new L(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new L(54);if(!e&&(c=g?40960===(g.mode&61440)?
|
||||
32:16384===(g.mode&61440)&&("r"!==Cb(b)||b&512)?31:zb(g,Cb(b)):44))throw new L(c);if(b&512){c=g;var h;"string"===typeof c?h=N(c,{Ya:!0}).node:h=c;if(!h.Ba.Ga)throw new L(63);if(16384===(h.mode&61440))throw new L(31);if(32768!==(h.mode&61440))throw new L(28);if(c=zb(h,"w"))throw new L(c);h.Ba.Ga(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Fb({node:g,path:xb(g),flags:b,seekable:!0,position:0,Ca:g.Ca,xb:[],error:!1},d);d.Ca.open&&d.Ca.open(d);!f.logReadFiles||b&1||(Mb||(Mb={}),a in Mb||(Mb[a]=1,z("FS.trackingDelegate error on read file: "+
|
||||
a)));try{vb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),vb.onOpenFile(a,g))}catch(k){z("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}return d}function Nb(a,b,c){if(null===a.fd)throw new L(8);if(!a.seekable||!a.Ca.La)throw new L(70);if(0!=c&&1!=c&&2!=c)throw new L(28);a.position=a.Ca.La(a,b,c);a.xb=[]}
|
||||
function Ob(){L||(L=function(a,b){this.node=b;this.tb=function(c){this.Ka=c};this.tb(a);this.message="FS error"},L.prototype=Error(),L.prototype.constructor=L,[44].forEach(function(a){mb[a]=new L(a);mb[a].stack="<generic error, no stack>"}))}var Pb;function Qb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
|
||||
function Rb(a,b,c){a=ab("/dev/"+a);var d=Qb(!!b,!!c);Sb||(Sb=64);var e=Sb++<<8|0;gb(e,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,k,l){for(var n=0,p=0;p<l;p++){try{var t=b()}catch(u){throw new L(29);}if(void 0===t&&0===n)throw new L(6);if(null===t||void 0===t)break;n++;h[k+p]=t}n&&(g.node.timestamp=Date.now());return n},write:function(g,h,k,l){for(var n=0;n<l;n++)try{c(h[k+n])}catch(p){throw new L(29);}l&&(g.node.timestamp=Date.now());return n}});
|
||||
Jb(a,d,e)}var Sb,Q={},Gb,Mb,Tb=void 0;function Ub(){Tb+=4;return F[Tb-4>>2]}function Vb(a){a=rb[a];if(!a)throw new L(8);return a}var Wb={};function Xb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Yb(a){return this.fromWireType(I[a>>2])}var Zb={},R={},$b={};function ac(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
|
||||
function bc(a,b){a=ac(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function cc(a){var b=Error,c=bc(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
|
||||
var dc=void 0;function ec(a,b,c){function d(k){k=c(k);if(k.length!==a.length)throw new dc("Mismatched type converter count");for(var l=0;l<a.length;++l)S(a[l],k[l])}a.forEach(function(k){$b[k]=b});var e=Array(b.length),g=[],h=0;b.forEach(function(k,l){R.hasOwnProperty(k)?e[l]=R[k]:(g.push(k),Zb.hasOwnProperty(k)||(Zb[k]=[]),Zb[k].push(function(){e[l]=R[k];++h;h===g.length&&d(e)}))});0===g.length&&d(e)}
|
||||
function fc(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var hc=void 0;function T(a){for(var b="";C[a];)b+=hc[C[a++]];return b}var ic=void 0;function U(a){throw new ic(a);}
|
||||
function S(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||U('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.mb)return;U("Cannot register type '"+d+"' twice")}R[a]=b;delete $b[a];Zb.hasOwnProperty(a)&&(b=Zb[a],delete Zb[a],b.forEach(function(e){e()}))}var jc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function kc(a){4<a&&0===--V[a].Ta&&(V[a]=void 0,jc.push(a))}function lc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=jc.length?jc.pop():V.length;V[b]={Ta:1,value:a};return b}}function mc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function nc(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ca[c>>2])};case 3:return function(c){return this.fromWireType(Da[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function oc(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=bc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function pc(a,b){var c=f;if(void 0===c[a].Fa){var d=c[a];c[a]=function(){c[a].Fa.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Fa+")!");return c[a].Fa[arguments.length].apply(this,arguments)};c[a].Fa=[];c[a].Fa[d.fb]=d}}
|
||||
function qc(a,b,c){f.hasOwnProperty(a)?((void 0===c||void 0!==f[a].Fa&&void 0!==f[a].Fa[c])&&U("Cannot register public name '"+a+"' twice"),pc(a,a),f.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),f[a].Fa[c]=b):(f[a]=b,void 0!==c&&(f[a].Cb=c))}function rc(a,b){for(var c=[],d=0;d<a;d++)c.push(F[(b>>2)+d]);return c}
|
||||
function sc(a,b){a=T(a);var c=f["dynCall_"+a];for(var d=[],e=1;e<a.length;++e)d.push("a"+e);e="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";e+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",e+"};\n"))(c,b);"function"!==typeof c&&U("unknown function pointer with signature "+a+": "+b);return c}var tc=void 0;function uc(a){a=vc(a);var b=T(a);W(a);return b}
|
||||
function wc(a,b){function c(g){e[g]||R[g]||($b[g]?$b[g].forEach(c):(d.push(g),e[g]=!0))}var d=[],e={};b.forEach(c);throw new tc(a+": "+d.map(uc).join([", "]));}function xc(a,b,c){switch(b){case 0:return c?function(d){return H[d]}:function(d){return C[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){return I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var yc={};
|
||||
function zc(){return"object"===typeof globalThis?globalThis:Function("return this")()}function Ac(a,b){var c=R[a];void 0===c&&U(b+" has unknown type "+uc(a));return c}var Bc={};function Ab(a,b,c,d){a||(a=this);this.parent=a;this.Ia=a.Ia;this.Oa=null;this.id=sb++;this.name=b;this.mode=c;this.Ba={};this.Ca={};this.rdev=d}
|
||||
Object.defineProperties(Ab.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Ob();tb=Array(4096);Hb(M,"/");O("/tmp");O("/home");O("/home/web_user");
|
||||
(function(){O("/dev");gb(259,{read:function(){return 0},write:function(d,e,g,h){return h}});Jb("/dev/null",259);fb(1280,ib);fb(1536,jb);Jb("/dev/tty",1280);Jb("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(ea)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){x("random_device")});Rb("random",b);Rb("urandom",b);O("/dev/shm");
|
||||
O("/dev/shm/tmp")})();O("/proc");O("/proc/self");O("/proc/self/fd");Hb({Ia:function(){var a=lb("/proc/self","fd",16895,73);a.Ba={lookup:function(b,c){var d=rb[+c];if(!d)throw new L(8);b={parent:null,Ia:{bb:"fake"},Ba:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");dc=f.InternalError=cc("InternalError");for(var Cc=Array(256),Dc=0;256>Dc;++Dc)Cc[Dc]=String.fromCharCode(Dc);hc=Cc;ic=f.BindingError=cc("BindingError");
|
||||
f.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};f.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};tc=f.UnboundTypeError=cc("UnboundTypeError");
|
||||
var Nc={O:function(){},u:function(a,b,c){Tb=c;try{var d=Vb(a);switch(b){case 0:var e=Ub();return 0>e?-28:Lb(d.path,d.flags,0,e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=Ub(),d.flags|=e,0;case 12:return e=Ub(),E[e+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return F[Ec()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Ka}},H:function(a,b,c){Tb=c;try{var d=Vb(a);switch(b){case 21509:case 21505:return d.tty?0:-59;
|
||||
case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return d.tty?0:-59;case 21519:if(!d.tty)return-59;var e=Ub();return F[e>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=e=Ub();if(!d.Ca.nb)throw new L(59);return d.Ca.nb(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:x("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Ka}},I:function(a,b,c){Tb=c;try{var d=a?B(C,a,void 0):"",e=Ub();return Lb(d,b,e).fd}catch(g){return"undefined"!==
|
||||
typeof Q&&g instanceof L||x(g),-g.Ka}},A:function(a){var b=Wb[a];delete Wb[a];var c=b.qb,d=b.rb,e=b.Xa,g=e.map(function(h){return h.lb}).concat(e.map(function(h){return h.vb}));ec([a],g,function(h){var k={};e.forEach(function(l,n){var p=h[n],t=l.jb,u=l.kb,w=h[n+e.length],q=l.ub,D=l.wb;k[l.hb]={read:function(y){return p.fromWireType(t(u,y))},write:function(y,P){var qa=[];q(D,y,w.toWireType(qa,P));Xb(qa)}}});return[{name:b.name,fromWireType:function(l){var n={},p;for(p in k)n[p]=k[p].read(l);d(l);return n},
|
||||
toWireType:function(l,n){for(var p in k)if(!(p in n))throw new TypeError('Missing field: "'+p+'"');var t=c();for(p in k)k[p].write(t,n[p]);null!==l&&l.push(d,t);return t},argPackAdvance:8,readValueFromPointer:Yb,Ha:d}]})},K:function(a,b,c,d,e){var g=fc(c);b=T(b);S(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:e},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var k=H;else if(2===c)k=E;else if(4===c)k=F;else throw new TypeError("Unknown boolean type size: "+
|
||||
b);return this.fromWireType(k[h>>g])},Ha:null})},J:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var d=V[c].value;kc(c);return d},toWireType:function(c,d){return lc(d)},argPackAdvance:8,readValueFromPointer:Yb,Ha:null})},w:function(a,b,c){c=fc(c);b=T(b);S(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){if("number"!==typeof e&&"boolean"!==typeof e)throw new TypeError('Cannot convert "'+mc(e)+'" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:nc(b,c),
|
||||
Ha:null})},z:function(a,b,c,d,e,g){var h=rc(b,c);a=T(a);e=sc(d,e);qc(a,function(){wc("Cannot call "+a+" due to unbound types",h)},b-1);ec([],h,function(k){var l=[k[0],null].concat(k.slice(1)),n=k=a,p=e,t=l.length;2>t&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var u=null!==l[1]&&!1,w=!1,q=1;q<l.length;++q)if(null!==l[q]&&void 0===l[q].Ha){w=!0;break}var D="void"!==l[0].name,y="",P="";for(q=0;q<t-2;++q)y+=(0!==q?", ":"")+"arg"+q,P+=(0!==q?", ":"")+"arg"+
|
||||
q+"Wired";n="return function "+ac(n)+"("+y+") {\nif (arguments.length !== "+(t-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+(t-2)+" args!');\n}\n";w&&(n+="var destructors = [];\n");var qa=w?"destructors":"null";y="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[U,p,g,Xb,l[0],l[1]];u&&(n+="var thisWired = classParam.toWireType("+qa+", this);\n");for(q=0;q<t-2;++q)n+="var arg"+q+"Wired = argType"+q+".toWireType("+
|
||||
qa+", arg"+q+"); // "+l[q+2].name+"\n",y.push("argType"+q),p.push(l[q+2]);u&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(D?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";if(w)n+="runDestructors(destructors);\n";else for(q=u?1:2;q<l.length;++q)t=1===q?"thisWired":"arg"+(q-2)+"Wired",null!==l[q].Ha&&(n+=t+"_dtor("+t+"); // "+l[q].name+"\n",y.push(t+"_dtor"),p.push(l[q].Ha));D&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");y.push(n+"}\n");l=oc(y).apply(null,p);q=b-1;if(!f.hasOwnProperty(k))throw new dc("Replacing nonexistant public symbol");
|
||||
void 0!==f[k].Fa&&void 0!==q?f[k].Fa[q]=l:(f[k]=l,f[k].fb=q);return[]})},i:function(a,b,c,d,e){function g(n){return n}b=T(b);-1===e&&(e=4294967295);var h=fc(c);if(0===d){var k=32-8*c;g=function(n){return n<<k>>>k}}var l=-1!=b.indexOf("unsigned");S(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+mc(p)+'" to '+this.name);if(p<d||p>e)throw new TypeError('Passing a number "'+mc(p)+'" from JS side to C/C++ side to an argument of type "'+
|
||||
b+'", which is outside the valid range ['+d+", "+e+"]!");return l?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:xc(b,h,0!==d),Ha:null})},e:function(a,b,c){function d(g){g>>=2;var h=I;return new e(G,h[g+1],h[g])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{mb:!0})},x:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(d){var e=I[d>>2];
|
||||
if(c)for(var g=d+4,h=0;h<=e;++h){var k=d+4+h;if(h==e||0==C[k]){g=g?B(C,g,k-g):"";if(void 0===l)var l=g;else l+=String.fromCharCode(0),l+=g;g=k+1}}else{l=Array(e);for(h=0;h<e;++h)l[h]=String.fromCharCode(C[d+4+h]);l=l.join("")}W(d);return l},toWireType:function(d,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var g="string"===typeof e;g||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int8Array||U("Cannot pass non-string to std::string");var h=(c&&g?function(){return ta(e)}:
|
||||
function(){return e.length})(),k=ob(4+h+1);I[k>>2]=h;if(c&&g)sa(e,C,k+4,h+1);else if(g)for(g=0;g<h;++g){var l=e.charCodeAt(g);255<l&&(W(k),U("String has UTF-16 code units that do not fit in 8 bits"));C[k+4+g]=l}else for(g=0;g<h;++g)C[k+4+g]=e[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:Yb,Ha:function(d){W(d)}})},q:function(a,b,c){c=T(c);if(2===b){var d=va;var e=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,e=Aa,g=Ba,h=function(){return I},k=2);S(a,
|
||||
{name:c,fromWireType:function(l){for(var n=I[l>>2],p=h(),t,u=l+4,w=0;w<=n;++w){var q=l+4+w*b;if(w==n||0==p[q>>k])u=d(u,q-u),void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),u=q+b}W(l);return t},toWireType:function(l,n){"string"!==typeof n&&U("Cannot pass non-string to C++ string type "+c);var p=g(n),t=ob(4+p+b);I[t>>2]=p>>k;e(n,t+4,p+b);null!==l&&l.push(W,t);return t},argPackAdvance:8,readValueFromPointer:Yb,Ha:function(l){W(l)}})},C:function(a,b,c,d,e,g){Wb[a]={name:T(b),qb:sc(c,d),rb:sc(e,g),Xa:[]}},
|
||||
j:function(a,b,c,d,e,g,h,k,l,n){Wb[a].Xa.push({hb:T(b),lb:c,jb:sc(d,e),kb:g,vb:h,ub:sc(k,l),wb:n})},L:function(a,b){b=T(b);S(a,{Bb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},n:kc,N:function(a){if(0===a)return lc(zc());var b=yc[a];a=void 0===b?T(a):b;return lc(zc()[a])},y:function(a){4<a&&(V[a].Ta+=1)},E:function(a,b,c,d){a||U("Cannot use deleted val. handle = "+a);a=V[a].value;var e=Bc[b];if(!e){e="";for(var g=0;g<b;++g)e+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+
|
||||
b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";e=(new Function("requireRegisteredType","Module","__emval_register",h+("var obj = new constructor("+e+");\nreturn __emval_register(obj);\n}\n")))(Ac,f,lc);Bc[b]=e}return e(a,c,d)},g:function(){x()},d:function(a,b){X(a,b||1);throw"longjmp";
|
||||
},F:function(a,b,c){C.copyWithin(a,b,b+c)},l:function(a){a>>>=0;var b=C.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{A.grow(Math.min(2147483648,d)-G.byteLength+65535>>>16);Ea(A.buffer);var e=1;break a}catch(g){}e=void 0}if(e)return!0}return!1},v:function(a){try{var b=Vb(a);if(null===b.fd)throw new L(8);b.Qa&&(b.Qa=null);try{b.Ca.close&&b.Ca.close(b)}catch(c){throw c;}finally{rb[b.fd]=
|
||||
null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Q&&c instanceof L||x(c),c.Ka}},G:function(a,b,c,d){try{a:{for(var e=Vb(a),g=a=0;g<c;g++){var h=F[b+(8*g+4)>>2],k=e,l=F[b+8*g>>2],n=h,p=void 0,t=H;if(0>n||0>p)throw new L(28);if(null===k.fd)throw new L(8);if(1===(k.flags&2097155))throw new L(8);if(16384===(k.node.mode&61440))throw new L(31);if(!k.Ca.read)throw new L(28);var u="undefined"!==typeof p;if(!u)p=k.position;else if(!k.seekable)throw new L(70);var w=k.Ca.read(k,t,l,n,p);u||(k.position+=
|
||||
w);var q=w;if(0>q){var D=-1;break a}a+=q;if(q<h)break}D=a}F[d>>2]=D;return 0}catch(y){return"undefined"!==typeof Q&&y instanceof L||x(y),y.Ka}},B:function(a,b,c,d,e){try{var g=Vb(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Nb(g,a,d);Ya=[g.position>>>0,(Xa=g.position,1<=+Ma(Xa)?0<Xa?(Pa(+Oa(Xa/4294967296),4294967295)|0)>>>0:~~+Na((Xa-+(~~Xa>>>0))/4294967296)>>>0:0)];F[e>>2]=Ya[0];F[e+4>>2]=Ya[1];g.Qa&&0===a&&0===d&&(g.Qa=null);return 0}catch(h){return"undefined"!==
|
||||
typeof Q&&h instanceof L||x(h),h.Ka}},t:function(a,b,c,d){try{a:{for(var e=Vb(a),g=a=0;g<c;g++){var h=e,k=F[b+8*g>>2],l=F[b+(8*g+4)>>2],n=void 0,p=H;if(0>l||0>n)throw new L(28);if(null===h.fd)throw new L(8);if(0===(h.flags&2097155))throw new L(8);if(16384===(h.node.mode&61440))throw new L(31);if(!h.Ca.write)throw new L(28);h.seekable&&h.flags&1024&&Nb(h,0,2);var t="undefined"!==typeof n;if(!t)n=h.position;else if(!h.seekable)throw new L(70);var u=h.Ca.write(h,p,k,l,n,void 0);t||(h.position+=u);try{if(h.path&&
|
||||
vb.onWriteToFile)vb.onWriteToFile(h.path)}catch(D){z("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+D.message)}var w=u;if(0>w){var q=-1;break a}a+=w}q=a}F[d>>2]=q;return 0}catch(D){return"undefined"!==typeof Q&&D instanceof L||x(D),D.Ka}},b:function(){return ma|0},s:Fc,D:Gc,r:Hc,m:Ic,p:Jc,f:Kc,c:Lc,o:Mc,memory:A,k:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},h:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},a:function(a){ma=a|0},table:oa,M:function(a){var b=Date.now()/
|
||||
1E3|0;a&&(F[a>>2]=b);return b}};
|
||||
(function(){function a(e){f.asm=e.exports;J--;f.monitorRunDependencies&&f.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(e=Ra,Ra=null,e()))}function b(e){a(e.instance)}function c(e){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(e,function(g){z("failed to asynchronously prepare wasm: "+g);x(g)})}var d={a:Nc};J++;f.monitorRunDependencies&&f.monitorRunDependencies(J);if(f.instantiateWasm)try{return f.instantiateWasm(d,a)}catch(e){return z("Module.instantiateWasm callback failed with error: "+
|
||||
e),!1}(function(){if(na||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(g){z("wasm streaming compile failed: "+g);z("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var Za=f.___wasm_call_ctors=function(){return(Za=f.___wasm_call_ctors=f.asm.P).apply(null,arguments)},ob=f._malloc=function(){return(ob=f._malloc=f.asm.Q).apply(null,arguments)},W=f._free=function(){return(W=f._free=f.asm.R).apply(null,arguments)},vc=f.___getTypeName=function(){return(vc=f.___getTypeName=f.asm.S).apply(null,arguments)};f.___embind_register_native_and_builtin_types=function(){return(f.___embind_register_native_and_builtin_types=f.asm.T).apply(null,arguments)};
|
||||
var Ec=f.___errno_location=function(){return(Ec=f.___errno_location=f.asm.U).apply(null,arguments)},X=f._setThrew=function(){return(X=f._setThrew=f.asm.V).apply(null,arguments)},Y=f.stackSave=function(){return(Y=f.stackSave=f.asm.W).apply(null,arguments)},Z=f.stackRestore=function(){return(Z=f.stackRestore=f.asm.X).apply(null,arguments)},Oc=f.dynCall_vi=function(){return(Oc=f.dynCall_vi=f.asm.Y).apply(null,arguments)},Pc=f.dynCall_vii=function(){return(Pc=f.dynCall_vii=f.asm.Z).apply(null,arguments)};
|
||||
f.dynCall_viii=function(){return(f.dynCall_viii=f.asm._).apply(null,arguments)};
|
||||
var Qc=f.dynCall_viiii=function(){return(Qc=f.dynCall_viiii=f.asm.$).apply(null,arguments)},Rc=f.dynCall_viiiiiiiiii=function(){return(Rc=f.dynCall_viiiiiiiiii=f.asm.aa).apply(null,arguments)},Sc=f.dynCall_iii=function(){return(Sc=f.dynCall_iii=f.asm.ba).apply(null,arguments)},Tc=f.dynCall_iiii=function(){return(Tc=f.dynCall_iiii=f.asm.ca).apply(null,arguments)},Uc=f.dynCall_iiiii=function(){return(Uc=f.dynCall_iiiii=f.asm.da).apply(null,arguments)},Vc=f.dynCall_iiiiiiiii=function(){return(Vc=f.dynCall_iiiiiiiii=
|
||||
f.asm.ea).apply(null,arguments)};f.dynCall_i=function(){return(f.dynCall_i=f.asm.fa).apply(null,arguments)};f.dynCall_iiiiii=function(){return(f.dynCall_iiiiii=f.asm.ga).apply(null,arguments)};f.dynCall_viiiii=function(){return(f.dynCall_viiiii=f.asm.ha).apply(null,arguments)};f.dynCall_iiiiiii=function(){return(f.dynCall_iiiiiii=f.asm.ia).apply(null,arguments)};f.dynCall_viiiiii=function(){return(f.dynCall_viiiiii=f.asm.ja).apply(null,arguments)};
|
||||
f.dynCall_viiiiiii=function(){return(f.dynCall_viiiiiii=f.asm.ka).apply(null,arguments)};f.dynCall_viiiiiiiiiii=function(){return(f.dynCall_viiiiiiiiiii=f.asm.la).apply(null,arguments)};f.dynCall_iiiiiiii=function(){return(f.dynCall_iiiiiiii=f.asm.ma).apply(null,arguments)};f.dynCall_iiiiiiiiii=function(){return(f.dynCall_iiiiiiiiii=f.asm.na).apply(null,arguments)};f.dynCall_iiiiiiiiiiii=function(){return(f.dynCall_iiiiiiiiiiii=f.asm.oa).apply(null,arguments)};
|
||||
f.dynCall_viiiiiiii=function(){return(f.dynCall_viiiiiiii=f.asm.pa).apply(null,arguments)};f.dynCall_jiiiiiiiii=function(){return(f.dynCall_jiiiiiiiii=f.asm.qa).apply(null,arguments)};f.dynCall_jiji=function(){return(f.dynCall_jiji=f.asm.ra).apply(null,arguments)};f.dynCall_ii=function(){return(f.dynCall_ii=f.asm.sa).apply(null,arguments)};f.dynCall_iidiiii=function(){return(f.dynCall_iidiiii=f.asm.ta).apply(null,arguments)};
|
||||
f.dynCall_viiiiiiiiiiiii=function(){return(f.dynCall_viiiiiiiiiiiii=f.asm.ua).apply(null,arguments)};f.dynCall_jiiiiiiii=function(){return(f.dynCall_jiiiiiiii=f.asm.va).apply(null,arguments)};f.dynCall_ff=function(){return(f.dynCall_ff=f.asm.wa).apply(null,arguments)};f.dynCall_jiiiiii=function(){return(f.dynCall_jiiiiii=f.asm.xa).apply(null,arguments)};f.dynCall_jiiiii=function(){return(f.dynCall_jiiiii=f.asm.ya).apply(null,arguments)};
|
||||
f.dynCall_iiijii=function(){return(f.dynCall_iiijii=f.asm.za).apply(null,arguments)};function Jc(a,b){var c=Y();try{Oc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Lc(a,b,c,d,e){var g=Y();try{Qc(a,b,c,d,e)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Kc(a,b,c){var d=Y();try{Pc(a,b,c)}catch(e){Z(d);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}
|
||||
function Ic(a,b,c,d,e,g,h,k,l){var n=Y();try{return Vc(a,b,c,d,e,g,h,k,l)}catch(p){Z(n);if(p!==p+0&&"longjmp"!==p)throw p;X(1,0)}}function Fc(a,b,c){var d=Y();try{return Sc(a,b,c)}catch(e){Z(d);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}function Hc(a,b,c,d,e){var g=Y();try{return Uc(a,b,c,d,e)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Gc(a,b,c,d){var e=Y();try{return Tc(a,b,c,d)}catch(g){Z(e);if(g!==g+0&&"longjmp"!==g)throw g;X(1,0)}}
|
||||
function Mc(a,b,c,d,e,g,h,k,l,n,p){var t=Y();try{Rc(a,b,c,d,e,g,h,k,l,n,p)}catch(u){Z(t);if(u!==u+0&&"longjmp"!==u)throw u;X(1,0)}}var Wc;Ra=function Xc(){Wc||Yc();Wc||(Ra=Xc)};
|
||||
function Yc(){function a(){if(!Wc&&(Wc=!0,f.calledRun=!0,!pa)){f.noFSInit||Pb||(Pb=!0,Ob(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Rb("stdin",f.stdin):Kb("/dev/tty","/dev/stdin"),f.stdout?Rb("stdout",null,f.stdout):Kb("/dev/tty","/dev/stdout"),f.stderr?Rb("stderr",null,f.stderr):Kb("/dev/tty1","/dev/stderr"),Lb("/dev/stdin","r"),Lb("/dev/stdout","w"),Lb("/dev/stderr","w"));Ga(Ia);ub=!1;Ga(Ja);aa(f);if(f.onRuntimeInitialized)f.onRuntimeInitialized();if(f.postRun)for("function"==
|
||||
typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;){var b=f.postRun.shift();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)La();Ga(Ha);0<J||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}f.run=Yc;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();noExitRuntime=!0;Yc();
|
||||
|
||||
|
||||
return avif_enc.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = avif_enc;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return avif_enc; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["avif_enc"] = avif_enc;
|
||||
|
BIN
codecs/avif/enc/avif_enc.wasm
Normal file
BIN
codecs/avif/enc/avif_enc.wasm
Normal file
Binary file not shown.
155
codecs/avif/enc/avif_enc_mt.js
Normal file
155
codecs/avif/enc/avif_enc_mt.js
Normal file
@ -0,0 +1,155 @@
|
||||
|
||||
var avif_enc_mt = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(avif_enc_mt) {
|
||||
avif_enc_mt = avif_enc_mt || {};
|
||||
|
||||
|
||||
function e(){m.buffer!=n&&p(m.buffer);return aa}function t(){m.buffer!=n&&p(m.buffer);return ba}function ca(){m.buffer!=n&&p(m.buffer);return da}function ea(){m.buffer!=n&&p(m.buffer);return fa}function w(){m.buffer!=n&&p(m.buffer);return ha}function x(){m.buffer!=n&&p(m.buffer);return ia}function ja(){m.buffer!=n&&p(m.buffer);return ka}function la(){m.buffer!=n&&p(m.buffer);return ma}var z;z||(z=typeof avif_enc_mt !== 'undefined' ? avif_enc_mt : {});var na,oa;
|
||||
z.ready=new Promise(function(a,b){na=a;oa=b});var pa={},A;for(A in z)z.hasOwnProperty(A)&&(pa[A]=z[A]);var qa=!1,D=!1,F=!1,ra=!1;qa="object"===typeof window;D="function"===typeof importScripts;F="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ra=!qa&&!F&&!D;var G=z.ENVIRONMENT_IS_PTHREAD||!1;G&&(n=z.buffer,sa=z.DYNAMIC_BASE,ta=z.DYNAMICTOP_PTR);var H="";function ua(a){return z.locateFile?z.locateFile(a,H):H+a}var va,wa,I,xa;
|
||||
if(F){H=D?require("path").dirname(H)+"/":__dirname+"/";va=function(a,b){I||(I=require("fs"));xa||(xa=require("path"));a=xa.normalize(a);return I.readFileSync(a,b?null:"utf8")};wa=function(a){a=va(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a};1<process.argv.length&&process.argv[1].replace(/\\/g,"/");process.argv.slice(2);process.on("uncaughtException",function(a){if(!(a instanceof ya))throw a;});process.on("unhandledRejection",J);z.inspect=function(){return"[Emscripten Module object]"};
|
||||
var za;try{za=require("worker_threads")}catch(a){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),a;}global.Worker=za.Worker}else if(ra)"undefined"!=typeof read&&(va=function(a){return read(a)}),wa=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,
|
||||
console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(qa||D)D?H=self.location.href:document.currentScript&&(H=document.currentScript.src),_scriptDir&&(H=_scriptDir),0!==H.indexOf("blob:")?H=H.substr(0,H.lastIndexOf("/")+1):H="",F?(va=function(a,b){I||(I=require("fs"));xa||(xa=require("path"));a=xa.normalize(a);return I.readFileSync(a,b?null:"utf8")},wa=function(a){a=va(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a}):(va=function(a){var b=new XMLHttpRequest;
|
||||
b.open("GET",a,!1);b.send(null);return b.responseText},D&&(wa=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}));F&&"undefined"===typeof performance&&(global.performance=require("perf_hooks").performance);var Aa=z.print||console.log.bind(console),K=z.printErr||console.warn.bind(console);for(A in pa)pa.hasOwnProperty(A)&&(z[A]=pa[A]);pa=null;var Ca,Da=0,Ea;z.wasmBinary&&(Ea=z.wasmBinary);var noExitRuntime;
|
||||
z.noExitRuntime&&(noExitRuntime=z.noExitRuntime);"object"!==typeof WebAssembly&&J("no native wasm support detected");var m,Fa=new WebAssembly.Table({initial:874,maximum:874,element:"anyfunc"}),Ga,threadInfoStruct=0,selfThreadId=0,Ha=!1;function assert(a,b){a||J("Assertion failed: "+b)}
|
||||
function Ia(a,b,c){c=b+c;for(var d="";!(b>=c);){var f=a[b++];if(!f)break;if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var h=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|h:(f&7)<<18|g<<12|h<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}function Ja(a,b){return a?Ia(t(),a,b):""}
|
||||
function Ka(a,b,c,d){if(!(0<d))return 0;var f=c;d=c+d-1;for(var g=0;g<a.length;++g){var h=a.charCodeAt(g);if(55296<=h&&57343>=h){var l=a.charCodeAt(++g);h=65536+((h&1023)<<10)|l&1023}if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(c+3>=d)break;b[c++]=240|h>>18;b[c++]=128|h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-f}function La(a,b,c){Ka(a,t(),b,c)}
|
||||
function Ma(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}function Na(a,b){for(var c=0,d="";;){var f=ca()[a+2*c>>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}function Oa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f){var g=a.charCodeAt(f);ca()[b>>1]=g;b+=2}ca()[b>>1]=0;return b-d}
|
||||
function Pa(a){return 2*a.length}function Qa(a,b){for(var c=0,d="";!(c>=b/4);){var f=w()[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023)):d+=String.fromCharCode(f)}return d}function Ra(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}w()[b>>2]=g;b+=4;if(b+4>c)break}w()[b>>2]=0;return b-d}
|
||||
function Sa(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var n,aa,ba,da,fa,ha,ia,ka,ma;function p(a){n=a;z.HEAP8=aa=new Int8Array(a);z.HEAP16=da=new Int16Array(a);z.HEAP32=ha=new Int32Array(a);z.HEAPU8=ba=new Uint8Array(a);z.HEAPU16=fa=new Uint16Array(a);z.HEAPU32=ia=new Uint32Array(a);z.HEAPF32=ka=new Float32Array(a);z.HEAPF64=ma=new Float64Array(a)}var sa=6123216,ta=879408,Ta=z.INITIAL_MEMORY||16777216;
|
||||
if(G)m=z.wasmMemory,n=z.buffer;else if(z.wasmMemory)m=z.wasmMemory;else if(m=new WebAssembly.Memory({initial:Ta/65536,maximum:32768,shared:!0}),!(m.buffer instanceof SharedArrayBuffer))throw K("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),F&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),
|
||||
Error("bad memory");m&&(n=m.buffer);Ta=n.byteLength;p(n);G||(w()[ta>>2]=sa);function Ua(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(z);else{var c=b.yc;"number"===typeof c?void 0===b.Mb?z.dynCall_v(c):z.dynCall_vi(c,b.Mb):c(void 0===b.Mb?null:b.Mb)}}}var Va=[],Wa=[],Xa=[],Ya=[];function Za(){var a=z.preRun.shift();Va.unshift(a)}var $a=Math.abs,ab=Math.ceil,bb=Math.floor,cb=Math.min,db=0,eb=null,fb=null;z.preloadedImages={};z.preloadedAudios={};
|
||||
function J(a){if(z.onAbort)z.onAbort(a);G&&console.error("Pthread aborting at "+Error().stack);K(a);Ha=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");oa(a);throw a;}function gb(a){var b=hb;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function ib(){return gb("data:application/octet-stream;base64,")}var hb="avif_enc_mt.wasm";ib()||(hb=ua(hb));
|
||||
function jb(){try{if(Ea)return new Uint8Array(Ea);if(wa)return wa(hb);throw"both async and sync fetching of the wasm failed";}catch(a){J(a)}}function kb(){return Ea||!qa&&!D||"function"!==typeof fetch||gb("file://")?new Promise(function(a){a(jb())}):fetch(hb,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+hb+"'";return a.arrayBuffer()}).catch(function(){return jb()})}
|
||||
var lb,mb,ob={575937:function(a,b){setTimeout(function(){nb(a,b)},0)},576015:function(){throw"Canceled!";}};G||Wa.push({yc:function(){pb()}});var qb=0,rb=0,sb=0;function tb(a,b,c){qb=a|0;sb=b|0;rb=c|0}z.registerPthreadPtr=tb;
|
||||
function ub(a,b){if(0>=a||a>e().length||a&1||0>b)return-28;if(0==b)return 0;2147483647<=b&&(b=Infinity);var c=Atomics.load(w(),220080),d=0;if(c==a&&Atomics.compareExchange(w(),220080,c,0)==c&&(--b,d=1,0>=b))return 1;a=Atomics.notify(w(),a>>2,b);if(0<=a)return a+d;throw"Atomics.notify returned an unexpected value "+a;}z._emscripten_futex_wake=ub;
|
||||
function vb(a){if(G)throw"Internal Error! cleanupThread() can only ever be called from main application thread!";if(!a)throw"Internal Error! Null pthread_ptr in cleanupThread!";w()[a+12>>2]=0;(a=L.Ab[a])&&L.Tb(a.worker)}
|
||||
var L={bd:1,nd:{rc:0,sc:0},xb:[],Fb:[],Gc:function(){tb(L.vb,!D,1);wb(L.vb)},Fc:function(){for(var a=navigator.hardwareConcurrency,b=0;b<a;++b)L.cc();L.vb=879568;for(b=0;58>b;++b)x()[L.vb/4+b]=0;w()[L.vb+12>>2]=L.vb;a=L.vb+156;w()[a>>2]=a;for(b=0;128>b;++b)x()[219952+b]=0;Atomics.store(x(),L.vb+104>>2,879808);Atomics.store(x(),L.vb+40>>2,L.vb);Atomics.store(x(),L.vb+44>>2,42)},Hc:function(){L.receiveObjectTransfer=L.Qc;L.setThreadStatus=L.Tc;L.threadCancel=L.Yc;L.threadExit=L.Zc},Ab:{},Ub:[],Tc:function(){},
|
||||
qc:function(){for(;0<L.Ub.length;)L.Ub.pop()();G&&threadInfoStruct&&xb()},Zc:function(a){var b=qb|0;b&&(Atomics.store(x(),b+4>>2,a),Atomics.store(x(),b+0>>2,1),Atomics.store(x(),b+60>>2,1),Atomics.store(x(),b+64>>2,0),L.qc(),ub(b+0,2147483647),tb(0,0,0),threadInfoStruct=0,G&&postMessage({cmd:"exit"}))},Yc:function(){L.qc();Atomics.store(x(),threadInfoStruct+4>>2,-1);Atomics.store(x(),threadInfoStruct+0>>2,1);ub(threadInfoStruct+0,2147483647);threadInfoStruct=selfThreadId=0;tb(0,0,0);postMessage({cmd:"cancelDone"})},
|
||||
vd:function(){for(var a in L.Ab){var b=L.Ab[a];b&&b.worker&&L.Tb(b.worker)}L.Ab={};for(a=0;a<L.xb.length;++a){var c=L.xb[a];c.terminate()}L.xb=[];for(a=0;a<L.Fb.length;++a)c=L.Fb[a],b=c.wb,L.Xb(b),c.terminate();L.Fb=[]},Xb:function(a){if(a){if(a.threadInfoStruct){var b=w()[a.threadInfoStruct+104>>2];w()[a.threadInfoStruct+104>>2]=0;M(b);M(a.threadInfoStruct)}a.threadInfoStruct=0;a.Vb&&a.Ib&&M(a.Ib);a.Ib=0;a.worker&&(a.worker.wb=null)}},Tb:function(a){delete L.Ab[a.wb.tc];L.xb.push(a);L.Fb.splice(L.Fb.indexOf(a),
|
||||
1);L.Xb(a.wb);a.wb=void 0},Qc:function(){},lc:function(a,b){a.onmessage=function(c){var d=c.data,f=d.cmd;a.wb&&(L.Wb=a.wb.threadInfoStruct);if(d.targetThread&&d.targetThread!=(qb|0)){var g=L.Ab[d.ud];g?g.worker.postMessage(c.data,d.transferList):console.error('Internal error! Worker sent a message "'+f+'" to target pthread '+d.targetThread+", but that thread no longer exists!")}else if("processQueuedMainThreadWork"===f)yb();else if("spawnThread"===f)zb(c.data);else if("cleanupThread"===f)vb(d.thread);
|
||||
else if("killThread"===f){c=d.thread;if(G)throw"Internal Error! killThread() can only ever be called from main application thread!";if(!c)throw"Internal Error! Null pthread_ptr in killThread!";w()[c+12>>2]=0;c=L.Ab[c];c.worker.terminate();L.Xb(c);L.Fb.splice(L.Fb.indexOf(c.worker),1);c.worker.wb=void 0}else if("cancelThread"===f){c=d.thread;if(G)throw"Internal Error! cancelThread() can only ever be called from main application thread!";if(!c)throw"Internal Error! Null pthread_ptr in cancelThread!";
|
||||
L.Ab[c].worker.postMessage({cmd:"cancel"})}else"loaded"===f?(a.loaded=!0,b&&b(a),a.Nb&&(a.Nb(),delete a.Nb)):"print"===f?Aa("Thread "+d.threadId+": "+d.text):"printErr"===f?K("Thread "+d.threadId+": "+d.text):"alert"===f?alert("Thread "+d.threadId+": "+d.text):"exit"===f?a.wb&&Atomics.load(x(),a.wb.tc+68>>2)&&L.Tb(a):"cancelDone"===f?L.Tb(a):"objectTransfer"!==f&&("setimmediate"===c.data.target?a.postMessage(c.data):K("worker sent an unknown command "+f));L.Wb=void 0};a.onerror=function(c){K("pthread sent an error! "+
|
||||
c.filename+":"+c.lineno+": "+c.message)};F&&(a.on("message",function(c){a.onmessage({data:c})}),a.on("error",function(c){a.onerror(c)}),a.on("exit",function(){console.log("worker exited - TODO: update the worker queue?")}));a.postMessage({cmd:"load",urlOrBlob:z.mainScriptUrlOrBlob||_scriptDir,wasmMemory:m,wasmModule:Ga,DYNAMIC_BASE:sa,DYNAMICTOP_PTR:ta})},cc:function(){var a=ua("avif_enc_mt.worker.js");L.xb.push(new Worker(a))},zc:function(){0==L.xb.length&&(L.cc(),L.lc(L.xb[0]));return 0<L.xb.length?
|
||||
L.xb.pop():null},dd:function(a){for(a=performance.now()+a;performance.now()<a;);}};z.establishStackSpace=function(a){N(a)};z.getNoExitRuntime=function(){return noExitRuntime};var Ab;F?Ab=function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:G?Ab=function(){return performance.now()-z.__performance_now_clock_drift}:"undefined"!==typeof dateNow?Ab=dateNow:Ab=function(){return performance.now()};function Bb(a,b){L.Ub.push(function(){Cb(a,b)})}
|
||||
function Db(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function Eb(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=Db(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
|
||||
function Fb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function Gb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
|
||||
function Hb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=Db(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var Ib=[];function Jb(a,b){Ib[a]={input:[],output:[],Jb:b};Kb(a,Lb)}
|
||||
var Lb={open:function(a){var b=Ib[a.node.rdev];if(!b)throw new P(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Jb.flush(a.tty)},flush:function(a){a.tty.Jb.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Jb.kc)throw new P(60);for(var f=0,g=0;g<d;g++){try{var h=a.tty.Jb.kc(a.tty)}catch(l){throw new P(29);}if(void 0===h&&0===f)throw new P(6);if(null===h||void 0===h)break;f++;b[c+g]=h}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.Jb.Zb)throw new P(60);
|
||||
try{for(var f=0;f<d;f++)a.tty.Jb.Zb(a.tty,b[c+f])}catch(g){throw new P(29);}d&&(a.node.timestamp=Date.now());return f}},Mb={kc:function(a){if(!a.input.length){var b=null;if(F){var c=Buffer.Pc?Buffer.Pc(256):new Buffer(256),d=0;try{d=I.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(-1!=f.toString().indexOf("EOF"))d=0;else throw f;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
|
||||
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;c=Array(Ma(b)+1);b=Ka(b,c,0,c.length);c.length=b;a.input=c}return a.input.shift()},Zb:function(a,b){null===b||10===b?(Aa(Ia(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(Aa(Ia(a.output,0)),a.output=[])}},Nb={Zb:function(a,b){null===b||10===b?(K(Ia(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(K(Ia(a.output,0)),a.output=[])}},
|
||||
Q={yb:null,Db:function(){return Q.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new P(63);Q.yb||(Q.yb={dir:{node:{Eb:Q.sb.Eb,Bb:Q.sb.Bb,lookup:Q.sb.lookup,Rb:Q.sb.Rb,rename:Q.sb.rename,unlink:Q.sb.unlink,rmdir:Q.sb.rmdir,readdir:Q.sb.readdir,symlink:Q.sb.symlink},stream:{Hb:Q.tb.Hb}},file:{node:{Eb:Q.sb.Eb,Bb:Q.sb.Bb},stream:{Hb:Q.tb.Hb,read:Q.tb.read,write:Q.tb.write,bc:Q.tb.bc,mc:Q.tb.mc,oc:Q.tb.oc}},link:{node:{Eb:Q.sb.Eb,Bb:Q.sb.Bb,readlink:Q.sb.readlink},
|
||||
stream:{}},dc:{node:{Eb:Q.sb.Eb,Bb:Q.sb.Bb},stream:Ob}});c=Pb(a,b,c,d);16384===(c.mode&61440)?(c.sb=Q.yb.dir.node,c.tb=Q.yb.dir.stream,c.rb={}):32768===(c.mode&61440)?(c.sb=Q.yb.file.node,c.tb=Q.yb.file.stream,c.ub=0,c.rb=null):40960===(c.mode&61440)?(c.sb=Q.yb.link.node,c.tb=Q.yb.link.stream):8192===(c.mode&61440)&&(c.sb=Q.yb.dc.node,c.tb=Q.yb.dc.stream);c.timestamp=Date.now();a&&(a.rb[b]=c);return c},jd:function(a){if(a.rb&&a.rb.subarray){for(var b=[],c=0;c<a.ub;++c)b.push(a.rb[c]);return b}return a.rb},
|
||||
kd:function(a){return a.rb?a.rb.subarray?a.rb.subarray(0,a.ub):new Uint8Array(a.rb):new Uint8Array(0)},fc:function(a,b){var c=a.rb?a.rb.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.rb,a.rb=new Uint8Array(b),0<a.ub&&a.rb.set(c.subarray(0,a.ub),0))},Rc:function(a,b){if(a.ub!=b)if(0==b)a.rb=null,a.ub=0;else{if(!a.rb||a.rb.subarray){var c=a.rb;a.rb=new Uint8Array(b);c&&a.rb.set(c.subarray(0,Math.min(b,a.ub)))}else if(a.rb||(a.rb=[]),a.rb.length>b)a.rb.length=b;
|
||||
else for(;a.rb.length<b;)a.rb.push(0);a.ub=b}},sb:{Eb:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.ub:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.vc=4096;b.blocks=Math.ceil(b.size/b.vc);return b},Bb:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
|
||||
(a.timestamp=b.timestamp);void 0!==b.size&&Q.Rc(a,b.size)},lookup:function(){throw Qb[44];},Rb:function(a,b,c,d){return Q.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=Rb(b,c)}catch(g){}if(d)for(var f in d.rb)throw new P(55);}delete a.parent.rb[a.name];a.name=c;b.rb[c]=a;a.parent=b},unlink:function(a,b){delete a.rb[b]},rmdir:function(a,b){var c=Rb(a,b),d;for(d in c.rb)throw new P(55);delete a.rb[b]},readdir:function(a){var b=[".",".."],c;for(c in a.rb)a.rb.hasOwnProperty(c)&&
|
||||
b.push(c);return b},symlink:function(a,b,c){a=Q.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new P(28);return a.link}},tb:{read:function(a,b,c,d,f){var g=a.node.rb;if(f>=a.node.ub)return 0;a=Math.min(a.node.ub-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===e().buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.rb||a.rb.subarray)){if(g)return a.rb=
|
||||
b.subarray(c,c+d),a.ub=d;if(0===a.ub&&0===f)return a.rb=b.slice(c,c+d),a.ub=d;if(f+d<=a.ub)return a.rb.set(b.subarray(c,c+d),f),d}Q.fc(a,f+d);if(a.rb.subarray&&b.subarray)a.rb.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.rb[f+g]=b[c+g];a.ub=Math.max(a.ub,f+d);return d},Hb:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.ub);if(0>b)throw new P(28);return b},bc:function(a,b,c){Q.fc(a.node,b+c);a.node.ub=Math.max(a.node.ub,b+c)},mc:function(a,b,c,d,f,g){assert(0===
|
||||
b);if(32768!==(a.node.mode&61440))throw new P(43);a=a.node.rb;if(g&2||a.buffer!==n){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=R(g);c<g;)e()[b+c++]=0;c=b;if(!c)throw new P(48);e().set(a,c)}else d=!1,c=a.byteOffset;return{sd:c,cd:d}},oc:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new P(43);if(f&2)return 0;Q.tb.write(a,b,0,d,c,!1);return 0}}},Sb=null,Tb={},Ub=[],Vb=1,Wb=null,Xb=!0,Yb={},P=null,Qb={};
|
||||
function Zb(a,b){a=Hb("/",a);b=b||{};if(!a)return{path:"",node:null};var c={jc:!0,$b:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.$b)throw new P(32);a=Db(a.split("/").filter(function(h){return!!h}),!1);var f=Sb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=Rb(f,a[d]);c=Eb(c+"/"+a[d]);f.Sb&&(!g||g&&b.jc)&&(f=f.Sb.root);if(!g||b.ic)for(g=0;40960===(f.mode&61440);)if(f=$b(c),c=Hb(Fb(c),f),f=Zb(c,{$b:b.$b}).node,40<g++)throw new P(32);}return{path:c,node:f}}
|
||||
function ac(a){for(var b;;){if(a===a.parent)return a=a.Db.nc,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function bc(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%Wb.length}function Rb(a,b){var c;if(c=(c=cc(a,"x"))?c:a.sb.lookup?0:2)throw new P(c,a);for(c=Wb[bc(a.id,b)];c;c=c.Lc){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.sb.lookup(a,b)}
|
||||
function Pb(a,b,c,d){a=new dc(a,b,c,d);b=bc(a.parent.id,a.name);a.Lc=Wb[b];return Wb[b]=a}var ec={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function fc(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function cc(a,b){if(Xb)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
|
||||
function hc(a,b){try{return Rb(a,b),20}catch(c){}return cc(a,"wx")}function ic(a){var b=4096;for(a=a||0;a<=b;a++)if(!Ub[a])return a;throw new P(33);}function jc(a,b){kc||(kc=function(){},kc.prototype={});var c=new kc,d;for(d in a)c[d]=a[d];a=c;b=ic(b);a.fd=b;return Ub[b]=a}var Ob={open:function(a){a.tb=Tb[a.node.rdev].tb;a.tb.open&&a.tb.open(a)},Hb:function(){throw new P(70);}};function Kb(a,b){Tb[a]={tb:b}}
|
||||
function lc(a,b){var c="/"===b,d=!b;if(c&&Sb)throw new P(10);if(!c&&!d){var f=Zb(b,{jc:!1});b=f.path;f=f.node;if(f.Sb)throw new P(10);if(16384!==(f.mode&61440))throw new P(54);}b={type:a,qd:{},nc:b,Kc:[]};a=a.Db(b);a.Db=b;b.root=a;c?Sb=a:f&&(f.Sb=b,f.Db&&f.Db.Kc.push(b))}function mc(a,b,c){var d=Zb(a,{parent:!0}).node;a=Gb(a);if(!a||"."===a||".."===a)throw new P(28);var f=hc(d,a);if(f)throw new P(f);if(!d.sb.Rb)throw new P(63);return d.sb.Rb(d,a,b,c)}function S(a){mc(a,16895,0)}
|
||||
function nc(a,b,c){"undefined"===typeof c&&(c=b,b=438);mc(a,b|8192,c)}function oc(a,b){if(!Hb(a))throw new P(44);var c=Zb(b,{parent:!0}).node;if(!c)throw new P(44);b=Gb(b);var d=hc(c,b);if(d)throw new P(d);if(!c.sb.symlink)throw new P(63);c.sb.symlink(c,b,a)}function $b(a){a=Zb(a).node;if(!a)throw new P(44);if(!a.sb.readlink)throw new P(28);return Hb(ac(a.parent),a.sb.readlink(a))}
|
||||
function pc(a,b,c,d){if(""===a)throw new P(44);if("string"===typeof b){var f=ec[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=Eb(a);try{g=Zb(a,{ic:!(b&131072)}).node}catch(l){}}f=!1;if(b&64)if(g){if(b&128)throw new P(20);}else g=mc(a,c,0),f=!0;if(!g)throw new P(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new P(54);if(!f&&(c=g?40960===(g.mode&61440)?
|
||||
32:16384===(g.mode&61440)&&("r"!==fc(b)||b&512)?31:cc(g,fc(b)):44))throw new P(c);if(b&512){c=g;var h;"string"===typeof c?h=Zb(c,{ic:!0}).node:h=c;if(!h.sb.Bb)throw new P(63);if(16384===(h.mode&61440))throw new P(31);if(32768!==(h.mode&61440))throw new P(28);if(c=cc(h,"w"))throw new P(c);h.sb.Bb(h,{size:0,timestamp:Date.now()})}b&=-131713;d=jc({node:g,path:ac(g),flags:b,seekable:!0,position:0,tb:g.tb,ad:[],error:!1},d);d.tb.open&&d.tb.open(d);!z.logReadFiles||b&1||(qc||(qc={}),a in qc||(qc[a]=1,K("FS.trackingDelegate error on read file: "+
|
||||
a)));try{Yb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),Yb.onOpenFile(a,g))}catch(l){K("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+l.message)}return d}function rc(a,b,c){if(null===a.fd)throw new P(8);if(!a.seekable||!a.tb.Hb)throw new P(70);if(0!=c&&1!=c&&2!=c)throw new P(28);a.position=a.tb.Hb(a,b,c);a.ad=[]}
|
||||
function sc(){P||(P=function(a,b){this.node=b;this.Sc=function(c){this.Gb=c};this.Sc(a);this.message="FS error"},P.prototype=Error(),P.prototype.constructor=P,[44].forEach(function(a){Qb[a]=new P(a);Qb[a].stack="<generic error, no stack>"}))}var tc;function uc(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
|
||||
function vc(a,b,c){a=Eb("/dev/"+a);var d=uc(!!b,!!c);wc||(wc=64);var f=wc++<<8|0;Kb(f,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,l,k){for(var q=0,r=0;r<k;r++){try{var v=b()}catch(y){throw new P(29);}if(void 0===v&&0===q)throw new P(6);if(null===v||void 0===v)break;q++;h[l+r]=v}q&&(g.node.timestamp=Date.now());return q},write:function(g,h,l,k){for(var q=0;q<k;q++)try{c(h[l+q])}catch(r){throw new P(29);}k&&(g.node.timestamp=Date.now());return q}});
|
||||
nc(a,d,f)}var wc,xc={},kc,qc,yc=void 0;function zc(){yc+=4;return w()[yc-4>>2]}function Ac(a){a=Ub[a];if(!a)throw new P(8);return a}
|
||||
function Bc(a,b,c){if(G)return T(1,1,a,b,c);yc=c;try{var d=Ac(a);switch(b){case 0:var f=zc();return 0>f?-28:pc(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return f=zc(),d.flags|=f,0;case 12:return f=zc(),ca()[f+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return w()[Cc()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof xc&&g instanceof P||J(g),-g.Gb}}
|
||||
function Dc(a,b,c){if(G)return T(2,1,a,b,c);yc=c;try{var d=Ac(a);switch(b){case 21509:case 21505:return d.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return d.tty?0:-59;case 21519:if(!d.tty)return-59;var f=zc();return w()[f>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=f=zc();if(!d.tb.Ic)throw new P(59);return d.tb.Ic(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:J("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof xc&&g instanceof
|
||||
P||J(g),-g.Gb}}function Ec(a,b,c){if(G)return T(3,1,a,b,c);yc=c;try{var d=Ja(a),f=zc();return pc(d,b,f).fd}catch(g){return"undefined"!==typeof xc&&g instanceof P||J(g),-g.Gb}}var Fc={};function Gc(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Hc(a){return this.fromWireType(x()[a>>2])}var Ic={},Jc={},Kc={};function Lc(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
|
||||
function Mc(a,b){a=Lc(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Nc(a){var b=Error,c=Mc(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
|
||||
var Oc=void 0;function Pc(a,b,c){function d(l){l=c(l);if(l.length!==a.length)throw new Oc("Mismatched type converter count");for(var k=0;k<a.length;++k)U(a[k],l[k])}a.forEach(function(l){Kc[l]=b});var f=Array(b.length),g=[],h=0;b.forEach(function(l,k){Jc.hasOwnProperty(l)?f[k]=Jc[l]:(g.push(l),Ic.hasOwnProperty(l)||(Ic[l]=[]),Ic[l].push(function(){f[k]=Jc[l];++h;h===g.length&&d(f)}))});0===g.length&&d(f)}
|
||||
function Qc(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Rc=void 0;function V(a){for(var b="";t()[a];)b+=Rc[t()[a++]];return b}var Sc=void 0;function W(a){throw new Sc(a);}
|
||||
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||W('type "'+d+'" must have a positive integer typeid pointer');if(Jc.hasOwnProperty(a)){if(c.Dc)return;W("Cannot register type '"+d+"' twice")}Jc[a]=b;delete Kc[a];Ic.hasOwnProperty(a)&&(b=Ic[a],delete Ic[a],b.forEach(function(f){f()}))}var Tc=[],X=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Uc(a){4<a&&0===--X[a].ac&&(X[a]=void 0,Tc.push(a))}function Vc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Tc.length?Tc.pop():X.length;X[b]={ac:1,value:a};return b}}function Wc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function Xc(a,b){switch(b){case 2:return function(c){return this.fromWireType(ja()[c>>2])};case 3:return function(c){return this.fromWireType(la()[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Yc(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Mc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function Zc(a,b){var c=z;if(void 0===c[a].zb){var d=c[a];c[a]=function(){c[a].zb.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].zb+")!");return c[a].zb[arguments.length].apply(this,arguments)};c[a].zb=[];c[a].zb[d.uc]=d}}
|
||||
function $c(a,b,c){z.hasOwnProperty(a)?((void 0===c||void 0!==z[a].zb&&void 0!==z[a].zb[c])&&W("Cannot register public name '"+a+"' twice"),Zc(a,a),z.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),z[a].zb[c]=b):(z[a]=b,void 0!==c&&(z[a].pd=c))}function ad(a,b){for(var c=[],d=0;d<a;d++)c.push(w()[(b>>2)+d]);return c}
|
||||
function bd(a,b){a=V(a);var c=z["dynCall_"+a];for(var d=[],f=1;f<a.length;++f)d.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&W("unknown function pointer with signature "+a+": "+b);return c}var cd=void 0;function dd(a){a=ed(a);var b=V(a);M(a);return b}
|
||||
function fd(a,b){function c(g){f[g]||Jc[g]||(Kc[g]?Kc[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new cd(a+": "+d.map(dd).join([", "]));}function gd(a,b,c){switch(b){case 0:return c?function(d){return e()[d]}:function(d){return t()[d]};case 1:return c?function(d){return ca()[d>>1]}:function(d){return ea()[d>>1]};case 2:return c?function(d){return w()[d>>2]}:function(d){return x()[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var hd={};
|
||||
function id(){return"object"===typeof globalThis?globalThis:Function("return this")()}function jd(a,b){var c=Jc[a];void 0===c&&W(b+" has unknown type "+dd(a));return c}var kd={};
|
||||
function ld(){F||D||(Ca||(Ca={}),Ca["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]||(Ca["Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread"]=1,K("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")))}
|
||||
function md(a,b,c){if(0>=a||a>e().length||a&1)return-28;if(D){a=Atomics.wait(w(),a>>2,b,c);if("timed-out"===a)return-73;if("not-equal"===a)return-6;if("ok"===a)return 0;throw"Atomics.wait returned an unexpected value "+a;}var d=Atomics.load(w(),a>>2);if(b!=d)return-6;b=performance.now();c=b+c;Atomics.store(w(),220080,a);for(d=a;a==d;){b=performance.now();if(b>c)return-73;yb();a=Atomics.load(w(),220080)}return 0}
|
||||
function T(a,b){for(var c=arguments.length-2,d=Y(),f=nd(8*c),g=f>>3,h=0;h<c;h++)la()[g+h]=arguments[2+h];c=od(a,c,f,b);N(d);return c}var pd=[],qd=[],rd=[0,"undefined"!==typeof document?document:0,"undefined"!==typeof window?window:0];function sd(a){a=2<a?Ja(a):a;return rd[a]||("undefined"!==typeof document?document.querySelector(a):void 0)}
|
||||
function td(a,b,c){var d=sd(a);if(!d)return-4;d.Qb&&(w()[d.Qb>>2]=b,w()[d.Qb+4>>2]=c);if(d.pc||!d.gd)d.pc&&(d=d.pc),a=!1,d.Pb&&d.Pb.Ob&&(a=d.Pb.Ob.getParameter(2978),a=0===a[0]&&0===a[1]&&a[2]===d.width&&a[3]===d.height),d.width=b,d.height=c,a&&d.Pb.Ob.viewport(0,0,b,c);else{if(d.Qb){d=w()[d.Qb+8>>2];a=a?Ja(a):"";var f=Y(),g=nd(12),h=0;if(a){h=Ma(a)+1;var l=R(h);La(a,l,h);h=l}w()[g>>2]=h;w()[g+4>>2]=b;w()[g+8>>2]=c;ud(0,d,657457152,0,h,g);N(f);return 1}return-4}return 0}
|
||||
function vd(a,b,c){return G?T(4,1,a,b,c):td(a,b,c)}function wd(a){var b=a.getExtension("ANGLE_instanced_arrays");b&&(a.vertexAttribDivisor=function(c,d){b.vertexAttribDivisorANGLE(c,d)},a.drawArraysInstanced=function(c,d,f,g){b.drawArraysInstancedANGLE(c,d,f,g)},a.drawElementsInstanced=function(c,d,f,g,h){b.drawElementsInstancedANGLE(c,d,f,g,h)})}
|
||||
function xd(a){var b=a.getExtension("OES_vertex_array_object");b&&(a.createVertexArray=function(){return b.createVertexArrayOES()},a.deleteVertexArray=function(c){b.deleteVertexArrayOES(c)},a.bindVertexArray=function(c){b.bindVertexArrayOES(c)},a.isVertexArray=function(c){return b.isVertexArrayOES(c)})}function yd(a){var b=a.getExtension("WEBGL_draw_buffers");b&&(a.drawBuffers=function(c,d){b.drawBuffersWEBGL(c,d)})}
|
||||
function zd(a){a||(a=Ad);if(!a.Ec){a.Ec=!0;var b=a.Ob;wd(b);xd(b);yd(b);b.hd=b.getExtension("EXT_disjoint_timer_query");var c="OES_texture_float OES_texture_half_float OES_standard_derivatives OES_vertex_array_object WEBGL_compressed_texture_s3tc WEBGL_depth_texture OES_element_index_uint EXT_texture_filter_anisotropic EXT_frag_depth WEBGL_draw_buffers ANGLE_instanced_arrays OES_texture_float_linear OES_texture_half_float_linear EXT_blend_minmax EXT_shader_texture_lod EXT_texture_norm16 WEBGL_compressed_texture_pvrtc EXT_color_buffer_half_float WEBGL_color_buffer_float EXT_sRGB WEBGL_compressed_texture_etc1 EXT_disjoint_timer_query WEBGL_compressed_texture_etc WEBGL_compressed_texture_astc EXT_color_buffer_float WEBGL_compressed_texture_s3tc_srgb EXT_disjoint_timer_query_webgl2 WEBKIT_WEBGL_compressed_texture_pvrtc".split(" ");
|
||||
(b.getSupportedExtensions()||[]).forEach(function(d){-1!=c.indexOf(d)&&b.getExtension(d)})}}var Ad,Bd=["default","low-power","high-performance"];function Cd(a){if(G)return T(5,1,a);try{var b=Ac(a);if(null===b.fd)throw new P(8);b.Yb&&(b.Yb=null);try{b.tb.close&&b.tb.close(b)}catch(c){throw c;}finally{Ub[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof xc&&c instanceof P||J(c),c.Gb}}
|
||||
function Dd(a,b,c,d){if(G)return T(6,1,a,b,c,d);try{a:{for(var f=Ac(a),g=a=0;g<c;g++){var h=w()[b+8*g>>2],l=w()[b+(8*g+4)>>2],k=f,q=e(),r=h,v=l,y=void 0;if(0>v||0>y)throw new P(28);if(null===k.fd)throw new P(8);if(1===(k.flags&2097155))throw new P(8);if(16384===(k.node.mode&61440))throw new P(31);if(!k.tb.read)throw new P(28);var B="undefined"!==typeof y;if(!B)y=k.position;else if(!k.seekable)throw new P(70);var u=k.tb.read(k,q,r,v,y);B||(k.position+=u);var O=u;if(0>O){var E=-1;break a}a+=O;if(O<
|
||||
l)break}E=a}w()[d>>2]=E;return 0}catch(C){return"undefined"!==typeof xc&&C instanceof P||J(C),C.Gb}}
|
||||
function Ed(a,b,c,d,f){if(G)return T(7,1,a,b,c,d,f);try{var g=Ac(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;rc(g,a,d);mb=[g.position>>>0,(lb=g.position,1<=+$a(lb)?0<lb?(cb(+bb(lb/4294967296),4294967295)|0)>>>0:~~+ab((lb-+(~~lb>>>0))/4294967296)>>>0:0)];w()[f>>2]=mb[0];w()[f+4>>2]=mb[1];g.Yb&&0===a&&0===d&&(g.Yb=null);return 0}catch(h){return"undefined"!==typeof xc&&h instanceof P||J(h),h.Gb}}
|
||||
function Fd(a,b,c,d){if(G)return T(8,1,a,b,c,d);try{a:{for(var f=Ac(a),g=a=0;g<c;g++){var h=w()[b+8*g>>2],l=w()[b+(8*g+4)>>2],k=f,q=e(),r=h,v=l,y=void 0;if(0>v||0>y)throw new P(28);if(null===k.fd)throw new P(8);if(0===(k.flags&2097155))throw new P(8);if(16384===(k.node.mode&61440))throw new P(31);if(!k.tb.write)throw new P(28);k.seekable&&k.flags&1024&&rc(k,0,2);var B="undefined"!==typeof y;if(!B)y=k.position;else if(!k.seekable)throw new P(70);var u=k.tb.write(k,q,r,v,y,void 0);B||(k.position+=u);
|
||||
try{if(k.path&&Yb.onWriteToFile)Yb.onWriteToFile(k.path)}catch(C){K("FS.trackingDelegate['onWriteToFile']('"+k.path+"') threw an exception: "+C.message)}var O=u;if(0>O){var E=-1;break a}a+=O}E=a}w()[d>>2]=E;return 0}catch(C){return"undefined"!==typeof xc&&C instanceof P||J(C),C.Gb}}
|
||||
function zb(a){if(G)throw"Internal Error! spawnThread() can only ever be called from main application thread!";var b=L.zc();if(void 0!==b.wb)throw"Internal error!";if(!a.Kb)throw"Internal error, no pthread ptr!";L.Fb.push(b);for(var c=R(512),d=0;128>d;++d)w()[c+4*d>>2]=0;var f=a.Ib+a.Lb;d=L.Ab[a.Kb]={worker:b,Ib:a.Ib,Lb:a.Lb,Vb:a.Vb,tc:a.Kb,threadInfoStruct:a.Kb};var g=d.threadInfoStruct>>2;Atomics.store(x(),g,0);Atomics.store(x(),g+1,0);Atomics.store(x(),g+2,0);Atomics.store(x(),g+17,a.detached);
|
||||
Atomics.store(x(),g+26,c);Atomics.store(x(),g+12,0);Atomics.store(x(),g+10,d.threadInfoStruct);Atomics.store(x(),g+11,42);Atomics.store(x(),g+27,a.Lb);Atomics.store(x(),g+21,a.Lb);Atomics.store(x(),g+20,f);Atomics.store(x(),g+29,f);Atomics.store(x(),g+30,a.detached);Atomics.store(x(),g+32,a.rc);Atomics.store(x(),g+33,a.sc);c=Gd()+40;Atomics.store(x(),g+44,c);b.wb=d;var h={cmd:"run",start_routine:a.Xc,arg:a.Mb,threadInfoStruct:a.Kb,selfThreadId:a.Kb,parentThreadId:a.Mc,stackBase:a.Ib,stackSize:a.Lb};
|
||||
b.Nb=function(){h.time=performance.now();b.postMessage(h,a.$c)};b.loaded&&(b.Nb(),delete b.Nb)}function Hd(){return qb|0}z._pthread_self=Hd;
|
||||
function Id(a,b){if(!a)return K("pthread_join attempted on a null thread pointer!"),71;if(G&&selfThreadId==a)return K("PThread "+a+" is attempting to join to itself!"),16;if(!G&&L.vb==a)return K("Main thread "+a+" is attempting to join to itself!"),16;if(w()[a+12>>2]!==a)return K("pthread_join attempted on thread "+a+", which does not point to a valid thread, or does not exist anymore!"),71;if(Atomics.load(x(),a+68>>2))return K("Attempted to join thread "+a+", which was already detached!"),28;for(ld();;){var c=
|
||||
Atomics.load(x(),a+0>>2);if(1==c)return c=Atomics.load(x(),a+4>>2),b&&(w()[b>>2]=c),Atomics.store(x(),a+68>>2,1),G?postMessage({cmd:"cleanupThread",thread:a}):vb(a),0;if(G&&threadInfoStruct&&!Atomics.load(x(),threadInfoStruct+60>>2)&&2==Atomics.load(x(),threadInfoStruct+0>>2))throw"Canceled!";G||yb();md(a+0,c,G?100:1)}}G?L.Hc():L.Fc();function dc(a,b,c,d){a||(a=this);this.parent=a;this.Db=a.Db;this.Sb=null;this.id=Vb++;this.name=b;this.mode=c;this.sb={};this.tb={};this.rdev=d}
|
||||
Object.defineProperties(dc.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});sc();Wb=Array(4096);lc(Q,"/");S("/tmp");S("/home");S("/home/web_user");
|
||||
(function(){S("/dev");Kb(259,{read:function(){return 0},write:function(d,f,g,h){return h}});nc("/dev/null",259);Jb(1280,Mb);Jb(1536,Nb);nc("/dev/tty",1280);nc("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(F)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){J("random_device")});vc("random",b);vc("urandom",b);S("/dev/shm");
|
||||
S("/dev/shm/tmp")})();S("/proc");S("/proc/self");S("/proc/self/fd");lc({Db:function(){var a=Pb("/proc/self","fd",16895,73);a.sb={lookup:function(b,c){var d=Ub[+c];if(!d)throw new P(8);b={parent:null,Db:{nc:"fake"},sb:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");Oc=z.InternalError=Nc("InternalError");for(var Jd=Array(256),Kd=0;256>Kd;++Kd)Jd[Kd]=String.fromCharCode(Kd);Rc=Jd;Sc=z.BindingError=Nc("BindingError");
|
||||
z.count_emval_handles=function(){for(var a=0,b=5;b<X.length;++b)void 0!==X[b]&&++a;return a};z.get_first_emval=function(){for(var a=5;a<X.length;++a)if(void 0!==X[a])return X[a];return null};cd=z.UnboundTypeError=Nc("UnboundTypeError");
|
||||
var Ld=[null,Bc,Dc,Ec,vd,Cd,Dd,Ed,Fd],Vd={n:function(a,b,c,d){J("Assertion failed: "+Ja(a)+", at: "+[b?Ja(b):"unknown filename",c,d?Ja(d):"unknown function"])},ga:function(a,b){return Bb(a,b)},D:Bc,Z:Dc,_:Ec,K:function(a){var b=Fc[a];delete Fc[a];var c=b.Nc,d=b.Oc,f=b.hc,g=f.map(function(h){return h.Cc}).concat(f.map(function(h){return h.Vc}));Pc([a],g,function(h){var l={};f.forEach(function(k,q){var r=h[q],v=k.Ac,y=k.Bc,B=h[q+f.length],u=k.Uc,O=k.Wc;l[k.xc]={read:function(E){return r.fromWireType(v(y,
|
||||
E))},write:function(E,C){var Ba=[];u(O,E,B.toWireType(Ba,C));Gc(Ba)}}});return[{name:b.name,fromWireType:function(k){var q={},r;for(r in l)q[r]=l[r].read(k);d(k);return q},toWireType:function(k,q){for(var r in l)if(!(r in q))throw new TypeError('Missing field: "'+r+'"');var v=c();for(r in l)l[r].write(v,q[r]);null!==k&&k.push(d,v);return v},argPackAdvance:8,readValueFromPointer:Hc,Cb:d}]})},ba:function(a,b,c,d,f){var g=Qc(c);b=V(b);U(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,
|
||||
l){return l?d:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var l=e();else if(2===c)l=ca();else if(4===c)l=w();else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(l[h>>g])},Cb:null})},aa:function(a,b){b=V(b);U(a,{name:b,fromWireType:function(c){var d=X[c].value;Uc(c);return d},toWireType:function(c,d){return Vc(d)},argPackAdvance:8,readValueFromPointer:Hc,Cb:null})},F:function(a,b,c){c=Qc(c);b=V(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,
|
||||
f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Wc(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Xc(b,c),Cb:null})},J:function(a,b,c,d,f,g){var h=ad(b,c);a=V(a);f=bd(d,f);$c(a,function(){fd("Cannot call "+a+" due to unbound types",h)},b-1);Pc([],h,function(l){var k=[l[0],null].concat(l.slice(1)),q=l=a,r=f,v=k.length;2>v&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==k[1]&&!1,B=!1,
|
||||
u=1;u<k.length;++u)if(null!==k[u]&&void 0===k[u].Cb){B=!0;break}var O="void"!==k[0].name,E="",C="";for(u=0;u<v-2;++u)E+=(0!==u?", ":"")+"arg"+u,C+=(0!==u?", ":"")+"arg"+u+"Wired";q="return function "+Lc(q)+"("+E+") {\nif (arguments.length !== "+(v-2)+") {\nthrowBindingError('function "+q+" called with ' + arguments.length + ' arguments, expected "+(v-2)+" args!');\n}\n";B&&(q+="var destructors = [];\n");var Ba=B?"destructors":"null";E="throwBindingError invoker fn runDestructors retType classParam".split(" ");
|
||||
r=[W,r,g,Gc,k[0],k[1]];y&&(q+="var thisWired = classParam.toWireType("+Ba+", this);\n");for(u=0;u<v-2;++u)q+="var arg"+u+"Wired = argType"+u+".toWireType("+Ba+", arg"+u+"); // "+k[u+2].name+"\n",E.push("argType"+u),r.push(k[u+2]);y&&(C="thisWired"+(0<C.length?", ":"")+C);q+=(O?"var rv = ":"")+"invoker(fn"+(0<C.length?", ":"")+C+");\n";if(B)q+="runDestructors(destructors);\n";else for(u=y?1:2;u<k.length;++u)v=1===u?"thisWired":"arg"+(u-2)+"Wired",null!==k[u].Cb&&(q+=v+"_dtor("+v+"); // "+k[u].name+
|
||||
"\n",E.push(v+"_dtor"),r.push(k[u].Cb));O&&(q+="var ret = retType.fromWireType(rv);\nreturn ret;\n");E.push(q+"}\n");k=Yc(E).apply(null,r);u=b-1;if(!z.hasOwnProperty(l))throw new Oc("Replacing nonexistant public symbol");void 0!==z[l].zb&&void 0!==u?z[l].zb[u]=k:(z[l]=k,z[l].uc=u);return[]})},o:function(a,b,c,d,f){function g(q){return q}b=V(b);-1===f&&(f=4294967295);var h=Qc(c);if(0===d){var l=32-8*c;g=function(q){return q<<l>>>l}}var k=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(q,
|
||||
r){if("number"!==typeof r&&"boolean"!==typeof r)throw new TypeError('Cannot convert "'+Wc(r)+'" to '+this.name);if(r<d||r>f)throw new TypeError('Passing a number "'+Wc(r)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return k?r>>>0:r|0},argPackAdvance:8,readValueFromPointer:gd(b,h,0!==d),Cb:null})},j:function(a,b,c){function d(g){g>>=2;var h=x();return new f(n,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,
|
||||
Uint32Array,Float32Array,Float64Array][b];c=V(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{Dc:!0})},G:function(a,b){b=V(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=x()[d>>2];if(c)for(var g=d+4,h=0;h<=f;++h){var l=d+4+h;if(h==f||0==t()[l]){g=Ja(g,l-g);if(void 0===k)var k=g;else k+=String.fromCharCode(0),k+=g;g=l+1}}else{k=Array(f);for(h=0;h<f;++h)k[h]=String.fromCharCode(t()[d+4+h]);k=k.join("")}M(d);return k},toWireType:function(d,f){f instanceof
|
||||
ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||W("Cannot pass non-string to std::string");var h=(c&&g?function(){return Ma(f)}:function(){return f.length})(),l=R(4+h+1);x()[l>>2]=h;if(c&&g)La(f,l+4,h+1);else if(g)for(g=0;g<h;++g){var k=f.charCodeAt(g);255<k&&(M(l),W("String has UTF-16 code units that do not fit in 8 bits"));t()[l+4+g]=k}else for(g=0;g<h;++g)t()[l+4+g]=f[g];null!==d&&d.push(M,l);return l},
|
||||
argPackAdvance:8,readValueFromPointer:Hc,Cb:function(d){M(d)}})},x:function(a,b,c){c=V(c);if(2===b){var d=Na;var f=Oa;var g=Pa;var h=function(){return ea()};var l=1}else 4===b&&(d=Qa,f=Ra,g=Sa,h=function(){return x()},l=2);U(a,{name:c,fromWireType:function(k){for(var q=x()[k>>2],r=h(),v,y=k+4,B=0;B<=q;++B){var u=k+4+B*b;if(B==q||0==r[u>>l])y=d(y,u-y),void 0===v?v=y:(v+=String.fromCharCode(0),v+=y),y=u+b}M(k);return v},toWireType:function(k,q){"string"!==typeof q&&W("Cannot pass non-string to C++ string type "+
|
||||
c);var r=g(q),v=R(4+r+b);x()[v>>2]=r>>l;f(q,v+4,r+b);null!==k&&k.push(M,v);return v},argPackAdvance:8,readValueFromPointer:Hc,Cb:function(k){M(k)}})},N:function(a,b,c,d,f,g){Fc[a]={name:V(b),Nc:bd(c,d),Oc:bd(f,g),hc:[]}},p:function(a,b,c,d,f,g,h,l,k,q){Fc[a].hc.push({xc:V(b),Cc:c,Ac:bd(d,f),Bc:g,Vc:h,Uc:bd(l,k),Wc:q})},ca:function(a,b){b=V(b);U(a,{md:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},T:function(a,b){if(a==b)postMessage({cmd:"processQueuedMainThreadWork"});
|
||||
else if(G)postMessage({targetThread:a,cmd:"processThreadQueue"});else{a=(a=L.Ab[a])&&a.worker;if(!a)return;a.postMessage({cmd:"processThreadQueue"})}return 1},w:Uc,$:function(a){if(0===a)return Vc(id());var b=hd[a];a=void 0===b?V(a):b;return Vc(id()[a])},I:function(a){4<a&&(X[a].ac+=1)},U:function(a,b,c,d){a||W("Cannot use deleted val. handle = "+a);a=X[a].value;var f=kd[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";
|
||||
for(g=0;g<b;++g)h+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",h+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(jd,z,Vc);kd[b]=f}return f(a,c,d)},k:function(){J()},u:function(a,b,c){qd.length=0;var d;for(c>>=2;d=t()[b++];)(d=105>d)&&c&1&&c++,
|
||||
qd.push(d?la()[c++>>1]:w()[c]),++c;return ob[a].apply(null,qd)},X:ld,A:function(){},g:md,h:ub,e:Ab,r:function(){return sb|0},V:function(){return rb|0},i:function(a,b){Z(a,b||1);throw"longjmp";},P:function(a,b,c){t().copyWithin(a,b,b+c)},fa:function(){return navigator.hardwareConcurrency},Q:function(a,b,c){pd.length=b;c>>=3;for(var d=0;d<b;d++)pd[d]=la()[c+d];return(0>a?ob[-a-1]:Ld[a]).apply(null,pd)},s:function(a){a>>>=0;var b=t().length;if(a<=b||2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=
|
||||
b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{m.grow(Math.min(2147483648,d)-n.byteLength+65535>>>16);p(m.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},R:function(a,b,c){return sd(a)?td(a,b,c):vd(a,b,c)},f:function(){},S:function(a,b){var c={};b>>=2;c.alpha=!!w()[b];c.depth=!!w()[b+1];c.stencil=!!w()[b+2];c.antialias=!!w()[b+3];c.premultipliedAlpha=!!w()[b+4];c.preserveDrawingBuffer=!!w()[b+5];var d=w()[b+6];c.powerPreference=
|
||||
Bd[d];c.failIfMajorPerformanceCaveat=!!w()[b+7];c.Jc=w()[b+8];c.od=w()[b+9];c.ec=w()[b+10];c.wc=w()[b+11];c.rd=w()[b+12];c.td=w()[b+13];(a=sd(a))?c.wc?c=-1:(a=a.getContext("webgl",c))?(b=R(8),w()[b+4>>2]=qb|0,d={ld:b,attributes:c,version:c.Jc,Ob:a},a.canvas&&(a.canvas.Pb=d),("undefined"===typeof c.ec||c.ec)&&zd(d),c=b):c=0:c=-4;return c},E:Cd,Y:Dd,L:Ed,C:Fd,b:function(){return Da|0},O:function(){L.Gc()},z:Md,M:Nd,y:Od,t:Pd,v:Qd,l:Rd,c:Sd,memory:m||z.wasmMemory,W:function(a){var b=L.Ub.pop();a&&b()},
|
||||
B:Bb,H:function(a,b,c,d){if("undefined"===typeof SharedArrayBuffer)return K("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;if(!a)return K("pthread_create called with a null thread pointer!"),28;var f=[];if(G&&0===f.length)return Td(687865856,a,b,c,d);var g=0,h=0,l=0,k=0;if(b){var q=w()[b>>2];q+=81920;g=w()[b+8>>2];h=0!==w()[b+12>>2];if(0===w()[b+16>>2]){var r=w()[b+20>>2],v=w()[b+24>>2];l=b+20;k=b+24;var y=L.Wb?L.Wb:qb|0;if(l||k)if(y)if(w()[y+12>>2]!==y)K("pthread_getschedparam attempted on thread "+
|
||||
y+", which does not point to a valid thread, or does not exist anymore!");else{var B=Atomics.load(x(),y+108+20>>2);y=Atomics.load(x(),y+108+24>>2);l&&(w()[l>>2]=B);k&&(w()[k>>2]=y)}else K("pthread_getschedparam called with a null thread pointer!");l=w()[b+20>>2];k=w()[b+24>>2];w()[b+20>>2]=r;w()[b+24>>2]=v}else l=w()[b+20>>2],k=w()[b+24>>2]}else q=2097152;(b=0==g)?g=Ud(16,q):(g-=q,assert(0<g));r=R(232);for(v=0;58>v;++v)x()[(r>>2)+v]=0;w()[a>>2]=r;w()[r+12>>2]=r;a=r+156;w()[a>>2]=a;c={Ib:g,Lb:q,Vb:b,
|
||||
rc:l,sc:k,detached:h,Xc:c,Kb:r,Mc:qb|0,Mb:d,$c:f};G?(c.ed="spawnThread",postMessage(c,f)):zb(c);return 0},da:function(a,b){return Id(a,b)},d:Hd,q:function(a){a=+a;return 0<=a?+bb(a+.5):+ab(a-.5)},m:function(a){a=+a;return 0<=a?+bb(a+.5):+ab(a-.5)},a:function(a){Da=a|0},table:Fa,ea:function(a){var b=Date.now()/1E3|0;a&&(w()[a>>2]=b);return b}};
|
||||
(function(){function a(f,g){z.asm=f.exports;Ga=g;if(!G){var h=L.xb.length;L.xb.forEach(function(l){L.lc(l,function(){if(!--h&&(db--,z.monitorRunDependencies&&z.monitorRunDependencies(db),0==db&&(null!==eb&&(clearInterval(eb),eb=null),fb))){var k=fb;fb=null;k()}})})}}function b(f){a(f.instance,f.module)}function c(f){return kb().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){K("failed to asynchronously prepare wasm: "+g);J(g)})}var d={a:Vd};G||(assert(!G,"addRunDependency cannot be used in a pthread worker"),
|
||||
db++,z.monitorRunDependencies&&z.monitorRunDependencies(db));if(z.instantiateWasm)try{return z.instantiateWasm(d,a)}catch(f){return K("Module.instantiateWasm callback failed with error: "+f),!1}(function(){if(Ea||"function"!==typeof WebAssembly.instantiateStreaming||ib()||gb("file://")||"function"!==typeof fetch)return c(b);fetch(hb,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){K("wasm streaming compile failed: "+g);K("falling back to ArrayBuffer instantiation");
|
||||
return c(b)})})})();return{}})();var pb=z.___wasm_call_ctors=function(){return(pb=z.___wasm_call_ctors=z.asm.ha).apply(null,arguments)},R=z._malloc=function(){return(R=z._malloc=z.asm.ia).apply(null,arguments)},M=z._free=function(){return(M=z._free=z.asm.ja).apply(null,arguments)},ed=z.___getTypeName=function(){return(ed=z.___getTypeName=z.asm.ka).apply(null,arguments)};
|
||||
z.___embind_register_native_and_builtin_types=function(){return(z.___embind_register_native_and_builtin_types=z.asm.la).apply(null,arguments)};var Gd=z._emscripten_get_global_libc=function(){return(Gd=z._emscripten_get_global_libc=z.asm.ma).apply(null,arguments)},Cc=z.___errno_location=function(){return(Cc=z.___errno_location=z.asm.na).apply(null,arguments)};z.___em_js__initPthreadsJS=function(){return(z.___em_js__initPthreadsJS=z.asm.oa).apply(null,arguments)};
|
||||
var Z=z._setThrew=function(){return(Z=z._setThrew=z.asm.pa).apply(null,arguments)},Y=z.stackSave=function(){return(Y=z.stackSave=z.asm.qa).apply(null,arguments)},N=z.stackRestore=function(){return(N=z.stackRestore=z.asm.ra).apply(null,arguments)},nd=z.stackAlloc=function(){return(nd=z.stackAlloc=z.asm.sa).apply(null,arguments)},Ud=z._memalign=function(){return(Ud=z._memalign=z.asm.ta).apply(null,arguments)};
|
||||
z._emscripten_main_browser_thread_id=function(){return(z._emscripten_main_browser_thread_id=z.asm.ua).apply(null,arguments)};var xb=z.___pthread_tsd_run_dtors=function(){return(xb=z.___pthread_tsd_run_dtors=z.asm.va).apply(null,arguments)},yb=z._emscripten_main_thread_process_queued_calls=function(){return(yb=z._emscripten_main_thread_process_queued_calls=z.asm.wa).apply(null,arguments)};
|
||||
z._emscripten_current_thread_process_queued_calls=function(){return(z._emscripten_current_thread_process_queued_calls=z.asm.xa).apply(null,arguments)};var wb=z._emscripten_register_main_browser_thread_id=function(){return(wb=z._emscripten_register_main_browser_thread_id=z.asm.ya).apply(null,arguments)},nb=z._do_emscripten_dispatch_to_thread=function(){return(nb=z._do_emscripten_dispatch_to_thread=z.asm.za).apply(null,arguments)};
|
||||
z._emscripten_async_run_in_main_thread=function(){return(z._emscripten_async_run_in_main_thread=z.asm.Aa).apply(null,arguments)};z._emscripten_sync_run_in_main_thread=function(){return(z._emscripten_sync_run_in_main_thread=z.asm.Ba).apply(null,arguments)};z._emscripten_sync_run_in_main_thread_0=function(){return(z._emscripten_sync_run_in_main_thread_0=z.asm.Ca).apply(null,arguments)};
|
||||
z._emscripten_sync_run_in_main_thread_1=function(){return(z._emscripten_sync_run_in_main_thread_1=z.asm.Da).apply(null,arguments)};z._emscripten_sync_run_in_main_thread_2=function(){return(z._emscripten_sync_run_in_main_thread_2=z.asm.Ea).apply(null,arguments)};z._emscripten_sync_run_in_main_thread_xprintf_varargs=function(){return(z._emscripten_sync_run_in_main_thread_xprintf_varargs=z.asm.Fa).apply(null,arguments)};
|
||||
z._emscripten_sync_run_in_main_thread_3=function(){return(z._emscripten_sync_run_in_main_thread_3=z.asm.Ga).apply(null,arguments)};var Td=z._emscripten_sync_run_in_main_thread_4=function(){return(Td=z._emscripten_sync_run_in_main_thread_4=z.asm.Ha).apply(null,arguments)};z._emscripten_sync_run_in_main_thread_5=function(){return(z._emscripten_sync_run_in_main_thread_5=z.asm.Ia).apply(null,arguments)};
|
||||
z._emscripten_sync_run_in_main_thread_6=function(){return(z._emscripten_sync_run_in_main_thread_6=z.asm.Ja).apply(null,arguments)};z._emscripten_sync_run_in_main_thread_7=function(){return(z._emscripten_sync_run_in_main_thread_7=z.asm.Ka).apply(null,arguments)};
|
||||
var od=z._emscripten_run_in_main_runtime_thread_js=function(){return(od=z._emscripten_run_in_main_runtime_thread_js=z.asm.La).apply(null,arguments)},ud=z.__emscripten_call_on_thread=function(){return(ud=z.__emscripten_call_on_thread=z.asm.Ma).apply(null,arguments)};z._emscripten_tls_init=function(){return(z._emscripten_tls_init=z.asm.Na).apply(null,arguments)};
|
||||
var Cb=z.dynCall_vi=function(){return(Cb=z.dynCall_vi=z.asm.Oa).apply(null,arguments)},Wd=z.dynCall_vii=function(){return(Wd=z.dynCall_vii=z.asm.Pa).apply(null,arguments)};z.dynCall_viii=function(){return(z.dynCall_viii=z.asm.Qa).apply(null,arguments)};var Xd=z.dynCall_viiii=function(){return(Xd=z.dynCall_viiii=z.asm.Ra).apply(null,arguments)};z.dynCall_viiiiiiiiii=function(){return(z.dynCall_viiiiiiiiii=z.asm.Sa).apply(null,arguments)};
|
||||
var Yd=z.dynCall_iii=function(){return(Yd=z.dynCall_iii=z.asm.Ta).apply(null,arguments)},Zd=z.dynCall_iiii=function(){return(Zd=z.dynCall_iiii=z.asm.Ua).apply(null,arguments)},$d=z.dynCall_iiiii=function(){return($d=z.dynCall_iiiii=z.asm.Va).apply(null,arguments)},ae=z.dynCall_iiiiiiiii=function(){return(ae=z.dynCall_iiiiiiiii=z.asm.Wa).apply(null,arguments)};z.dynCall_i=function(){return(z.dynCall_i=z.asm.Xa).apply(null,arguments)};
|
||||
z.dynCall_iiiiii=function(){return(z.dynCall_iiiiii=z.asm.Ya).apply(null,arguments)};z.dynCall_viiiii=function(){return(z.dynCall_viiiii=z.asm.Za).apply(null,arguments)};z.dynCall_iiiiiii=function(){return(z.dynCall_iiiiiii=z.asm._a).apply(null,arguments)};z.dynCall_viiiiii=function(){return(z.dynCall_viiiiii=z.asm.$a).apply(null,arguments)};z.dynCall_viiiiiii=function(){return(z.dynCall_viiiiiii=z.asm.ab).apply(null,arguments)};
|
||||
z.dynCall_viiiiiiiiiii=function(){return(z.dynCall_viiiiiiiiiii=z.asm.bb).apply(null,arguments)};z.dynCall_ii=function(){return(z.dynCall_ii=z.asm.cb).apply(null,arguments)};z.dynCall_v=function(){return(z.dynCall_v=z.asm.db).apply(null,arguments)};z.dynCall_iiiiiiii=function(){return(z.dynCall_iiiiiiii=z.asm.eb).apply(null,arguments)};z.dynCall_iiiiiiiiii=function(){return(z.dynCall_iiiiiiiiii=z.asm.fb).apply(null,arguments)};
|
||||
z.dynCall_iiiiiiiiiiii=function(){return(z.dynCall_iiiiiiiiiiii=z.asm.gb).apply(null,arguments)};z.dynCall_viiiiiiii=function(){return(z.dynCall_viiiiiiii=z.asm.hb).apply(null,arguments)};z.dynCall_jiiiiiiiii=function(){return(z.dynCall_jiiiiiiiii=z.asm.ib).apply(null,arguments)};z.dynCall_jiji=function(){return(z.dynCall_jiji=z.asm.jb).apply(null,arguments)};z.dynCall_iidiiii=function(){return(z.dynCall_iidiiii=z.asm.kb).apply(null,arguments)};
|
||||
z.dynCall_viiiiiiiiiiiii=function(){return(z.dynCall_viiiiiiiiiiiii=z.asm.lb).apply(null,arguments)};z.dynCall_jiiiiiiii=function(){return(z.dynCall_jiiiiiiii=z.asm.mb).apply(null,arguments)};z.dynCall_ff=function(){return(z.dynCall_ff=z.asm.nb).apply(null,arguments)};z.dynCall_jiiiiii=function(){return(z.dynCall_jiiiiii=z.asm.ob).apply(null,arguments)};z.dynCall_jiiiii=function(){return(z.dynCall_jiiiii=z.asm.pb).apply(null,arguments)};
|
||||
z.dynCall_iiijii=function(){return(z.dynCall_iiijii=z.asm.qb).apply(null,arguments)};function Qd(a,b){var c=Y();try{Cb(a,b)}catch(d){N(c);if(d!==d+0&&"longjmp"!==d)throw d;Z(1,0)}}function Sd(a,b,c,d,f){var g=Y();try{Xd(a,b,c,d,f)}catch(h){N(g);if(h!==h+0&&"longjmp"!==h)throw h;Z(1,0)}}function Rd(a,b,c){var d=Y();try{Wd(a,b,c)}catch(f){N(d);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}
|
||||
function Pd(a,b,c,d,f,g,h,l,k){var q=Y();try{return ae(a,b,c,d,f,g,h,l,k)}catch(r){N(q);if(r!==r+0&&"longjmp"!==r)throw r;Z(1,0)}}function Md(a,b,c){var d=Y();try{return Yd(a,b,c)}catch(f){N(d);if(f!==f+0&&"longjmp"!==f)throw f;Z(1,0)}}function Od(a,b,c,d,f){var g=Y();try{return $d(a,b,c,d,f)}catch(h){N(g);if(h!==h+0&&"longjmp"!==h)throw h;Z(1,0)}}function Nd(a,b,c,d){var f=Y();try{return Zd(a,b,c,d)}catch(g){N(f);if(g!==g+0&&"longjmp"!==g)throw g;Z(1,0)}}z.PThread=L;z.PThread=L;z._pthread_self=Hd;
|
||||
z.wasmMemory=m;z.ExitStatus=ya;var be;function ya(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}fb=function ce(){be||de();be||(fb=ce)};
|
||||
function de(){function a(){if(!be&&(be=!0,z.calledRun=!0,!Ha)){z.noFSInit||tc||(tc=!0,sc(),z.stdin=z.stdin,z.stdout=z.stdout,z.stderr=z.stderr,z.stdin?vc("stdin",z.stdin):oc("/dev/tty","/dev/stdin"),z.stdout?vc("stdout",null,z.stdout):oc("/dev/tty","/dev/stdout"),z.stderr?vc("stderr",null,z.stderr):oc("/dev/tty1","/dev/stderr"),pc("/dev/stdin","r"),pc("/dev/stdout","w"),pc("/dev/stderr","w"));Ua(Wa);G||(Xb=!1,Ua(Xa));na(z);if(z.onRuntimeInitialized)z.onRuntimeInitialized();if(!G){if(z.postRun)for("function"==
|
||||
typeof z.postRun&&(z.postRun=[z.postRun]);z.postRun.length;){var b=z.postRun.shift();Ya.unshift(b)}Ua(Ya)}}}if(!(0<db)){if(!G){if(z.preRun)for("function"==typeof z.preRun&&(z.preRun=[z.preRun]);z.preRun.length;)Za();Ua(Va)}0<db||(z.setStatus?(z.setStatus("Running..."),setTimeout(function(){setTimeout(function(){z.setStatus("")},1);a()},1)):a())}}z.run=de;if(z.preInit)for("function"==typeof z.preInit&&(z.preInit=[z.preInit]);0<z.preInit.length;)z.preInit.pop()();G||(noExitRuntime=!0);
|
||||
G?(z.___embind_register_native_and_builtin_types(),na(z)):de();
|
||||
|
||||
|
||||
return avif_enc_mt.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = avif_enc_mt;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return avif_enc_mt; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["avif_enc_mt"] = avif_enc_mt;
|
||||
|
BIN
codecs/avif/enc/avif_enc_mt.wasm
Normal file
BIN
codecs/avif/enc/avif_enc_mt.wasm
Normal file
Binary file not shown.
1
codecs/avif/enc/avif_enc_mt.worker.js
Normal file
1
codecs/avif/enc/avif_enc_mt.worker.js
Normal file
@ -0,0 +1 @@
|
||||
var threadInfoStruct=0;var selfThreadId=0;var parentThreadId=0;var Module={};function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:selfThreadId})}var err=threadPrintErr;this.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);Module["wasmModule"]=null;receiveInstance(instance);return instance.exports};this.onmessage=function(e){try{if(e.data.cmd==="load"){Module["DYNAMIC_BASE"]=e.data.DYNAMIC_BASE;Module["DYNAMICTOP_PTR"]=e.data.DYNAMICTOP_PTR;Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}avif_enc_mt(Module).then(function(instance){Module=instance;postMessage({"cmd":"loaded"})})}else if(e.data.cmd==="objectTransfer"){Module["PThread"].receiveObjectTransfer(e.data)}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;threadInfoStruct=e.data.threadInfoStruct;Module["registerPthreadPtr"](threadInfoStruct,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0);selfThreadId=e.data.selfThreadId;parentThreadId=e.data.parentThreadId;var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["_emscripten_tls_init"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].setThreadStatus(Module["_pthread_self"](),1);/*EM_THREAD_STATUS_RUNNING*/try{var result=Module["dynCall_ii"](e.data.start_routine,e.data.arg);if(!Module["getNoExitRuntime"]())Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){Atomics.store(Module["HEAPU32"],(threadInfoStruct+4)>>/*C_STRUCTS.pthread.threadExitCode*/2,(ex instanceof Module["ExitStatus"])?ex.status:-2);/*A custom entry specific to Emscripten denoting that the thread crashed.*/Atomics.store(Module["HEAPU32"],(threadInfoStruct+0)>>/*C_STRUCTS.pthread.threadStatus*/2,1);Module["_emscripten_futex_wake"](threadInfoStruct+0,/*C_STRUCTS.pthread.threadStatus*/2147483647);if(!(ex instanceof Module["ExitStatus"]))throw ex}}}else if(e.data.cmd==="cancel"){if(threadInfoStruct){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(threadInfoStruct){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex.stack)err(ex.stack);throw ex}};if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){self={location:{href:__filename}};var onmessage=this.onmessage;var nodeWorkerThreads=require("worker_threads");global.Worker=nodeWorkerThreads.Worker;var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var nodeFS=require("fs");var nodeRead=function(filename){return nodeFS.readFileSync(filename,"utf8")};function globalEval(x){global.require=require;global.Module=Module;eval.call(null,x)}importScripts=function(f){globalEval(nodeRead(f))};postMessage=function(msg){parentPort.postMessage(msg)};if(typeof performance==="undefined"){performance={now:function(){return Date.now()}}}}
|
72
codecs/avif/helper.Makefile
Normal file
72
codecs/avif/helper.Makefile
Normal file
@ -0,0 +1,72 @@
|
||||
# This is a helper Makefile for building LibAVIF + LibAOM with given params.
|
||||
#
|
||||
# Params that must be supplied by the caller:
|
||||
# $(CODEC_DIR)
|
||||
# $(LIBAOM_DIR)
|
||||
# $(BUILD_DIR)
|
||||
# $(OUT_JS)
|
||||
# $(OUT_CPP)
|
||||
# $(LIBAOM_FLAGS)
|
||||
# $(LIBAVIF_FLAGS)
|
||||
|
||||
CODEC_BUILD_DIR := $(BUILD_DIR)/libavif
|
||||
CODEC_OUT := $(CODEC_BUILD_DIR)/libavif.a
|
||||
|
||||
LIBAOM_BUILD_DIR := $(BUILD_DIR)/libaom
|
||||
LIBAOM_OUT := $(LIBAOM_BUILD_DIR)/libaom.a
|
||||
|
||||
OUT_WASM = $(OUT_JS:.js=.wasm)
|
||||
OUT_WORKER=$(OUT_JS:.js=.worker.js)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_JS)
|
||||
|
||||
$(OUT_JS): $(OUT_CPP) $(LIBAOM_OUT) $(CODEC_OUT)
|
||||
$(CXX) \
|
||||
-I $(CODEC_DIR)/include \
|
||||
$(CXXFLAGS) \
|
||||
$(LDFLAGS) \
|
||||
$(OUT_FLAGS) \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||
-o $@ \
|
||||
$+
|
||||
|
||||
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
|
||||
emcmake cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_SHARED_LIBS=0 \
|
||||
-DAVIF_CODEC_AOM=1 \
|
||||
-DAOM_LIBRARY=$(LIBAOM_OUT) \
|
||||
-DAOM_INCLUDE_DIR=$(LIBAOM_DIR) \
|
||||
$(LIBAVIF_FLAGS) \
|
||||
-B $(CODEC_BUILD_DIR) \
|
||||
$(CODEC_DIR) && \
|
||||
$(MAKE) -C $(CODEC_BUILD_DIR)
|
||||
|
||||
$(LIBAOM_OUT): $(LIBAOM_DIR)/CMakeLists.txt
|
||||
emcmake cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_CCACHE=0 \
|
||||
-DAOM_TARGET_CPU=generic \
|
||||
-DENABLE_DOCS=0 \
|
||||
-DENABLE_TESTS=0 \
|
||||
-DENABLE_EXAMPLES=0 \
|
||||
-DENABLE_TOOLS=0 \
|
||||
-DCONFIG_ACCOUNTING=1 \
|
||||
-DCONFIG_INSPECTION=0 \
|
||||
-DCONFIG_RUNTIME_CPU_DETECT=0 \
|
||||
-DCONFIG_WEBM_IO=0 \
|
||||
$(LIBAOM_FLAGS) \
|
||||
-B $(LIBAOM_BUILD_DIR) \
|
||||
$(LIBAOM_DIR) && \
|
||||
$(MAKE) -C $(LIBAOM_BUILD_DIR)
|
||||
|
||||
clean:
|
||||
$(RM) $(OUT_JS) $(OUT_WASM) $(OUT_WORKER)
|
||||
$(MAKE) -C $(CODEC_BUILD_DIR) clean
|
||||
$(MAKE) -C $(LIBAOM_BUILD_DIR) clean
|
6
codecs/avif/package.json
Normal file
6
codecs/avif/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "avif",
|
||||
"scripts": {
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
3
codecs/build-cpp.sh
Executable file
3
codecs/build-cpp.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh -e
|
||||
docker build -t squoosh-cpp - < ../cpp.Dockerfile
|
||||
docker run --rm -v $PWD:/src squoosh-cpp
|
4
codecs/build-rust-nightly.sh
Normal file
4
codecs/build-rust-nightly.sh
Normal file
@ -0,0 +1,4 @@
|
||||
set -e
|
||||
|
||||
docker build -t squoosh-rust-nightly --build-arg RUST_IMG=rustlang/rust@sha256:744aeea5a38f95aa7a96ec37269a65f0c6197a1cdd87d6534e12bb869141d807 - < ../rust.Dockerfile
|
||||
docker run --rm -v $PWD:/src squoosh-rust-nightly "$@"
|
4
codecs/build-rust.sh
Executable file
4
codecs/build-rust.sh
Executable file
@ -0,0 +1,4 @@
|
||||
set -e
|
||||
|
||||
docker build -t squoosh-rust - < ../rust.Dockerfile
|
||||
docker run --rm -v $PWD:/src squoosh-rust "$@"
|
9
codecs/cpp.Dockerfile
Normal file
9
codecs/cpp.Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM emscripten/emsdk:1.40.0
|
||||
RUN apt-get update && apt-get install -qqy autoconf libtool pkg-config
|
||||
ENV CFLAGS "-O3 -flto"
|
||||
ENV CXXFLAGS "${CFLAGS} -std=c++17"
|
||||
ENV LDFLAGS "${CFLAGS} -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
|
||||
# Build and cache standard libraries with these flags
|
||||
RUN emcc ${CXXFLAGS} --bind -xc++ /dev/null -o /dev/null
|
||||
WORKDIR /src
|
||||
CMD ["sh", "-c", "emmake make -j`nproc`"]
|
1
codecs/hqx/.gitignore
vendored
Normal file
1
codecs/hqx/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
289
codecs/hqx/Cargo.lock
generated
Normal file
289
codecs/hqx/Cargo.lock
generated
Normal file
@ -0,0 +1,289 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "hqx"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2#5f19cda24191ccc7c0c4920b6b246b4e242f377c"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memory_units"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "0.4.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "squooshhqx"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)",
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.3.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test"
|
||||
version = "0.2.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-test-macro"
|
||||
version = "0.2.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wee_alloc"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
|
||||
"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
|
||||
"checksum hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)" = "<none>"
|
||||
"checksum js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9"
|
||||
"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
|
||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
"checksum proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
|
||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||
"checksum syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
|
||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||
"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
"checksum wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d"
|
||||
"checksum wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d"
|
||||
"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
|
||||
"checksum wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
|
||||
"checksum wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
|
||||
"checksum wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87"
|
||||
"checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
|
||||
"checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
|
||||
"checksum web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2"
|
||||
"checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
|
||||
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
37
codecs/hqx/Cargo.toml
Normal file
37
codecs/hqx/Cargo.toml
Normal file
@ -0,0 +1,37 @@
|
||||
[package]
|
||||
name = "squooshhqx"
|
||||
version = "0.1.0"
|
||||
authors = ["Surma <surma@surma.link>"]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[features]
|
||||
default = ["console_error_panic_hook", "wee_alloc"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "0.1.2"
|
||||
wasm-bindgen = "0.2.38"
|
||||
# lazy_static = "1.0.0"
|
||||
hqx = {git = "https://github.com/CryZe/wasmboy-rs", tag="v0.1.2"}
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||
# code size when deploying.
|
||||
console_error_panic_hook = { version = "0.1.1", optional = true }
|
||||
|
||||
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
|
||||
# compared to the default allocator's ~10K. It is slower than the default
|
||||
# allocator, however.
|
||||
#
|
||||
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
|
||||
wee_alloc = { version = "0.4.2", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.2"
|
||||
|
||||
[profile.release]
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
opt-level = "s"
|
||||
lto = true
|
11
codecs/hqx/Dockerfile
Normal file
11
codecs/hqx/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
# This is intentionally an old version of Rust. Newer versions
|
||||
# generate _significantly_ bigger Wasm binaries.
|
||||
FROM rust:1.37
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||
|
||||
RUN mkdir /opt/binaryen && \
|
||||
curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1
|
||||
|
||||
ENV PATH="/opt/binaryen:${PATH}"
|
||||
WORKDIR /src
|
201
codecs/hqx/LICENSE.codec.md
Normal file
201
codecs/hqx/LICENSE.codec.md
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
5
codecs/hqx/README.md
Normal file
5
codecs/hqx/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# HQX
|
||||
|
||||
- Source: <https://github.com/CryZe/wasmboy-rs>
|
||||
- Version: v0.1.2
|
||||
- License: Apache 2.0
|
21
codecs/hqx/build.sh
Executable file
21
codecs/hqx/build.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling wasm"
|
||||
echo "============================================="
|
||||
(
|
||||
wasm-pack build -- --verbose --locked
|
||||
rm pkg/.gitignore
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling wasm done"
|
||||
echo "============================================="
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Did you update your docker image?"
|
||||
echo "Run \`docker pull ubuntu\`"
|
||||
echo "Run \`docker pull rust\`"
|
||||
echo "Run \`docker build -t squoosh-hqx .\`"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
4
codecs/hqx/package-lock.json
generated
Normal file
4
codecs/hqx/package-lock.json
generated
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "hqx",
|
||||
"lockfileVersion": 1
|
||||
}
|
7
codecs/hqx/package.json
Normal file
7
codecs/hqx/package.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "hqx",
|
||||
"scripts": {
|
||||
"build:image": "docker build -t squoosh-hqx - < Dockerfile",
|
||||
"build": "docker run --rm -v $(pwd):/src squoosh-hqx ./build.sh"
|
||||
}
|
||||
}
|
15
codecs/hqx/pkg/package.json
Normal file
15
codecs/hqx/pkg/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "squooshhqx",
|
||||
"collaborators": [
|
||||
"Surma <surma@surma.link>"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"squooshhqx_bg.wasm",
|
||||
"squooshhqx.js",
|
||||
"squooshhqx.d.ts"
|
||||
],
|
||||
"module": "squooshhqx.js",
|
||||
"types": "squooshhqx.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
10
codecs/hqx/pkg/squooshhqx.d.ts
vendored
Normal file
10
codecs/hqx/pkg/squooshhqx.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @param {Uint32Array} input_image
|
||||
* @param {number} input_width
|
||||
* @param {number} input_height
|
||||
* @param {number} factor
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
export function resize(input_image: Uint32Array, input_width: number, input_height: number, factor: number): Uint32Array;
|
2
codecs/hqx/pkg/squooshhqx.js
Normal file
2
codecs/hqx/pkg/squooshhqx.js
Normal file
@ -0,0 +1,2 @@
|
||||
import * as wasm from "./squooshhqx_bg.wasm";
|
||||
export * from "./squooshhqx_bg.js";
|
6
codecs/hqx/pkg/squooshhqx_bg.d.ts
vendored
Normal file
6
codecs/hqx/pkg/squooshhqx_bg.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export function resize(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
48
codecs/hqx/pkg/squooshhqx_bg.js
Normal file
48
codecs/hqx/pkg/squooshhqx_bg.js
Normal file
@ -0,0 +1,48 @@
|
||||
import * as wasm from './squooshhqx_bg.wasm';
|
||||
|
||||
let cachegetUint32Memory0 = null;
|
||||
function getUint32Memory0() {
|
||||
if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint32Memory0;
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
function passArray32ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 4);
|
||||
getUint32Memory0().set(arg, ptr / 4);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
|
||||
function getArrayU32FromWasm0(ptr, len) {
|
||||
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
|
||||
}
|
||||
/**
|
||||
* @param {Uint32Array} input_image
|
||||
* @param {number} input_width
|
||||
* @param {number} input_height
|
||||
* @param {number} factor
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
export function resize(input_image, input_width, input_height, factor) {
|
||||
var ptr0 = passArray32ToWasm0(input_image, wasm.__wbindgen_malloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
wasm.resize(8, ptr0, len0, input_width, input_height, factor);
|
||||
var r0 = getInt32Memory0()[8 / 4 + 0];
|
||||
var r1 = getInt32Memory0()[8 / 4 + 1];
|
||||
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 4);
|
||||
return v1;
|
||||
}
|
||||
|
BIN
codecs/hqx/pkg/squooshhqx_bg.wasm
Normal file
BIN
codecs/hqx/pkg/squooshhqx_bg.wasm
Normal file
Binary file not shown.
55
codecs/hqx/src/lib.rs
Normal file
55
codecs/hqx/src/lib.rs
Normal file
@ -0,0 +1,55 @@
|
||||
extern crate cfg_if;
|
||||
extern crate hqx;
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
mod utils;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
cfg_if! {
|
||||
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
||||
// allocator.
|
||||
if #[cfg(feature = "wee_alloc")] {
|
||||
extern crate wee_alloc;
|
||||
#[global_allocator]
|
||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
#[no_mangle]
|
||||
pub fn resize(
|
||||
input_image: Vec<u32>,
|
||||
input_width: usize,
|
||||
input_height: usize,
|
||||
factor: usize,
|
||||
) -> Vec<u32> {
|
||||
let num_output_pixels = input_width * input_height * factor * factor;
|
||||
let mut output_image = Vec::<u32>::with_capacity(num_output_pixels * 4);
|
||||
output_image.resize(num_output_pixels, 0);
|
||||
|
||||
match factor {
|
||||
2 => hqx::hq2x(
|
||||
input_image.as_slice(),
|
||||
output_image.as_mut_slice(),
|
||||
input_width,
|
||||
input_height,
|
||||
),
|
||||
3 => hqx::hq3x(
|
||||
input_image.as_slice(),
|
||||
output_image.as_mut_slice(),
|
||||
input_width,
|
||||
input_height,
|
||||
),
|
||||
4 => hqx::hq4x(
|
||||
input_image.as_slice(),
|
||||
output_image.as_mut_slice(),
|
||||
input_width,
|
||||
input_height,
|
||||
),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
return output_image;
|
||||
}
|
17
codecs/hqx/src/utils.rs
Normal file
17
codecs/hqx/src/utils.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||
// `set_panic_hook` function at least once during initialization, and then
|
||||
// we will get better error messages if our code ever panics.
|
||||
//
|
||||
// For more details see
|
||||
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||
if #[cfg(feature = "console_error_panic_hook")] {
|
||||
extern crate console_error_panic_hook;
|
||||
pub use self::console_error_panic_hook::set_once as set_panic_hook;
|
||||
} else {
|
||||
#[inline]
|
||||
pub fn set_panic_hook() {}
|
||||
}
|
||||
}
|
641
codecs/imagequant/LICENSE.codec.md
Normal file
641
codecs/imagequant/LICENSE.codec.md
Normal file
@ -0,0 +1,641 @@
|
||||
|
||||
libimagequant is derived from code by Jef Poskanzer and Greg Roelofs
|
||||
licensed under pngquant's original license (at the end of this file),
|
||||
and contains extensive changes and additions by Kornel Lesiński
|
||||
licensed under GPL v3 or later.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
libimagequant © 2009-2018 by Kornel Lesiński.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
© 1989, 1991 by Jef Poskanzer.
|
||||
© 1997, 2000, 2002 by Greg Roelofs.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation. This software is provided "as is" without express or
|
||||
implied warranty.
|
40
codecs/imagequant/Makefile
Normal file
40
codecs/imagequant/Makefile
Normal file
@ -0,0 +1,40 @@
|
||||
CODEC_URL := https://github.com/ImageOptim/libimagequant/archive/2.12.1.tar.gz
|
||||
CODEC_DIR := node_modules/libimagequant
|
||||
CODEC_OUT_RELATIVE := libimagequant.a
|
||||
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
||||
OUT_JS := imagequant.js
|
||||
OUT_WASM := $(OUT_JS:.js=.wasm)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_JS)
|
||||
|
||||
%.js: %.cpp $(CODEC_OUT)
|
||||
$(CXX) \
|
||||
-I $(CODEC_DIR) \
|
||||
${CXXFLAGS} \
|
||||
${LDFLAGS} \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||
-o $@ \
|
||||
$+
|
||||
|
||||
$(CODEC_OUT): $(CODEC_DIR)/config.mk
|
||||
$(MAKE) -C $(CODEC_DIR) $(CODEC_OUT_RELATIVE)
|
||||
|
||||
$(CODEC_DIR)/config.mk: $(CODEC_DIR)/configure
|
||||
cd $(CODEC_DIR) && ./configure \
|
||||
--disable-sse
|
||||
|
||||
$(CODEC_DIR)/configure: $(CODEC_DIR)
|
||||
|
||||
$(CODEC_DIR):
|
||||
mkdir -p $@
|
||||
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
|
||||
|
||||
clean:
|
||||
$(RM) $(OUT_JS) $(OUT_WASM)
|
||||
$(MAKE) -C $(CODEC_DIR) clean
|
@ -2,6 +2,7 @@
|
||||
|
||||
- Source: <https://github.com/ImageOptim/libimagequant>
|
||||
- Version: v2.12.1
|
||||
- License: GPL3
|
||||
|
||||
## Dependencies
|
||||
|
||||
@ -24,7 +25,3 @@ Quantizes the given images, using at most `numColors`, a value between 2 and 256
|
||||
### `RawImage zx_quantize(std::string buffer, int image_width, int image_height, float dithering)`
|
||||
|
||||
???
|
||||
|
||||
### `void free_result()`
|
||||
|
||||
Frees the result created by `quantize()`.
|
||||
|
@ -1,48 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export OPTIMIZE="-Os"
|
||||
export LDFLAGS="${OPTIMIZE}"
|
||||
export CFLAGS="${OPTIMIZE}"
|
||||
export CPPFLAGS="${OPTIMIZE}"
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling libimagequant"
|
||||
echo "============================================="
|
||||
(
|
||||
emcc \
|
||||
--bind \
|
||||
${OPTIMIZE} \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="imagequant"' \
|
||||
-I node_modules/libimagequant \
|
||||
--std=c99 \
|
||||
-c \
|
||||
node_modules/libimagequant/{libimagequant,pam,mediancut,blur,mempool,kmeans,nearest}.c
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling wasm module"
|
||||
echo "============================================="
|
||||
(
|
||||
emcc \
|
||||
--bind \
|
||||
${OPTIMIZE} \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="imagequant"' \
|
||||
-I node_modules/libimagequant \
|
||||
-o ./imagequant.js \
|
||||
--std=c++11 *.o \
|
||||
-x c++ \
|
||||
imagequant.cpp
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling wasm module done"
|
||||
echo "============================================="
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Did you update your docker image?"
|
||||
echo "Run \`docker pull trzeci/emscripten\`"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -28,9 +28,8 @@
|
||||
// const rawImage = Module.quantize(image.data, image.width, image.height, 256, 1.0);
|
||||
const rawImage = Module.zx_quantize(image.data, image.width, image.height, 1.0);
|
||||
console.log('done');
|
||||
Module.free_result();
|
||||
|
||||
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), rawImage.width, rawImage.height);
|
||||
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), image.width, image.height);
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = image.width;
|
||||
canvas.height = image.height;
|
||||
|
@ -1,95 +1,87 @@
|
||||
#include "emscripten/bind.h"
|
||||
#include "emscripten/val.h"
|
||||
#include <stdlib.h>
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libimagequant.h"
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
int version() {
|
||||
return (((LIQ_VERSION/10000) % 100) << 16) |
|
||||
(((LIQ_VERSION/100 ) % 100) << 8) |
|
||||
(((LIQ_VERSION/1 ) % 100) << 0);
|
||||
return (((LIQ_VERSION / 10000) % 100) << 16) | (((LIQ_VERSION / 100) % 100) << 8) |
|
||||
(((LIQ_VERSION / 1) % 100) << 0);
|
||||
}
|
||||
|
||||
class RawImage {
|
||||
public:
|
||||
val buffer;
|
||||
int width;
|
||||
int height;
|
||||
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
|
||||
|
||||
RawImage(val b, int w, int h)
|
||||
: buffer(b), width(w), height(h) {}
|
||||
};
|
||||
#define liq_ptr(T) std::unique_ptr<T, std::integral_constant<decltype(&T##_destroy), T##_destroy>>
|
||||
|
||||
using liq_attr_ptr = liq_ptr(liq_attr);
|
||||
using liq_image_ptr = liq_ptr(liq_image);
|
||||
using liq_result_ptr = liq_ptr(liq_result);
|
||||
|
||||
liq_attr *attr;
|
||||
liq_image *image;
|
||||
liq_result *res;
|
||||
uint8_t* result;
|
||||
RawImage quantize(std::string rawimage, int image_width, int image_height, int num_colors, float dithering) {
|
||||
const uint8_t* image_buffer = (uint8_t*)rawimage.c_str();
|
||||
int size = image_width * image_height;
|
||||
attr = liq_attr_create();
|
||||
image = liq_image_create_rgba(attr, image_buffer, image_width, image_height, 0);
|
||||
liq_set_max_colors(attr, num_colors);
|
||||
liq_result_ptr liq_image_quantize(liq_image* image, liq_attr* attr) {
|
||||
liq_result* res = nullptr;
|
||||
liq_image_quantize(image, attr, &res);
|
||||
liq_set_dithering_level(res, dithering);
|
||||
uint8_t* image8bit = (uint8_t*) malloc(size);
|
||||
result = (uint8_t*) malloc(size * 4);
|
||||
liq_write_remapped_image(res, image, image8bit, size);
|
||||
const liq_palette *pal = liq_get_palette(res);
|
||||
return liq_result_ptr(res);
|
||||
}
|
||||
|
||||
val quantize(std::string rawimage,
|
||||
int image_width,
|
||||
int image_height,
|
||||
int num_colors,
|
||||
float dithering) {
|
||||
auto image_buffer = (const liq_color*)rawimage.c_str();
|
||||
int size = image_width * image_height;
|
||||
liq_attr_ptr attr(liq_attr_create());
|
||||
liq_image_ptr image(
|
||||
liq_image_create_rgba(attr.get(), image_buffer, image_width, image_height, 0));
|
||||
liq_set_max_colors(attr.get(), num_colors);
|
||||
auto res = liq_image_quantize(image.get(), attr.get());
|
||||
liq_set_dithering_level(res.get(), dithering);
|
||||
std::vector<uint8_t> image8bit(size);
|
||||
std::vector<liq_color> result(size);
|
||||
liq_write_remapped_image(res.get(), image.get(), image8bit.data(), image8bit.size());
|
||||
auto pal = liq_get_palette(res.get());
|
||||
// Turn palletted image back into an RGBA image
|
||||
for(int i = 0; i < size; i++) {
|
||||
result[i * 4 + 0] = pal->entries[image8bit[i]].r;
|
||||
result[i * 4 + 1] = pal->entries[image8bit[i]].g;
|
||||
result[i * 4 + 2] = pal->entries[image8bit[i]].b;
|
||||
result[i * 4 + 3] = pal->entries[image8bit[i]].a;
|
||||
for (int i = 0; i < size; i++) {
|
||||
result[i] = pal->entries[image8bit[i]];
|
||||
}
|
||||
free(image8bit);
|
||||
liq_result_destroy(res);
|
||||
liq_image_destroy(image);
|
||||
liq_attr_destroy(attr);
|
||||
return {
|
||||
val(typed_memory_view(image_width*image_height*4, result)),
|
||||
image_width,
|
||||
image_height
|
||||
};
|
||||
return Uint8ClampedArray.new_(
|
||||
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
|
||||
}
|
||||
|
||||
const liq_color zx_colors[] = {
|
||||
{.a = 255, .r = 0, .g = 0, .b = 0}, // regular black
|
||||
{.a = 255, .r = 0, .g = 0, .b = 215}, // regular blue
|
||||
{.a = 255, .r = 215, .g = 0, .b = 0}, // regular red
|
||||
{.a = 255, .r = 215, .g = 0, .b = 215}, // regular magenta
|
||||
{.a = 255, .r = 0, .g = 215, .b = 0}, // regular green
|
||||
{.a = 255, .r = 0, .g = 215, .b = 215}, // regular cyan
|
||||
{.a = 255, .r = 215, .g = 215, .b = 0}, // regular yellow
|
||||
{.a = 255, .r = 215, .g = 215, .b = 215}, // regular white
|
||||
{.a = 255, .r = 0, .g = 0, .b = 255}, // bright blue
|
||||
{.a = 255, .r = 255, .g = 0, .b = 0}, // bright red
|
||||
{.a = 255, .r = 255, .g = 0, .b = 255}, // bright magenta
|
||||
{.a = 255, .r = 0, .g = 255, .b = 0}, // bright green
|
||||
{.a = 255, .r = 0, .g = 255, .b = 255}, // bright cyan
|
||||
{.a = 255, .r = 255, .g = 255, .b = 0}, // bright yellow
|
||||
{.a = 255, .r = 255, .g = 255, .b = 255} // bright white
|
||||
{.r = 0, .g = 0, .b = 0, .a = 255}, // regular black
|
||||
{.r = 0, .g = 0, .b = 215, .a = 255}, // regular blue
|
||||
{.r = 215, .g = 0, .b = 0, .a = 255}, // regular red
|
||||
{.r = 215, .g = 0, .b = 215, .a = 255}, // regular magenta
|
||||
{.r = 0, .g = 215, .b = 0, .a = 255}, // regular green
|
||||
{.r = 0, .g = 215, .b = 215, .a = 255}, // regular cyan
|
||||
{.r = 215, .g = 215, .b = 0, .a = 255}, // regular yellow
|
||||
{.r = 215, .g = 215, .b = 215, .a = 255}, // regular white
|
||||
{.r = 0, .g = 0, .b = 255, .a = 255}, // bright blue
|
||||
{.r = 255, .g = 0, .b = 0, .a = 255}, // bright red
|
||||
{.r = 255, .g = 0, .b = 255, .a = 255}, // bright magenta
|
||||
{.r = 0, .g = 255, .b = 0, .a = 255}, // bright green
|
||||
{.r = 0, .g = 255, .b = 255, .a = 255}, // bright cyan
|
||||
{.r = 255, .g = 255, .b = 0, .a = 255}, // bright yellow
|
||||
{.r = 255, .g = 255, .b = 255, .a = 255} // bright white
|
||||
};
|
||||
|
||||
uint8_t block[8 * 8 * 4];
|
||||
|
||||
/**
|
||||
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The two colours must
|
||||
* both be 'regular' or 'bright'. Black exists as both regular and bright.
|
||||
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The
|
||||
* two colours must both be 'regular' or 'bright'. Black exists as both regular
|
||||
* and bright.
|
||||
*/
|
||||
RawImage zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
|
||||
const uint8_t* image_buffer = (uint8_t*) rawimage.c_str();
|
||||
val zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
|
||||
auto image_buffer = (const liq_color*)rawimage.c_str();
|
||||
int size = image_width * image_height;
|
||||
int bytes_per_pixel = 4;
|
||||
result = (uint8_t*) malloc(size * bytes_per_pixel);
|
||||
uint8_t* image8bit = (uint8_t*) malloc(8 * 8);
|
||||
liq_color block[8 * 8];
|
||||
uint8_t image8bit[8 * 8];
|
||||
std::vector<liq_color> result(size);
|
||||
|
||||
// For each 8x8 grid
|
||||
for (int block_start_y = 0; block_start_y < image_height; block_start_y += 8) {
|
||||
@ -99,7 +91,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
int block_width = 8;
|
||||
int block_height = 8;
|
||||
|
||||
// If the block hangs off the right/bottom of the image dimensions, make it smaller to fit.
|
||||
// If the block hangs off the right/bottom of the image dimensions, make
|
||||
// it smaller to fit.
|
||||
if (block_start_y + block_height > image_height) {
|
||||
block_height = image_height - block_start_y;
|
||||
}
|
||||
@ -111,26 +104,22 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
// For each pixel in that block:
|
||||
for (int y = block_start_y; y < block_start_y + block_height; y++) {
|
||||
for (int x = block_start_x; x < block_start_x + block_width; x++) {
|
||||
int pixel_start = (y * image_width * bytes_per_pixel) + (x * bytes_per_pixel);
|
||||
int pixel_start = (y * image_width) + x;
|
||||
int smallest_distance = INT_MAX;
|
||||
int winning_index = -1;
|
||||
|
||||
// Copy pixel data for quantizing later
|
||||
block[block_index++] = image_buffer[pixel_start];
|
||||
block[block_index++] = image_buffer[pixel_start + 1];
|
||||
block[block_index++] = image_buffer[pixel_start + 2];
|
||||
block[block_index++] = image_buffer[pixel_start + 3];
|
||||
|
||||
// Which zx color is this pixel closest to?
|
||||
for (int color_index = 0; color_index < 15; color_index++) {
|
||||
liq_color color = zx_colors[color_index];
|
||||
liq_color pixel = image_buffer[pixel_start];
|
||||
|
||||
// Using Euclidean distance. LibQuant has better methods, but it requires conversion to
|
||||
// LAB, so I don't think it's worth it.
|
||||
// Using Euclidean distance. LibQuant has better methods, but it
|
||||
// requires conversion to LAB, so I don't think it's worth it.
|
||||
int distance =
|
||||
pow(color.r - image_buffer[pixel_start + 0], 2) +
|
||||
pow(color.g - image_buffer[pixel_start + 1], 2) +
|
||||
pow(color.b - image_buffer[pixel_start + 2], 2);
|
||||
pow(color.r - pixel.r, 2) + pow(color.g - pixel.g, 2) + pow(color.b - pixel.b, 2);
|
||||
|
||||
if (distance < smallest_distance) {
|
||||
winning_index = color_index;
|
||||
@ -151,7 +140,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
|
||||
for (int color_index = 0; color_index < 15; color_index++) {
|
||||
if (color_popularity[color_index] > highest_popularity) {
|
||||
// Store this as the most popular pixel, and demote the current values:
|
||||
// Store this as the most popular pixel, and demote the current
|
||||
// values:
|
||||
third_color_index = second_color_index;
|
||||
third_highest_popularity = second_highest_popularity;
|
||||
second_color_index = first_color_index;
|
||||
@ -169,8 +159,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
}
|
||||
}
|
||||
|
||||
// ZX images can't mix bright and regular colours, except black which appears in both.
|
||||
// Resolve any conflict:
|
||||
// ZX images can't mix bright and regular colours, except black which
|
||||
// appears in both. Resolve any conflict:
|
||||
while (1) {
|
||||
// If either colour is black, there's no conflict to resolve.
|
||||
if (first_color_index != 0 && second_color_index != 0) {
|
||||
@ -183,63 +173,44 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
}
|
||||
}
|
||||
|
||||
// If, during conflict resolving, we now have two of the same colour (because we initially
|
||||
// selected the bright & regular version of the same colour), retry again with the third
|
||||
// most popular colour.
|
||||
// If, during conflict resolving, we now have two of the same colour
|
||||
// (because we initially selected the bright & regular version of the
|
||||
// same colour), retry again with the third most popular colour.
|
||||
if (first_color_index == second_color_index) {
|
||||
second_color_index = third_color_index;
|
||||
} else break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
// Quantize
|
||||
attr = liq_attr_create();
|
||||
image = liq_image_create_rgba(attr, block, block_width, block_height, 0);
|
||||
liq_set_max_colors(attr, 2);
|
||||
liq_image_add_fixed_color(image, zx_colors[first_color_index]);
|
||||
liq_image_add_fixed_color(image, zx_colors[second_color_index]);
|
||||
liq_image_quantize(image, attr, &res);
|
||||
liq_set_dithering_level(res, dithering);
|
||||
liq_write_remapped_image(res, image, image8bit, size);
|
||||
const liq_palette *pal = liq_get_palette(res);
|
||||
liq_attr_ptr attr(liq_attr_create());
|
||||
liq_image_ptr image(liq_image_create_rgba(attr.get(), block, block_width, block_height, 0));
|
||||
liq_set_max_colors(attr.get(), 2);
|
||||
liq_image_add_fixed_color(image.get(), zx_colors[first_color_index]);
|
||||
liq_image_add_fixed_color(image.get(), zx_colors[second_color_index]);
|
||||
auto res = liq_image_quantize(image.get(), attr.get());
|
||||
liq_set_dithering_level(res.get(), dithering);
|
||||
liq_write_remapped_image(res.get(), image.get(), image8bit, size);
|
||||
auto pal = liq_get_palette(res.get());
|
||||
|
||||
// Turn palletted image back into an RGBA image, and write it into the full size result image.
|
||||
for(int y = 0; y < block_height; y++) {
|
||||
for(int x = 0; x < block_width; x++) {
|
||||
// Turn palletted image back into an RGBA image, and write it into the
|
||||
// full size result image.
|
||||
for (int y = 0; y < block_height; y++) {
|
||||
for (int x = 0; x < block_width; x++) {
|
||||
int image8BitPos = y * block_width + x;
|
||||
int resultStartPos = ((block_start_y + y) * bytes_per_pixel * image_width) + ((block_start_x + x) * bytes_per_pixel);
|
||||
result[resultStartPos + 0] = pal->entries[image8bit[image8BitPos]].r;
|
||||
result[resultStartPos + 1] = pal->entries[image8bit[image8BitPos]].g;
|
||||
result[resultStartPos + 2] = pal->entries[image8bit[image8BitPos]].b;
|
||||
result[resultStartPos + 3] = pal->entries[image8bit[image8BitPos]].a;
|
||||
int resultStartPos = ((block_start_y + y) * image_width) + (block_start_x + x);
|
||||
result[resultStartPos] = pal->entries[image8bit[image8BitPos]];
|
||||
}
|
||||
}
|
||||
|
||||
liq_result_destroy(res);
|
||||
liq_image_destroy(image);
|
||||
liq_attr_destroy(attr);
|
||||
}
|
||||
}
|
||||
|
||||
free(image8bit);
|
||||
return {
|
||||
val(typed_memory_view(image_width*image_height*4, result)),
|
||||
image_width,
|
||||
image_height
|
||||
};
|
||||
}
|
||||
|
||||
void free_result() {
|
||||
free(result);
|
||||
return Uint8ClampedArray.new_(
|
||||
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
class_<RawImage>("RawImage")
|
||||
.property("buffer", &RawImage::buffer)
|
||||
.property("width", &RawImage::width)
|
||||
.property("height", &RawImage::height);
|
||||
|
||||
function("quantize", &quantize);
|
||||
function("zx_quantize", &zx_quantize);
|
||||
function("version", &version);
|
||||
function("free_result", &free_result);
|
||||
}
|
||||
|
15
codecs/imagequant/imagequant.d.ts
vendored
15
codecs/imagequant/imagequant.d.ts
vendored
@ -1,15 +1,6 @@
|
||||
interface RawImage {
|
||||
buffer: Uint8Array;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface QuantizerModule extends EmscriptenWasm.Module {
|
||||
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): RawImage;
|
||||
zx_quantize(data: BufferSource, width: number, height: number, dither: number): RawImage;
|
||||
free_result(): void;
|
||||
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): Uint8ClampedArray;
|
||||
zx_quantize(data: BufferSource, width: number, height: number, dither: number): Uint8ClampedArray;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule;
|
||||
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<QuantizerModule>;
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
1145
codecs/imagequant/package-lock.json
generated
1145
codecs/imagequant/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,6 @@
|
||||
{
|
||||
"name": "imagequant",
|
||||
"scripts": {
|
||||
"install": "napa",
|
||||
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
|
||||
},
|
||||
"napa": {
|
||||
"libimagequant": "ImageOptim/libimagequant#2.12.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"napa": "^3.0.0"
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
||||
|
132
codecs/mozjpeg_enc/LICENSE.codec.md
Normal file
132
codecs/mozjpeg_enc/LICENSE.codec.md
Normal file
@ -0,0 +1,132 @@
|
||||
libjpeg-turbo Licenses
|
||||
======================
|
||||
|
||||
libjpeg-turbo is covered by three compatible BSD-style open source licenses:
|
||||
|
||||
- The IJG (Independent JPEG Group) License, which is listed in
|
||||
[README.ijg](README.ijg)
|
||||
|
||||
This license applies to the libjpeg API library and associated programs
|
||||
(any code inherited from libjpeg, and any modifications to that code.)
|
||||
|
||||
- The Modified (3-clause) BSD License, which is listed below
|
||||
|
||||
This license covers the TurboJPEG API library and associated programs, as
|
||||
well as the build system.
|
||||
|
||||
- The [zlib License](https://opensource.org/licenses/Zlib)
|
||||
|
||||
This license is a subset of the other two, and it covers the libjpeg-turbo
|
||||
SIMD extensions.
|
||||
|
||||
|
||||
Complying with the libjpeg-turbo Licenses
|
||||
=========================================
|
||||
|
||||
This section provides a roll-up of the libjpeg-turbo licensing terms, to the
|
||||
best of our understanding.
|
||||
|
||||
1. If you are distributing a modified version of the libjpeg-turbo source,
|
||||
then:
|
||||
|
||||
1. You cannot alter or remove any existing copyright or license notices
|
||||
from the source.
|
||||
|
||||
**Origin**
|
||||
- Clause 1 of the IJG License
|
||||
- Clause 1 of the Modified BSD License
|
||||
- Clauses 1 and 3 of the zlib License
|
||||
|
||||
2. You must add your own copyright notice to the header of each source
|
||||
file you modified, so others can tell that you modified that file (if
|
||||
there is not an existing copyright header in that file, then you can
|
||||
simply add a notice stating that you modified the file.)
|
||||
|
||||
**Origin**
|
||||
- Clause 1 of the IJG License
|
||||
- Clause 2 of the zlib License
|
||||
|
||||
3. You must include the IJG README file, and you must not alter any of the
|
||||
copyright or license text in that file.
|
||||
|
||||
**Origin**
|
||||
- Clause 1 of the IJG License
|
||||
|
||||
2. If you are distributing only libjpeg-turbo binaries without the source, or
|
||||
if you are distributing an application that statically links with
|
||||
libjpeg-turbo, then:
|
||||
|
||||
1. Your product documentation must include a message stating:
|
||||
|
||||
This software is based in part on the work of the Independent JPEG
|
||||
Group.
|
||||
|
||||
**Origin**
|
||||
- Clause 2 of the IJG license
|
||||
|
||||
2. If your binary distribution includes or uses the TurboJPEG API, then
|
||||
your product documentation must include the text of the Modified BSD
|
||||
License (see below.)
|
||||
|
||||
**Origin**
|
||||
- Clause 2 of the Modified BSD License
|
||||
|
||||
3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
|
||||
contributors thereof in advertising, publicity, etc.
|
||||
|
||||
**Origin**
|
||||
- IJG License
|
||||
- Clause 3 of the Modified BSD License
|
||||
|
||||
4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
|
||||
free of defects, nor do we accept any liability for undesirable
|
||||
consequences resulting from your use of the software.
|
||||
|
||||
**Origin**
|
||||
- IJG License
|
||||
- Modified BSD License
|
||||
- zlib License
|
||||
|
||||
|
||||
The Modified (3-clause) BSD License
|
||||
===================================
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
Why Three Licenses?
|
||||
===================
|
||||
|
||||
The zlib License could have been used instead of the Modified (3-clause) BSD
|
||||
License, and since the IJG License effectively subsumes the distribution
|
||||
conditions of the zlib License, this would have effectively placed
|
||||
libjpeg-turbo binary distributions under the IJG License. However, the IJG
|
||||
License specifically refers to the Independent JPEG Group and does not extend
|
||||
attribution and endorsement protections to other entities. Thus, it was
|
||||
desirable to choose a license that granted us the same protections for new code
|
||||
that were granted to the IJG for code derived from their software.
|
52
codecs/mozjpeg_enc/Makefile
Normal file
52
codecs/mozjpeg_enc/Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
CODEC_URL := https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz
|
||||
CODEC_DIR := node_modules/mozjpeg
|
||||
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
|
||||
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
||||
OUT_JS := mozjpeg_enc.js
|
||||
OUT_WASM := $(OUT_JS:.js=.wasm)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_JS)
|
||||
|
||||
%.js: %.cpp $(CODEC_OUT)
|
||||
$(CXX) \
|
||||
-I $(CODEC_DIR) \
|
||||
${CXXFLAGS} \
|
||||
${LDFLAGS} \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||
-o $@ \
|
||||
$+
|
||||
|
||||
# This one is a bit special: there is no rule for .libs/libjpeg.a
|
||||
# so we use libjpeg.la which implicitly builds that one instead.
|
||||
$(CODEC_DIR)/.libs/libjpeg.a: $(CODEC_DIR)/Makefile
|
||||
$(MAKE) -C $(CODEC_DIR) libjpeg.la
|
||||
|
||||
$(CODEC_DIR)/rdswitch.o: $(CODEC_DIR)/Makefile
|
||||
$(MAKE) -C $(CODEC_DIR) rdswitch.o
|
||||
|
||||
$(CODEC_DIR)/Makefile: $(CODEC_DIR)/configure
|
||||
cd $(CODEC_DIR) && ./configure \
|
||||
--disable-shared \
|
||||
--without-turbojpeg \
|
||||
--without-simd \
|
||||
--without-arith-enc \
|
||||
--without-arith-dec
|
||||
|
||||
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
|
||||
cd $(CODEC_DIR) && autoreconf -iv
|
||||
|
||||
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
|
||||
|
||||
$(CODEC_DIR):
|
||||
mkdir -p $@
|
||||
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
|
||||
|
||||
clean:
|
||||
$(RM) $(OUT_JS) $(OUT_WASM)
|
||||
$(MAKE) -C $(CODEC_DIR) clean
|
@ -2,6 +2,7 @@
|
||||
|
||||
- Source: <https://github.com/mozilla/mozjpeg>
|
||||
- Version: v3.3.1
|
||||
- License: BSD
|
||||
|
||||
## Dependencies
|
||||
|
||||
@ -17,10 +18,6 @@ See `example.html`
|
||||
|
||||
Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c
|
||||
|
||||
### `void free_result()`
|
||||
|
||||
Frees the result created by `encode()`.
|
||||
|
||||
### `Uint8Array encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts)`
|
||||
|
||||
Encodes the given image with given dimension to JPEG. Options looks like this:
|
||||
|
@ -1,53 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export OPTIMIZE="-Os"
|
||||
export LDFLAGS="${OPTIMIZE}"
|
||||
export CFLAGS="${OPTIMIZE}"
|
||||
export CPPFLAGS="${OPTIMIZE}"
|
||||
|
||||
apt-get update
|
||||
apt-get install -qqy autoconf libtool libpng-dev pkg-config
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling mozjpeg"
|
||||
echo "============================================="
|
||||
(
|
||||
cd node_modules/mozjpeg
|
||||
autoreconf -fiv
|
||||
emconfigure ./configure --without-simd
|
||||
emmake make libjpeg.la
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling mozjpeg done"
|
||||
echo "============================================="
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling wasm bindings"
|
||||
echo "============================================="
|
||||
(
|
||||
emcc \
|
||||
--bind \
|
||||
${OPTIMIZE} \
|
||||
-s WASM=1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="mozjpeg_enc"' \
|
||||
-I node_modules/mozjpeg \
|
||||
-o ./mozjpeg_enc.js \
|
||||
-Wno-deprecated-register \
|
||||
-Wno-writable-strings \
|
||||
node_modules/mozjpeg/rdswitch.c \
|
||||
-x c++ -std=c++11 \
|
||||
mozjpeg_enc.cpp \
|
||||
node_modules/mozjpeg/.libs/libjpeg.a
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling wasm bindings done"
|
||||
echo "============================================="
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Did you update your docker image?"
|
||||
echo "Run \`docker pull trzeci/emscripten\`"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -1,18 +1,22 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "jpeglib.h"
|
||||
|
||||
extern "C" {
|
||||
#include "cdjpeg.h"
|
||||
}
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
// MozJPEG doesn’t expose a numeric version, so I have to do some fun C macro hackery to turn it
|
||||
// into a string. More details here: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
|
||||
// MozJPEG doesn’t expose a numeric version, so I have to do some fun C macro
|
||||
// hackery to turn it into a string. More details here:
|
||||
// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
|
||||
#define xstr(s) str(s)
|
||||
#define str(s) #s
|
||||
|
||||
@ -39,8 +43,8 @@ int version() {
|
||||
char buffer[] = xstr(MOZJPEG_VERSION);
|
||||
int version = 0;
|
||||
int last_index = 0;
|
||||
for(int i = 0; i < strlen(buffer); i++) {
|
||||
if(buffer[i] == '.') {
|
||||
for (int i = 0; i < strlen(buffer); i++) {
|
||||
if (buffer[i] == '.') {
|
||||
buffer[i] = '\0';
|
||||
version = version << 8 | atoi(&buffer[last_index]);
|
||||
buffer[i] = '.';
|
||||
@ -51,16 +55,16 @@ int version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
uint8_t* last_result;
|
||||
struct jpeg_compress_struct cinfo;
|
||||
thread_local const val Uint8Array = val::global("Uint8Array");
|
||||
|
||||
val encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts) {
|
||||
uint8_t* image_buffer = (uint8_t*) image_in.c_str();
|
||||
uint8_t* image_buffer = (uint8_t*)image_in.c_str();
|
||||
|
||||
// The code below is basically the `write_JPEG_file` function from
|
||||
// https://github.com/mozilla/mozjpeg/blob/master/example.c
|
||||
// I just write to memory instead of a file.
|
||||
|
||||
/* Step 1: allocate and initialize JPEG compression object */
|
||||
|
||||
/* This struct contains the JPEG compression parameters and pointers to
|
||||
* working space (which is allocated as needed by the JPEG library).
|
||||
@ -68,6 +72,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
* compression/decompression processes, in existence at once. We refer
|
||||
* to any one struct (and its associated working data) as a "JPEG object".
|
||||
*/
|
||||
jpeg_compress_struct cinfo;
|
||||
/* This struct represents a JPEG error handler. It is declared separately
|
||||
* because applications often want to supply a specialized error handler
|
||||
* (see the second half of this file for an example). But here we just
|
||||
@ -76,15 +81,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
* Note that this struct must live as long as the main JPEG parameter
|
||||
* struct, to avoid dangling-pointer problems.
|
||||
*/
|
||||
struct jpeg_error_mgr jerr;
|
||||
/* More stuff */
|
||||
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
|
||||
int row_stride; /* physical row width in image buffer */
|
||||
uint8_t* output;
|
||||
unsigned long size;
|
||||
|
||||
/* Step 1: allocate and initialize JPEG compression object */
|
||||
|
||||
jpeg_error_mgr jerr;
|
||||
/* We have to set up the error handler first, in case the initialization
|
||||
* step fails. (Unlikely, but it could happen if you are out of memory.)
|
||||
* This routine fills in the contents of struct jerr, and returns jerr's
|
||||
@ -106,6 +103,8 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
// fprintf(stderr, "can't open %s\n", filename);
|
||||
// exit(1);
|
||||
// }
|
||||
uint8_t* output = nullptr;
|
||||
unsigned long size = 0;
|
||||
jpeg_mem_dest(&cinfo, &output, &size);
|
||||
|
||||
/* Step 3: set parameters for compression */
|
||||
@ -113,17 +112,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
/* First we supply a description of the input image.
|
||||
* Four fields of the cinfo struct must be filled in:
|
||||
*/
|
||||
cinfo.image_width = image_width; /* image width and height, in pixels */
|
||||
cinfo.image_width = image_width; /* image width and height, in pixels */
|
||||
cinfo.image_height = image_height;
|
||||
cinfo.input_components = 4; /* # of color components per pixel */
|
||||
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
|
||||
cinfo.input_components = 4; /* # of color components per pixel */
|
||||
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
|
||||
/* Now use the library's routine to set default compression parameters.
|
||||
* (You must set at least cinfo.in_color_space before calling this,
|
||||
* since the defaults depend on the source color space.)
|
||||
*/
|
||||
jpeg_set_defaults(&cinfo);
|
||||
|
||||
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE) opts.color_space);
|
||||
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE)opts.color_space);
|
||||
|
||||
if (opts.quant_table != -1) {
|
||||
jpeg_c_set_int_param(&cinfo, JINT_BASE_QUANT_TBL_IDX, opts.quant_table);
|
||||
@ -143,17 +142,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_TRELLIS_Q_OPT, opts.trellis_opt_table);
|
||||
jpeg_c_set_int_param(&cinfo, JINT_TRELLIS_NUM_LOOPS, opts.trellis_loops);
|
||||
|
||||
// A little hacky to build a string for this, but it means we can use set_quality_ratings which
|
||||
// does some useful heuristic stuff.
|
||||
// A little hacky to build a string for this, but it means we can use
|
||||
// set_quality_ratings which does some useful heuristic stuff.
|
||||
std::string quality_str = std::to_string(opts.quality);
|
||||
|
||||
if (opts.separate_chroma_quality && opts.color_space == JCS_YCbCr) {
|
||||
quality_str += "," + std::to_string(opts.chroma_quality);
|
||||
}
|
||||
|
||||
char const *pqual = quality_str.c_str();
|
||||
char const* pqual = quality_str.c_str();
|
||||
|
||||
set_quality_ratings(&cinfo, (char*) pqual, opts.baseline);
|
||||
set_quality_ratings(&cinfo, (char*)pqual, opts.baseline);
|
||||
|
||||
if (!opts.auto_subsample && opts.color_space == JCS_YCbCr) {
|
||||
cinfo.comp_info[0].h_samp_factor = opts.chroma_subsample;
|
||||
@ -181,54 +180,54 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
* To keep things simple, we pass one scanline per call; you can pass
|
||||
* more if you wish, though.
|
||||
*/
|
||||
row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
|
||||
int row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height) {
|
||||
/* jpeg_write_scanlines expects an array of pointers to scanlines.
|
||||
* Here the array is only one element long, but you could pass
|
||||
* more than one scanline at a time if that's more convenient.
|
||||
*/
|
||||
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
|
||||
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
|
||||
JSAMPROW row_pointer =
|
||||
&image_buffer[cinfo.next_scanline * row_stride]; /* pointer to JSAMPLE row[s] */
|
||||
(void)jpeg_write_scanlines(&cinfo, &row_pointer, 1);
|
||||
}
|
||||
|
||||
/* Step 6: Finish compression */
|
||||
|
||||
jpeg_finish_compress(&cinfo);
|
||||
|
||||
/* Step 7: release JPEG compression object */
|
||||
|
||||
last_result = output;
|
||||
auto js_result = Uint8Array.new_(typed_memory_view(size, output));
|
||||
|
||||
/* And we're done! */
|
||||
return val(typed_memory_view(size, output));
|
||||
}
|
||||
|
||||
void free_result() {
|
||||
/* This is an important step since it will release a good deal of memory. */
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
free(output);
|
||||
|
||||
/* And we're done! */
|
||||
return js_result;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
value_object<MozJpegOptions>("MozJpegOptions")
|
||||
.field("quality", &MozJpegOptions::quality)
|
||||
.field("baseline", &MozJpegOptions::baseline)
|
||||
.field("arithmetic", &MozJpegOptions::arithmetic)
|
||||
.field("progressive", &MozJpegOptions::progressive)
|
||||
.field("optimize_coding", &MozJpegOptions::optimize_coding)
|
||||
.field("smoothing", &MozJpegOptions::smoothing)
|
||||
.field("color_space", &MozJpegOptions::color_space)
|
||||
.field("quant_table", &MozJpegOptions::quant_table)
|
||||
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
|
||||
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
|
||||
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
|
||||
.field("trellis_loops", &MozJpegOptions::trellis_loops)
|
||||
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
|
||||
.field("auto_subsample", &MozJpegOptions::auto_subsample)
|
||||
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
|
||||
.field("chroma_quality", &MozJpegOptions::chroma_quality)
|
||||
;
|
||||
.field("quality", &MozJpegOptions::quality)
|
||||
.field("baseline", &MozJpegOptions::baseline)
|
||||
.field("arithmetic", &MozJpegOptions::arithmetic)
|
||||
.field("progressive", &MozJpegOptions::progressive)
|
||||
.field("optimize_coding", &MozJpegOptions::optimize_coding)
|
||||
.field("smoothing", &MozJpegOptions::smoothing)
|
||||
.field("color_space", &MozJpegOptions::color_space)
|
||||
.field("quant_table", &MozJpegOptions::quant_table)
|
||||
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
|
||||
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
|
||||
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
|
||||
.field("trellis_loops", &MozJpegOptions::trellis_loops)
|
||||
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
|
||||
.field("auto_subsample", &MozJpegOptions::auto_subsample)
|
||||
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
|
||||
.field("chroma_quality", &MozJpegOptions::chroma_quality);
|
||||
|
||||
function("version", &version);
|
||||
function("encode", &encode);
|
||||
function("free_result", &free_result);
|
||||
}
|
||||
|
3
codecs/mozjpeg_enc/mozjpeg_enc.d.ts
vendored
3
codecs/mozjpeg_enc/mozjpeg_enc.d.ts
vendored
@ -2,7 +2,6 @@ import { EncodeOptions } from '../../src/codecs/mozjpeg/encoder-meta';
|
||||
|
||||
interface MozJPEGModule extends EmscriptenWasm.Module {
|
||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
|
||||
free_result(): void;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): MozJPEGModule;
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): Promise<MozJPEGModule>;
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
1145
codecs/mozjpeg_enc/package-lock.json
generated
1145
codecs/mozjpeg_enc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,6 @@
|
||||
{
|
||||
"name": "mozjpeg_enc",
|
||||
"scripts": {
|
||||
"install": "napa",
|
||||
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten ./build.sh"
|
||||
},
|
||||
"napa": {
|
||||
"mozjpeg": "mozilla/mozjpeg#v3.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"napa": "^3.0.0"
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
||||
|
2
codecs/optipng/.gitignore
vendored
2
codecs/optipng/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
build/
|
||||
*.o
|
@ -1,26 +0,0 @@
|
||||
# OptiPNG
|
||||
|
||||
- Source: <https://sourceforge.net/project/optipng>
|
||||
- Version: v0.7.7
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Docker
|
||||
|
||||
## Example
|
||||
|
||||
See `example.html`
|
||||
|
||||
## API
|
||||
|
||||
### `int version()`
|
||||
|
||||
Returns the version of optipng as a number. va.b.c is encoded as 0x0a0b0c
|
||||
|
||||
### `ArrayBuffer compress(std::string buffer, {level})`;
|
||||
|
||||
`compress` will re-compress the given PNG image via `buffer`. `level` is a number between 0 and 7.
|
||||
|
||||
### `void free_result()`
|
||||
|
||||
Frees the result created by `compress()`.
|
@ -1,87 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export OPTIMIZE="-Os"
|
||||
export PREFIX="/src/build"
|
||||
export CFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
|
||||
export CPPFLAGS="${OPTIMIZE} -I${PREFIX}/include/"
|
||||
export LDFLAGS="${OPTIMIZE} -L${PREFIX}/lib/"
|
||||
|
||||
apt-get update
|
||||
apt-get install -qqy autoconf libtool
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling zlib"
|
||||
echo "============================================="
|
||||
test -n "$SKIP_ZLIB" || (
|
||||
cd node_modules/zlib
|
||||
emconfigure ./configure --prefix=${PREFIX}/
|
||||
emmake make
|
||||
emmake make install
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling zlib done"
|
||||
echo "============================================="
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling libpng"
|
||||
echo "============================================="
|
||||
test -n "$SKIP_LIBPNG" || (
|
||||
cd node_modules/libpng
|
||||
autoreconf -i
|
||||
emconfigure ./configure --with-zlib-prefix=${PREFIX}/ --prefix=${PREFIX}/
|
||||
emmake make
|
||||
emmake make install
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling libpng done"
|
||||
echo "============================================="
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling optipng"
|
||||
echo "============================================="
|
||||
(
|
||||
emcc \
|
||||
${OPTIMIZE} \
|
||||
-Wno-implicit-function-declaration \
|
||||
-I ${PREFIX}/include \
|
||||
-I node_modules/optipng/src/opngreduc \
|
||||
-I node_modules/optipng/src/pngxtern \
|
||||
-I node_modules/optipng/src/cexcept \
|
||||
-I node_modules/optipng/src/gifread \
|
||||
-I node_modules/optipng/src/pnmio \
|
||||
-I node_modules/optipng/src/minitiff \
|
||||
--std=c99 -c \
|
||||
node_modules/optipng/src/opngreduc/*.c \
|
||||
node_modules/optipng/src/pngxtern/*.c \
|
||||
node_modules/optipng/src/gifread/*.c \
|
||||
node_modules/optipng/src/minitiff/*.c \
|
||||
node_modules/optipng/src/pnmio/*.c \
|
||||
node_modules/optipng/src/optipng/*.c
|
||||
|
||||
emcc \
|
||||
--bind \
|
||||
${OPTIMIZE} \
|
||||
-s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s 'EXPORT_NAME="optipng"' \
|
||||
-I ${PREFIX}/include \
|
||||
-I node_modules/optipng/src/opngreduc \
|
||||
-I node_modules/optipng/src/pngxtern \
|
||||
-I node_modules/optipng/src/cexcept \
|
||||
-I node_modules/optipng/src/gifread \
|
||||
-I node_modules/optipng/src/pnmio \
|
||||
-I node_modules/optipng/src/minitiff \
|
||||
-o "optipng.js" \
|
||||
--std=c++11 \
|
||||
optipng.cpp \
|
||||
*.o \
|
||||
${PREFIX}/lib/libz.so ${PREFIX}/lib/libpng.a
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling optipng done"
|
||||
echo "============================================="
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Did you update your docker image?"
|
||||
echo "Run \`docker pull trzeci/emscripten\`"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -1,19 +0,0 @@
|
||||
<!doctype html>
|
||||
<script src='optipng.js'></script>
|
||||
<script>
|
||||
const Module = optipng();
|
||||
|
||||
Module.onRuntimeInitialized = async _ => {
|
||||
console.log('Version:', Module.version().toString(16));
|
||||
const image = await fetch('../example_palette.png').then(r => r.arrayBuffer());
|
||||
const newImage = Module.compress(image, {level: 3});
|
||||
console.log('done');
|
||||
Module.free_result();
|
||||
|
||||
console.log(`Old size: ${image.byteLength}, new size: ${newImage.byteLength} (${newImage.byteLength/image.byteLength*100}%)`);
|
||||
const blobURL = URL.createObjectURL(new Blob([newImage], {type: 'image/png'}));
|
||||
const img = document.createElement('img');
|
||||
img.src = blobURL;
|
||||
document.body.appendChild(img);
|
||||
};
|
||||
</script>
|
@ -1,53 +0,0 @@
|
||||
#include "emscripten/bind.h"
|
||||
#include "emscripten/val.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
extern "C" int main(int argc, char *argv[]);
|
||||
|
||||
int version() {
|
||||
// FIXME (@surma): Haven’t found a version in optipng :(
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct OptiPngOpts {
|
||||
int level;
|
||||
};
|
||||
|
||||
uint8_t* result;
|
||||
val compress(std::string png, OptiPngOpts opts) {
|
||||
remove("input.png");
|
||||
remove("output.png");
|
||||
FILE* infile = fopen("input.png", "wb");
|
||||
fwrite(png.c_str(), png.length(), 1, infile);
|
||||
fflush(infile);
|
||||
fclose(infile);
|
||||
|
||||
char optlevel[8];
|
||||
sprintf(&optlevel[0], "-o%d", opts.level);
|
||||
char* args[] = {"optipng", optlevel, "-out", "output.png", "input.png"};
|
||||
main(5, args);
|
||||
|
||||
FILE *outfile = fopen("output.png", "rb");
|
||||
fseek(outfile, 0, SEEK_END);
|
||||
int fsize = ftell(outfile);
|
||||
result = (uint8_t*) malloc(fsize);
|
||||
fseek(outfile, 0, SEEK_SET);
|
||||
fread(result, fsize, 1, outfile);
|
||||
return val(typed_memory_view(fsize, result));
|
||||
}
|
||||
|
||||
void free_result() {
|
||||
free(result);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
value_object<OptiPngOpts>("OptiPngOpts")
|
||||
.field("level", &OptiPngOpts::level);
|
||||
|
||||
function("version", &version);
|
||||
function("compress", &compress);
|
||||
function("free_result", &free_result);
|
||||
}
|
10
codecs/optipng/optipng.d.ts
vendored
10
codecs/optipng/optipng.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import {EncodeOptions} from "src/codecs/optipng/encoder";
|
||||
|
||||
export interface OptiPngModule extends EmscriptenWasm.Module {
|
||||
compress(data: BufferSource, opts: EncodeOptions): Uint8Array;
|
||||
free_result(): void;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): OptiPngModule;
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
1457
codecs/optipng/package-lock.json
generated
1457
codecs/optipng/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "optipng",
|
||||
"scripts": {
|
||||
"install": "tar-dependency install && napa",
|
||||
"build": "npm run build:wasm",
|
||||
"build:wasm": "docker run --rm -v $(pwd):/src -e SKIP_ZLIB=\"${SKIP_ZLIB}\" -e SKIP_LIBPNG=\"${SKIP_LIBPNG}\" trzeci/emscripten ./build.sh"
|
||||
},
|
||||
"tarDependencies": {
|
||||
"node_modules/optipng": {
|
||||
"url": "https://netcologne.dl.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.7/optipng-0.7.7.tar.gz",
|
||||
"strip": 1
|
||||
}
|
||||
},
|
||||
"napa": {
|
||||
"libpng": "emscripten-ports/libpng",
|
||||
"zlib": "emscripten-ports/zlib"
|
||||
},
|
||||
"dependencies": {
|
||||
"napa": "^3.0.0",
|
||||
"tar-dependency": "0.0.3"
|
||||
}
|
||||
}
|
1
codecs/oxipng/.gitignore
vendored
Normal file
1
codecs/oxipng/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
562
codecs/oxipng/Cargo.lock
generated
Normal file
562
codecs/oxipng/Cargo.lock
generated
Normal file
@ -0,0 +1,562 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
|
||||
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
|
||||
[[package]]
|
||||
name = "build_const"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "cloudflare-zlib"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f5ed63a019d55bacd15cadcbcb96bf41b16281417fff393bdb55fa84255fe4b9"
|
||||
dependencies = [
|
||||
"cloudflare-zlib-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cloudflare-zlib-sys"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e195cb274a0d6ee87e718838a09baecd7cbc9f6075dac256a84cb5842739c06"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
|
||||
dependencies = [
|
||||
"build_const",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
"maybe-uninit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"maybe-uninit",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deflate"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.23.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "974e194911d1f7efe3cd8a8f9db3b767e43536327e899e8bc9a12ef5711b74d2"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
|
||||
|
||||
[[package]]
|
||||
name = "libdeflate-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21e39efa87b84db3e13ff4e2dfac1e57220abcbd7fe8ec44d238f7f4f787cc1f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libdeflater"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4810980d791f26d470e2d7d91a3d4d22aa3a4b709fb7e9c5e43ee54f83a01f2"
|
||||
dependencies = [
|
||||
"libdeflate-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-uninit"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad"
|
||||
|
||||
[[package]]
|
||||
name = "oxipng"
|
||||
version = "3.0.1"
|
||||
source = "git+https://github.com/RReverser/oxipng?branch=crossbeam#0df4a32921f7b88d2be4649deb1b6fb7e5707ad8"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
"byteorder",
|
||||
"cloudflare-zlib",
|
||||
"crc",
|
||||
"crossbeam-channel",
|
||||
"image",
|
||||
"indexmap",
|
||||
"itertools",
|
||||
"libdeflater",
|
||||
"log",
|
||||
"miniz_oxide 0.4.2",
|
||||
"rayon",
|
||||
"rgb",
|
||||
"rustc_version",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.16.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crc32fast",
|
||||
"deflate",
|
||||
"miniz_oxide 0.3.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf6960dc9a5b4ee8d3e4c5787b4a112a8818e0290a42ff664ad60692fdf2032"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"crossbeam-deque",
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "287f3c3f8236abb92d8b7e36797f19159df4b58f0a658cc3fb6dd3004b1f3bd3"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "squoosh-oxipng"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"log",
|
||||
"once_cell",
|
||||
"oxipng",
|
||||
"rayon",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typed-arena"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
|
||||
|
||||
[[package]]
|
||||
name = "zopfli"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4079b79464426ade2a1b0177fb0ce8396ba6b4084267407e333573c666073964"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
"byteorder",
|
||||
"crc",
|
||||
"typed-arena",
|
||||
]
|
31
codecs/oxipng/Cargo.toml
Normal file
31
codecs/oxipng/Cargo.toml
Normal file
@ -0,0 +1,31 @@
|
||||
[package]
|
||||
name = "squoosh-oxipng"
|
||||
version = "0.1.0"
|
||||
authors = ["Ingvar Stepanyan <me@rreverser.com>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
oxipng = { version = "3.0.0", default-features = false }
|
||||
wasm-bindgen = "0.2.64"
|
||||
log = { version = "0.4", features = ["release_max_level_off"] }
|
||||
rayon = { version = "1.3.0", optional = true }
|
||||
once_cell = { version = "1.3.1", optional = true }
|
||||
crossbeam-channel = { version = "0.4.2", optional = true }
|
||||
|
||||
[patch.crates-io]
|
||||
# TODO: replace with upstream version once https://github.com/shssoichiro/oxipng/pull/327 is merged.
|
||||
oxipng = { git = "https://github.com/RReverser/oxipng", branch = "crossbeam" }
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
opt-level = "s"
|
||||
|
||||
[features]
|
||||
parallel = ["oxipng/parallel", "rayon", "crossbeam-channel", "once_cell"]
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = ["-O", "--no-validation"]
|
20
codecs/oxipng/LICENSE.codec.md
Normal file
20
codecs/oxipng/LICENSE.codec.md
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 Joshua Holmer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
5
codecs/oxipng/README.md
Normal file
5
codecs/oxipng/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# OxiPNG
|
||||
|
||||
- Source: <https://github.com/shssoichiro/oxipng>
|
||||
- Version: v3.0.0
|
||||
- License: MIT
|
9
codecs/oxipng/build.sh
Normal file
9
codecs/oxipng/build.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
rm -rf pkg,{-parallel}
|
||||
wasm-pack build
|
||||
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' wasm-pack build -t web -d pkg-parallel -- -Z build-std=panic_abort,std --features=parallel
|
||||
sed -i "s|input = import.meta.url.replace(/\\\.js$/, '_bg.wasm');||" pkg{,-parallel}/squoosh_oxipng.js
|
||||
rm pkg{,-parallel}/.gitignore
|
10
codecs/oxipng/index.ts
Normal file
10
codecs/oxipng/index.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { threads } from 'wasm-feature-detect';
|
||||
|
||||
async function init() {
|
||||
if (await threads()) {
|
||||
return (await import('./spawn')).default;
|
||||
}
|
||||
return import('./pkg');
|
||||
}
|
||||
|
||||
export default init();
|
4
codecs/oxipng/package-lock.json
generated
Normal file
4
codecs/oxipng/package-lock.json
generated
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "oxipng",
|
||||
"lockfileVersion": 1
|
||||
}
|
6
codecs/oxipng/package.json
Normal file
6
codecs/oxipng/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "oxipng",
|
||||
"scripts": {
|
||||
"build": "../build-rust-nightly.sh ./build.sh"
|
||||
}
|
||||
}
|
5
codecs/oxipng/pkg-parallel/README.md
Normal file
5
codecs/oxipng/pkg-parallel/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# OxiPNG
|
||||
|
||||
- Source: <https://github.com/shssoichiro/oxipng>
|
||||
- Version: v3.0.0
|
||||
- License: MIT
|
15
codecs/oxipng/pkg-parallel/package.json
Normal file
15
codecs/oxipng/pkg-parallel/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "squoosh-oxipng",
|
||||
"collaborators": [
|
||||
"Ingvar Stepanyan <me@rreverser.com>"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"squoosh_oxipng_bg.wasm",
|
||||
"squoosh_oxipng.js",
|
||||
"squoosh_oxipng.d.ts"
|
||||
],
|
||||
"module": "squoosh_oxipng.js",
|
||||
"types": "squoosh_oxipng.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
46
codecs/oxipng/pkg-parallel/squoosh_oxipng.d.ts
vendored
Normal file
46
codecs/oxipng/pkg-parallel/squoosh_oxipng.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @param {number} num
|
||||
* @returns {any}
|
||||
*/
|
||||
export function worker_initializer(num: number): any;
|
||||
/**
|
||||
*/
|
||||
export function start_main_thread(): void;
|
||||
/**
|
||||
*/
|
||||
export function start_worker_thread(): void;
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
||||
|
||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||
|
||||
export interface InitOutput {
|
||||
readonly malloc: (a: number) => number;
|
||||
readonly free: (a: number) => void;
|
||||
readonly worker_initializer: (a: number) => number;
|
||||
readonly start_main_thread: () => void;
|
||||
readonly start_worker_thread: () => void;
|
||||
readonly optimise: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly __wbindgen_export_0: WebAssembly.Memory;
|
||||
readonly __wbindgen_malloc: (a: number) => number;
|
||||
readonly __wbindgen_free: (a: number, b: number) => void;
|
||||
readonly __wbindgen_start: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||
*
|
||||
* @param {InitInput | Promise<InitInput>} module_or_path
|
||||
* @param {WebAssembly.Memory} maybe_memory
|
||||
*
|
||||
* @returns {Promise<InitOutput>}
|
||||
*/
|
||||
export default function init (module_or_path?: InitInput | Promise<InitInput>, maybe_memory: WebAssembly.Memory): Promise<InitOutput>;
|
||||
|
180
codecs/oxipng/pkg-parallel/squoosh_oxipng.js
Normal file
180
codecs/oxipng/pkg-parallel/squoosh_oxipng.js
Normal file
@ -0,0 +1,180 @@
|
||||
|
||||
let wasm;
|
||||
let memory;
|
||||
|
||||
const heap = new Array(32).fill(undefined);
|
||||
|
||||
heap.push(undefined, null, true, false);
|
||||
|
||||
let heap_next = heap.length;
|
||||
|
||||
function addHeapObject(obj) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
const idx = heap_next;
|
||||
heap_next = heap[idx];
|
||||
|
||||
heap[idx] = obj;
|
||||
return idx;
|
||||
}
|
||||
|
||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.__wbindgen_export_0.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.__wbindgen_export_0.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().slice(ptr, ptr + len));
|
||||
}
|
||||
|
||||
function getObject(idx) { return heap[idx]; }
|
||||
|
||||
function dropObject(idx) {
|
||||
if (idx < 36) return;
|
||||
heap[idx] = heap_next;
|
||||
heap_next = idx;
|
||||
}
|
||||
|
||||
function takeObject(idx) {
|
||||
const ret = getObject(idx);
|
||||
dropObject(idx);
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* @param {number} num
|
||||
* @returns {any}
|
||||
*/
|
||||
export function worker_initializer(num) {
|
||||
var ret = wasm.worker_initializer(num);
|
||||
return takeObject(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
export function start_main_thread() {
|
||||
wasm.start_main_thread();
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
export function start_worker_thread() {
|
||||
wasm.start_worker_thread();
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1);
|
||||
getUint8Memory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.__wbindgen_export_0.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.__wbindgen_export_0.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function optimise(data, level) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_export_1.value - 16;
|
||||
wasm.__wbindgen_export_1.value = retptr;
|
||||
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
wasm.optimise(retptr, ptr0, len0, level);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_export_1.value += 16;
|
||||
}
|
||||
}
|
||||
|
||||
async function load(module, imports, maybe_memory) {
|
||||
if (typeof Response === 'function' && module instanceof Response) {
|
||||
memory = imports.wbg.memory = new WebAssembly.Memory({initial:17,maximum:16384,shared:true});
|
||||
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
||||
try {
|
||||
return await WebAssembly.instantiateStreaming(module, imports);
|
||||
|
||||
} catch (e) {
|
||||
if (module.headers.get('Content-Type') != 'application/wasm') {
|
||||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
||||
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bytes = await module.arrayBuffer();
|
||||
return await WebAssembly.instantiate(bytes, imports);
|
||||
|
||||
} else {
|
||||
memory = imports.wbg.memory = maybe_memory;
|
||||
const instance = await WebAssembly.instantiate(module, imports);
|
||||
|
||||
if (instance instanceof WebAssembly.Instance) {
|
||||
return { instance, module };
|
||||
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function init(input, maybe_memory) {
|
||||
if (typeof input === 'undefined') {
|
||||
|
||||
}
|
||||
const imports = {};
|
||||
imports.wbg = {};
|
||||
imports.wbg.__wbindgen_module = function() {
|
||||
var ret = init.__wbindgen_wasm_module;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_memory = function() {
|
||||
var ret = wasm.__wbindgen_export_0;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbg_of_6510501edc06d65e = function(arg0, arg1) {
|
||||
var ret = Array.of(takeObject(arg0), takeObject(arg1));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
|
||||
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
||||
input = fetch(input);
|
||||
}
|
||||
|
||||
const { instance, module } = await load(await input, imports, maybe_memory);
|
||||
|
||||
wasm = instance.exports;
|
||||
init.__wbindgen_wasm_module = module;
|
||||
wasm.__wbindgen_start();
|
||||
return wasm;
|
||||
}
|
||||
|
||||
export default init;
|
||||
|
BIN
codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm
Normal file
BIN
codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm
Normal file
Binary file not shown.
12
codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm.d.ts
vendored
Normal file
12
codecs/oxipng/pkg-parallel/squoosh_oxipng_bg.wasm.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export function malloc(a: number): number;
|
||||
export function free(a: number): void;
|
||||
export function worker_initializer(a: number): number;
|
||||
export function start_main_thread(): void;
|
||||
export function start_worker_thread(): void;
|
||||
export function optimise(a: number, b: number, c: number, d: number): void;
|
||||
export const __wbindgen_export_0: WebAssembly.Memory;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
||||
export function __wbindgen_start(): void;
|
5
codecs/oxipng/pkg/README.md
Normal file
5
codecs/oxipng/pkg/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# OxiPNG
|
||||
|
||||
- Source: <https://github.com/shssoichiro/oxipng>
|
||||
- Version: v3.0.0
|
||||
- License: MIT
|
15
codecs/oxipng/pkg/package.json
Normal file
15
codecs/oxipng/pkg/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "squoosh-oxipng",
|
||||
"collaborators": [
|
||||
"Ingvar Stepanyan <me@rreverser.com>"
|
||||
],
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"squoosh_oxipng_bg.wasm",
|
||||
"squoosh_oxipng.js",
|
||||
"squoosh_oxipng.d.ts"
|
||||
],
|
||||
"module": "squoosh_oxipng.js",
|
||||
"types": "squoosh_oxipng.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
8
codecs/oxipng/pkg/squoosh_oxipng.d.ts
vendored
Normal file
8
codecs/oxipng/pkg/squoosh_oxipng.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
2
codecs/oxipng/pkg/squoosh_oxipng.js
Normal file
2
codecs/oxipng/pkg/squoosh_oxipng.js
Normal file
@ -0,0 +1,2 @@
|
||||
import * as wasm from "./squoosh_oxipng_bg.wasm";
|
||||
export * from "./squoosh_oxipng_bg.js";
|
66
codecs/oxipng/pkg/squoosh_oxipng_bg.js
Normal file
66
codecs/oxipng/pkg/squoosh_oxipng_bg.js
Normal file
@ -0,0 +1,66 @@
|
||||
import * as wasm from './squoosh_oxipng_bg.wasm';
|
||||
|
||||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
||||
|
||||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
|
||||
cachedTextDecoder.decode();
|
||||
|
||||
let cachegetUint8Memory0 = null;
|
||||
function getUint8Memory0() {
|
||||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetUint8Memory0;
|
||||
}
|
||||
|
||||
function getStringFromWasm0(ptr, len) {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
|
||||
function passArray8ToWasm0(arg, malloc) {
|
||||
const ptr = malloc(arg.length * 1);
|
||||
getUint8Memory0().set(arg, ptr / 1);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
let cachegetInt32Memory0 = null;
|
||||
function getInt32Memory0() {
|
||||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
||||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
||||
}
|
||||
return cachegetInt32Memory0;
|
||||
}
|
||||
|
||||
function getArrayU8FromWasm0(ptr, len) {
|
||||
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
||||
}
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function optimise(data, level) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_export_0.value - 16;
|
||||
wasm.__wbindgen_export_0.value = retptr;
|
||||
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||
var len0 = WASM_VECTOR_LEN;
|
||||
wasm.optimise(retptr, ptr0, len0, level);
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||
wasm.__wbindgen_free(r0, r1 * 1);
|
||||
return v1;
|
||||
} finally {
|
||||
wasm.__wbindgen_export_0.value += 16;
|
||||
}
|
||||
}
|
||||
|
||||
export const __wbindgen_throw = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
|
BIN
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm
Normal file
BIN
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm
Normal file
Binary file not shown.
8
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm.d.ts
vendored
Normal file
8
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const memory: WebAssembly.Memory;
|
||||
export function optimise(a: number, b: number, c: number, d: number): void;
|
||||
export function malloc(a: number): number;
|
||||
export function free(a: number): void;
|
||||
export function __wbindgen_malloc(a: number): number;
|
||||
export function __wbindgen_free(a: number, b: number): void;
|
1
codecs/oxipng/rust-toolchain
Normal file
1
codecs/oxipng/rust-toolchain
Normal file
@ -0,0 +1 @@
|
||||
nightly
|
52
codecs/oxipng/spawn.ts
Normal file
52
codecs/oxipng/spawn.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import initOxiPNG, {
|
||||
worker_initializer,
|
||||
start_main_thread,
|
||||
optimise,
|
||||
} from './pkg-parallel';
|
||||
// @ts-ignore
|
||||
import wasmUrl from './pkg-parallel/squoosh_oxipng_bg.wasm';
|
||||
import { WorkerInit } from './worker';
|
||||
|
||||
function initWorker(worker: Worker, workerInit: WorkerInit) {
|
||||
return new Promise((resolve) => {
|
||||
worker.postMessage(workerInit);
|
||||
worker.addEventListener('message', () => resolve(), { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
async function startMainThread() {
|
||||
const num = navigator.hardwareConcurrency;
|
||||
|
||||
// First, let browser fetch and spawn Workers for our pool in the background.
|
||||
// This is fairly expensive, so we want to start it as early as possible.
|
||||
const workers = Array.from({ length: num }, () => new Worker('./worker', { type: 'module' }));
|
||||
|
||||
// Meanwhile, asynchronously compile, instantiate and initialise Wasm on our main thread.
|
||||
await initOxiPNG(fetch(wasmUrl), undefined as any);
|
||||
|
||||
// Get module+memory from the Wasm instance.
|
||||
//
|
||||
// Ideally we wouldn't go via Wasm bindings here, since both are just JS variables, but memory is
|
||||
// currently not exposed on the Wasm instance correctly by wasm-bindgen.
|
||||
const workerInit: WorkerInit = worker_initializer(num);
|
||||
|
||||
// Once done, we want to send module+memory to each Worker so that they instantiate Wasm too.
|
||||
// While doing so, we need to wait for Workers to acknowledge that they have received our message.
|
||||
// Ideally this shouldn't be necessary, but Chromium currently doesn't conform to the spec:
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1075645
|
||||
//
|
||||
// If we didn't do this ping-pong game, the `start_main_thread` below would block the current
|
||||
// thread on an atomic before even *sending* the `postMessage` containing memory,
|
||||
// so Workers would never be able to unblock us back.
|
||||
await Promise.all(workers.map(worker => initWorker(worker, workerInit)));
|
||||
|
||||
// Finally, instantiate rayon pool - this will use shared Wasm memory to send tasks to the
|
||||
// Workers and then block until they're all ready.
|
||||
start_main_thread();
|
||||
|
||||
return {
|
||||
optimise,
|
||||
};
|
||||
}
|
||||
|
||||
export default startMainThread();
|
21
codecs/oxipng/src/lib.rs
Normal file
21
codecs/oxipng/src/lib.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
use oxipng::AlphaOptim;
|
||||
|
||||
mod malloc_shim;
|
||||
|
||||
#[cfg(feature = "parallel")]
|
||||
pub mod parallel;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn optimise(data: &[u8], level: u8) -> Vec<u8> {
|
||||
let mut options = oxipng::Options::from_preset(level);
|
||||
options.alphas.insert(AlphaOptim::Black);
|
||||
options.alphas.insert(AlphaOptim::White);
|
||||
options.alphas.insert(AlphaOptim::Up);
|
||||
options.alphas.insert(AlphaOptim::Down);
|
||||
options.alphas.insert(AlphaOptim::Left);
|
||||
options.alphas.insert(AlphaOptim::Right);
|
||||
|
||||
options.deflate = oxipng::Deflaters::Libdeflater;
|
||||
oxipng::optimize_from_memory(data, &options).unwrap_throw()
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user