mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 08:47:31 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
173d1ea1e5 | ||
|
|
0e90f805a4 |
@@ -7,6 +7,3 @@ end_of_line = lf
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
[Makefile]
|
|
||||||
indent_style = tab
|
|
||||||
|
|||||||
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -1,2 +0,0 @@
|
|||||||
/codecs/**/*.js linguist-generated=true
|
|
||||||
/codecs/*/pkg*/*.d.ts linguist-generated=true
|
|
||||||
22
.github/workflows/node.js.yml
vendored
22
.github/workflows/node.js.yml
vendored
@@ -1,22 +0,0 @@
|
|||||||
name: Node.js CI
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- id: nvmrc
|
|
||||||
uses: browniebroke/read-nvmrc-action@v1
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: '${{ steps.nvmrc.outputs.node_version }}'
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run build
|
|
||||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,11 +1,6 @@
|
|||||||
.tmp
|
|
||||||
node_modules
|
node_modules
|
||||||
|
/build
|
||||||
|
/*.log
|
||||||
*.scss.d.ts
|
*.scss.d.ts
|
||||||
*.css.d.ts
|
*.css.d.ts
|
||||||
build
|
|
||||||
*.o
|
*.o
|
||||||
|
|
||||||
# Auto-generated by lib/feature-plugin.js
|
|
||||||
src/features-worker/index.ts
|
|
||||||
src/client/lazy-app/worker-bridge/meta.ts
|
|
||||||
src/client/lazy-app/feature-meta/index.ts
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
codecs
|
|
||||||
.tmp
|
|
||||||
node_modules
|
|
||||||
*.scss.d.ts
|
|
||||||
*.css.d.ts
|
|
||||||
build
|
|
||||||
*.o
|
|
||||||
|
|
||||||
# Auto-generated by lib/feature-plugin.js
|
|
||||||
src/features-worker/index.ts
|
|
||||||
src/client/lazy-app/worker-bridge/meta.ts
|
|
||||||
src/client/lazy-app/feature-meta/index.ts
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
|
||||||
7
.travis.yml
Normal file
7
.travis.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
language: node_js
|
||||||
|
cache: npm
|
||||||
|
script: npm run build
|
||||||
|
after_success: npm run sizereport
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
18
_headers.ejs
Normal file
18
_headers.ejs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Long-term cache by default.
|
||||||
|
/*
|
||||||
|
Cache-Control: max-age=31536000
|
||||||
|
|
||||||
|
# And here are the exceptions:
|
||||||
|
/
|
||||||
|
Cache-Control: no-cache
|
||||||
|
|
||||||
|
/serviceworker.js
|
||||||
|
Cache-Control: no-cache
|
||||||
|
|
||||||
|
/manifest.json
|
||||||
|
Cache-Control: must-revalidate, max-age=3600
|
||||||
|
|
||||||
|
# URLs in /assets do not include a hash and are mutable.
|
||||||
|
# But it isn't a big deal if the user gets an old version.
|
||||||
|
/assets/*
|
||||||
|
Cache-Control: must-revalidate, max-age=3600
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./generic-tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["esnext", "dom", "dom.iterable"],
|
|
||||||
"types": []
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src/features/**/client/**/*",
|
|
||||||
"src/features/**/shared/**/*",
|
|
||||||
"src/features/client-utils/**/*",
|
|
||||||
"src/shared/**/*",
|
|
||||||
"src/client/**/*",
|
|
||||||
// Not really clean, but we need these to access the type of the functions
|
|
||||||
// for comlink
|
|
||||||
"src/features/**/worker/**/*",
|
|
||||||
"src/features-worker/**/*",
|
|
||||||
"src/features/worker-utils/**/*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# 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`.
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
||||||
7
codecs/avif/dec/avif_dec.d.ts
vendored
7
codecs/avif/dec/avif_dec.d.ts
vendored
@@ -1,7 +0,0 @@
|
|||||||
export interface AVIFModule extends EmscriptenWasm.Module {
|
|
||||||
decode(data: BufferSource): ImageData | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<AVIFModule>;
|
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,37 +0,0 @@
|
|||||||
# 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;
|
|
||||||
};
|
|
||||||
```
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
#include <emscripten/bind.h>
|
|
||||||
#include <emscripten/threading.h>
|
|
||||||
#include <emscripten/val.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);
|
|
||||||
}
|
|
||||||
23
codecs/avif/enc/avif_enc.d.ts
vendored
23
codecs/avif/enc/avif_enc.d.ts
vendored
@@ -1,23 +0,0 @@
|
|||||||
export interface EncodeOptions {
|
|
||||||
minQuantizer: number;
|
|
||||||
maxQuantizer: number;
|
|
||||||
minQuantizerAlpha: number;
|
|
||||||
maxQuantizerAlpha: number;
|
|
||||||
tileRowsLog2: number;
|
|
||||||
tileColsLog2: number;
|
|
||||||
speed: number;
|
|
||||||
subsample: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AVIFModule extends EmscriptenWasm.Module {
|
|
||||||
encode(
|
|
||||||
data: BufferSource,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
options: EncodeOptions,
|
|
||||||
): Uint8Array | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<AVIFModule>;
|
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
2
codecs/avif/enc/avif_enc_mt.d.ts
vendored
2
codecs/avif/enc/avif_enc_mt.d.ts
vendored
@@ -1,2 +0,0 @@
|
|||||||
export * from './avif_enc';
|
|
||||||
export { default } from './avif_enc';
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,103 +0,0 @@
|
|||||||
var threadInfoStruct = 0;
|
|
||||||
var selfThreadId = 0;
|
|
||||||
var parentThreadId = 0;
|
|
||||||
var initializedJS = false;
|
|
||||||
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['wasmModule'] = e.data.wasmModule;
|
|
||||||
Module['wasmMemory'] = e.data.wasmMemory;
|
|
||||||
Module['buffer'] = Module['wasmMemory'].buffer;
|
|
||||||
Module['ENVIRONMENT_IS_PTHREAD'] = true;
|
|
||||||
import(e.data.urlOrBlob)
|
|
||||||
.then(function (avif_enc_mt) {
|
|
||||||
return avif_enc_mt.default(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);
|
|
||||||
if (!initializedJS) {
|
|
||||||
Module['___embind_register_native_and_builtin_types']();
|
|
||||||
initializedJS = true;
|
|
||||||
}
|
|
||||||
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 && ex.stack) err(ex.stack);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
# 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 TEXTDECODER=2 \
|
|
||||||
-s ENVIRONMENT='worker' \
|
|
||||||
-s EXPORT_ES6=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
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "avif",
|
|
||||||
"scripts": {
|
|
||||||
"build": "../build-cpp.sh"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ ! -z "$RUST_IMG" ]
|
docker build -t squoosh-rust - < ../rust.Dockerfile
|
||||||
then
|
docker run --rm -v $PWD:/src squoosh-rust "$@"
|
||||||
# Get part after ":" (https://stackoverflow.com/a/15149278/439965).
|
|
||||||
IMG_SUFFIX=-${RUST_IMG#*:}
|
|
||||||
fi
|
|
||||||
IMG_NAME=squoosh-rust$IMG_SUFFIX
|
|
||||||
docker build -t $IMG_NAME --build-arg RUST_IMG - < ../rust.Dockerfile
|
|
||||||
docker run --rm -v $PWD:/src $IMG_NAME "$@"
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
FROM emscripten/emsdk:2.0.8
|
FROM emscripten/emsdk:1.39.19
|
||||||
RUN apt-get update && apt-get install -qqy autoconf libtool pkg-config
|
RUN apt-get update && apt-get install -qqy autoconf libtool pkg-config
|
||||||
ENV CFLAGS "-O3 -flto"
|
ENV CFLAGS "-Os -flto"
|
||||||
ENV CXXFLAGS "${CFLAGS} -std=c++17"
|
ENV CXXFLAGS "${CFLAGS} -std=c++17"
|
||||||
ENV LDFLAGS "${CFLAGS} -s PTHREAD_POOL_SIZE=navigator.hardwareConcurrency"
|
ENV LDFLAGS "${CFLAGS}"
|
||||||
# Build and cache standard libraries with these flags
|
# Build and cache standard libraries with these flags
|
||||||
RUN emcc ${CXXFLAGS} --bind -xc++ /dev/null -o /dev/null
|
RUN emcc ${CXXFLAGS} --bind -xc++ /dev/null -o /dev/null
|
||||||
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
|
||||||
|
RUN /bin/bash -ic 'nvm install 14.7.0'
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
CMD ["sh", "-c", "emmake make -j`nproc`"]
|
CMD ["sh", "-c", "emmake make -j`nproc`"]
|
||||||
|
|||||||
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
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
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.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# 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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "hqx",
|
"name": "hqx",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "RUST_IMG=rust:1.40 ../build-rust.sh"
|
"build:image": "docker build -t squoosh-hqx - < Dockerfile",
|
||||||
|
"build": "docker run --rm -v $(pwd):/src squoosh-hqx ./build.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# HQX
|
|
||||||
|
|
||||||
- Source: <https://github.com/CryZe/wasmboy-rs>
|
|
||||||
- Version: v0.1.2
|
|
||||||
- License: Apache 2.0
|
|
||||||
52
codecs/hqx/pkg/squooshhqx.d.ts
vendored
52
codecs/hqx/pkg/squooshhqx.d.ts
vendored
@@ -1,48 +1,10 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* @param {Uint32Array} input_image
|
* @param {Uint32Array} input_image
|
||||||
* @param {number} input_width
|
* @param {number} input_width
|
||||||
* @param {number} input_height
|
* @param {number} input_height
|
||||||
* @param {number} factor
|
* @param {number} factor
|
||||||
* @returns {Uint32Array}
|
* @returns {Uint32Array}
|
||||||
*/
|
*/
|
||||||
export function resize(
|
export function resize(input_image: Uint32Array, input_width: number, input_height: number, factor: number): Uint32Array;
|
||||||
input_image: Uint32Array,
|
|
||||||
input_width: number,
|
|
||||||
input_height: number,
|
|
||||||
factor: number,
|
|
||||||
): Uint32Array;
|
|
||||||
|
|
||||||
export type InitInput =
|
|
||||||
| RequestInfo
|
|
||||||
| URL
|
|
||||||
| Response
|
|
||||||
| BufferSource
|
|
||||||
| WebAssembly.Module;
|
|
||||||
|
|
||||||
export interface InitOutput {
|
|
||||||
readonly memory: WebAssembly.Memory;
|
|
||||||
readonly resize: (
|
|
||||||
a: number,
|
|
||||||
b: number,
|
|
||||||
c: number,
|
|
||||||
d: number,
|
|
||||||
e: number,
|
|
||||||
f: number,
|
|
||||||
) => void;
|
|
||||||
readonly __wbindgen_malloc: (a: number) => number;
|
|
||||||
readonly __wbindgen_free: (a: number, b: number) => 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
|
|
||||||
*
|
|
||||||
* @returns {Promise<InitOutput>}
|
|
||||||
*/
|
|
||||||
export default function init(
|
|
||||||
module_or_path?: InitInput | Promise<InitInput>,
|
|
||||||
): Promise<InitOutput>;
|
|
||||||
|
|||||||
@@ -1,107 +1,2 @@
|
|||||||
let wasm;
|
import * as wasm from "./squooshhqx_bg.wasm";
|
||||||
|
export * from "./squooshhqx_bg.js";
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load(module, imports) {
|
|
||||||
if (typeof Response === 'function' && module instanceof Response) {
|
|
||||||
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 {
|
|
||||||
const instance = await WebAssembly.instantiate(module, imports);
|
|
||||||
|
|
||||||
if (instance instanceof WebAssembly.Instance) {
|
|
||||||
return { instance, module };
|
|
||||||
} else {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function init(input) {
|
|
||||||
if (typeof input === 'undefined') {
|
|
||||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
|
||||||
}
|
|
||||||
const imports = {};
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
wasm = instance.exports;
|
|
||||||
init.__wbindgen_wasm_module = module;
|
|
||||||
|
|
||||||
return wasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default init;
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,641 +0,0 @@
|
|||||||
|
|
||||||
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.
|
|
||||||
@@ -18,9 +18,7 @@ all: $(OUT_JS)
|
|||||||
--closure 1 \
|
--closure 1 \
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
-s MODULARIZE=1 \
|
-s MODULARIZE=1 \
|
||||||
-s TEXTDECODER=2 \
|
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||||
-s ENVIRONMENT='worker' \
|
|
||||||
-s EXPORT_ES6=1 \
|
|
||||||
-o $@ \
|
-o $@ \
|
||||||
$+
|
$+
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
- Source: <https://github.com/ImageOptim/libimagequant>
|
- Source: <https://github.com/ImageOptim/libimagequant>
|
||||||
- Version: v2.12.1
|
- Version: v2.12.1
|
||||||
- License: GPL3
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<style>
|
<style>
|
||||||
canvas {
|
canvas {
|
||||||
image-rendering: pixelated;
|
image-rendering: pixelated;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="module">
|
<script src='imagequant.js'></script>
|
||||||
import imagequant from './imagequant.js';
|
<script>
|
||||||
|
const Module = imagequant();
|
||||||
|
|
||||||
async function loadImage(src) {
|
async function loadImage(src) {
|
||||||
// Load image
|
// Load image
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.src = src;
|
img.src = src;
|
||||||
await new Promise((resolve) => (img.onload = resolve));
|
await new Promise(resolve => img.onload = resolve);
|
||||||
// Make canvas same size as image
|
// Make canvas same size as image
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
[canvas.width, canvas.height] = [img.width, img.height];
|
[canvas.width, canvas.height] = [img.width, img.height];
|
||||||
@@ -21,32 +22,19 @@
|
|||||||
return ctx.getImageData(0, 0, img.width, img.height);
|
return ctx.getImageData(0, 0, img.width, img.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
Module.onRuntimeInitialized = async _ => {
|
||||||
const module = await imagequant();
|
console.log('Version:', Module.version().toString(16));
|
||||||
|
|
||||||
console.log('Version:', module.version().toString(16));
|
|
||||||
const image = await loadImage('../example.png');
|
const image = await loadImage('../example.png');
|
||||||
const rawImage = module.quantize(
|
// const rawImage = Module.quantize(image.data, image.width, image.height, 256, 1.0);
|
||||||
image.data,
|
const rawImage = Module.zx_quantize(image.data, image.width, image.height, 1.0);
|
||||||
image.width,
|
|
||||||
image.height,
|
|
||||||
256,
|
|
||||||
1.0,
|
|
||||||
);
|
|
||||||
console.log('done');
|
console.log('done');
|
||||||
|
|
||||||
const imageData = new ImageData(
|
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), rawImage.width, rawImage.height);
|
||||||
new Uint8ClampedArray(rawImage.buffer),
|
|
||||||
image.width,
|
|
||||||
image.height,
|
|
||||||
);
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = image.width;
|
canvas.width = image.width;
|
||||||
canvas.height = image.height;
|
canvas.height = image.height;
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.putImageData(imageData, 0, 0);
|
ctx.putImageData(imageData, 0, 0);
|
||||||
document.body.appendChild(canvas);
|
document.body.appendChild(canvas);
|
||||||
}
|
};
|
||||||
|
|
||||||
main();
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
21
codecs/imagequant/imagequant.d.ts
vendored
21
codecs/imagequant/imagequant.d.ts
vendored
@@ -1,19 +1,6 @@
|
|||||||
export interface QuantizerModule extends EmscriptenWasm.Module {
|
interface QuantizerModule extends EmscriptenWasm.Module {
|
||||||
quantize(
|
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): Uint8ClampedArray;
|
||||||
data: BufferSource,
|
zx_quantize(data: BufferSource, width: number, height: number, dither: number): Uint8ClampedArray;
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
numColors: number,
|
|
||||||
dither: number,
|
|
||||||
): Uint8ClampedArray;
|
|
||||||
zx_quantize(
|
|
||||||
data: BufferSource,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
dither: number,
|
|
||||||
): Uint8ClampedArray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<QuantizerModule>;
|
export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule;
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
BIN
codecs/imagequant/imagequant.wasm
Executable file → Normal file
BIN
codecs/imagequant/imagequant.wasm
Executable file → Normal file
Binary file not shown.
@@ -1,59 +0,0 @@
|
|||||||
CODEC_URL = https://gitlab.com/wg1/jpeg-xl.git
|
|
||||||
CODEC_VERSION = v0.1
|
|
||||||
CODEC_DIR = node_modules/jxl
|
|
||||||
CODEC_BUILD_DIR := $(CODEC_DIR)/build
|
|
||||||
CODEC_OUT := $(CODEC_BUILD_DIR)/lib/libjxl.a
|
|
||||||
|
|
||||||
OUT_JS = enc/jxl_enc.js dec/jxl_dec.js
|
|
||||||
OUT_WASM = $(OUT_JS:.js=.wasm)
|
|
||||||
|
|
||||||
.PHONY: all clean
|
|
||||||
|
|
||||||
all: $(OUT_JS)
|
|
||||||
|
|
||||||
%.js: %.cpp $(LIBAOM_OUT) $(CODEC_OUT)
|
|
||||||
$(CXX) \
|
|
||||||
-I $(CODEC_DIR) \
|
|
||||||
-I $(CODEC_DIR)/lib \
|
|
||||||
-I $(CODEC_DIR)/lib/include \
|
|
||||||
-I $(CODEC_BUILD_DIR)/lib/include \
|
|
||||||
-I $(CODEC_DIR)/third_party/highway \
|
|
||||||
-I $(CODEC_DIR)/third_party/skcms \
|
|
||||||
-I $(CODEC_DIR)/third_party/brunsli \
|
|
||||||
-I $(CODEC_DIR)/third_party/brunsli/c/include \
|
|
||||||
${CXXFLAGS} \
|
|
||||||
${LDFLAGS} \
|
|
||||||
--bind \
|
|
||||||
--closure 1 \
|
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
|
||||||
-s MODULARIZE=1 \
|
|
||||||
-s TEXTDECODER=2 \
|
|
||||||
-s ENVIRONMENT='worker' \
|
|
||||||
-s EXPORT_ES6=1 \
|
|
||||||
-s EXPORT_NAME="$(basename $(@F))" \
|
|
||||||
-o $@ \
|
|
||||||
$+ \
|
|
||||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslienc-static.bc \
|
|
||||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslicommon-static.bc \
|
|
||||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslidec-static.bc \
|
|
||||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlidec-static.a \
|
|
||||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlienc-static.a \
|
|
||||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlicommon-static.a \
|
|
||||||
$(CODEC_BUILD_DIR)/third_party/libskcms.a \
|
|
||||||
$(CODEC_BUILD_DIR)/third_party/highway/libhwy.a
|
|
||||||
|
|
||||||
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt
|
|
||||||
mkdir -p $(CODEC_BUILD_DIR)
|
|
||||||
cd $(CODEC_BUILD_DIR) && \
|
|
||||||
emcmake cmake ../ && \
|
|
||||||
$(MAKE) jxl-static
|
|
||||||
|
|
||||||
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_DIR)
|
|
||||||
|
|
||||||
$(CODEC_DIR):
|
|
||||||
mkdir -p $@
|
|
||||||
git clone $(CODEC_URL) --recursive -j`nproc` --depth 1 --branch $(CODEC_VERSION) $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) $(OUT_JS) $(OUT_WASM)
|
|
||||||
$(MAKE) -C $(CODEC_BUILD_DIR) clean
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
#include <emscripten/bind.h>
|
|
||||||
#include <emscripten/val.h>
|
|
||||||
|
|
||||||
#include <jxl/decode.h>
|
|
||||||
#include "lib/jxl/color_encoding_internal.h"
|
|
||||||
|
|
||||||
#include "skcms.h"
|
|
||||||
|
|
||||||
using namespace emscripten;
|
|
||||||
|
|
||||||
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
|
|
||||||
thread_local const val ImageData = val::global("ImageData");
|
|
||||||
|
|
||||||
// R, G, B, A
|
|
||||||
#define COMPONENTS_PER_PIXEL 4
|
|
||||||
|
|
||||||
#ifndef JXL_DEBUG_ON_ALL_ERROR
|
|
||||||
#define JXL_DEBUG_ON_ALL_ERROR 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if JXL_DEBUG_ON_ALL_ERROR
|
|
||||||
#define EXPECT_TRUE(a) \
|
|
||||||
if (!(a)) { \
|
|
||||||
fprintf(stderr, "Assertion failure (%d): %s\n", __LINE__, #a); \
|
|
||||||
return val::null(); \
|
|
||||||
}
|
|
||||||
#define EXPECT_EQ(a, b) \
|
|
||||||
{ \
|
|
||||||
int a_ = a; \
|
|
||||||
int b_ = b; \
|
|
||||||
if (a_ != b_) { \
|
|
||||||
fprintf(stderr, "Assertion failure (%d): %s (%d) != %s (%d)\n", __LINE__, #a, a_, #b, b_); \
|
|
||||||
return val::null(); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define EXPECT_TRUE(a) \
|
|
||||||
if (!(a)) { \
|
|
||||||
return val::null(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define EXPECT_EQ(a, b) EXPECT_TRUE((a) == (b));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
val decode(std::string data) {
|
|
||||||
std::unique_ptr<JxlDecoder,
|
|
||||||
std::integral_constant<decltype(&JxlDecoderDestroy), JxlDecoderDestroy>>
|
|
||||||
dec(JxlDecoderCreate(nullptr));
|
|
||||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
|
||||||
JxlDecoderSubscribeEvents(
|
|
||||||
dec.get(), JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE));
|
|
||||||
|
|
||||||
auto next_in = (const uint8_t*)data.c_str();
|
|
||||||
auto avail_in = data.size();
|
|
||||||
EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
|
||||||
JxlBasicInfo info;
|
|
||||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec.get(), &info));
|
|
||||||
size_t pixel_count = info.xsize * info.ysize;
|
|
||||||
size_t component_count = pixel_count * COMPONENTS_PER_PIXEL;
|
|
||||||
|
|
||||||
EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
|
||||||
static const JxlPixelFormat format = {COMPONENTS_PER_PIXEL, JXL_TYPE_FLOAT, JXL_LITTLE_ENDIAN, 0};
|
|
||||||
size_t icc_size;
|
|
||||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetICCProfileSize(dec.get(), &format,
|
|
||||||
JXL_COLOR_PROFILE_TARGET_DATA, &icc_size));
|
|
||||||
std::vector<uint8_t> icc_profile(icc_size);
|
|
||||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
|
||||||
JxlDecoderGetColorAsICCProfile(dec.get(), &format, JXL_COLOR_PROFILE_TARGET_DATA,
|
|
||||||
icc_profile.data(), icc_profile.size()));
|
|
||||||
|
|
||||||
auto float_pixels = std::make_unique<float[]>(component_count);
|
|
||||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderSetImageOutBuffer(dec.get(), &format, float_pixels.get(),
|
|
||||||
component_count * sizeof(float)));
|
|
||||||
EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec.get(), &next_in, &avail_in));
|
|
||||||
|
|
||||||
auto byte_pixels = std::make_unique<uint8_t[]>(component_count);
|
|
||||||
// Convert to sRGB.
|
|
||||||
skcms_ICCProfile jxl_profile;
|
|
||||||
EXPECT_TRUE(skcms_Parse(icc_profile.data(), icc_profile.size(), &jxl_profile));
|
|
||||||
EXPECT_TRUE(skcms_Transform(
|
|
||||||
float_pixels.get(), skcms_PixelFormat_RGBA_ffff,
|
|
||||||
info.alpha_premultiplied ? skcms_AlphaFormat_PremulAsEncoded : skcms_AlphaFormat_Unpremul,
|
|
||||||
&jxl_profile, byte_pixels.get(), skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_Unpremul,
|
|
||||||
skcms_sRGB_profile(), pixel_count));
|
|
||||||
|
|
||||||
return ImageData.new_(
|
|
||||||
Uint8ClampedArray.new_(typed_memory_view(component_count, byte_pixels.get())), info.xsize,
|
|
||||||
info.ysize);
|
|
||||||
}
|
|
||||||
|
|
||||||
EMSCRIPTEN_BINDINGS(my_module) {
|
|
||||||
function("decode", &decode);
|
|
||||||
}
|
|
||||||
7
codecs/jxl/dec/jxl_dec.d.ts
vendored
7
codecs/jxl/dec/jxl_dec.d.ts
vendored
@@ -1,7 +0,0 @@
|
|||||||
export interface JXLModule extends EmscriptenWasm.Module {
|
|
||||||
decode(data: BufferSource): ImageData | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<JXLModule>;
|
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,124 +0,0 @@
|
|||||||
#include <emscripten/bind.h>
|
|
||||||
#include <emscripten/val.h>
|
|
||||||
|
|
||||||
#include "lib/jxl/enc_file.h"
|
|
||||||
#include "lib/jxl/external_image.h"
|
|
||||||
|
|
||||||
using namespace emscripten;
|
|
||||||
|
|
||||||
thread_local const val Uint8Array = val::global("Uint8Array");
|
|
||||||
|
|
||||||
struct JXLOptions {
|
|
||||||
// 1 = slowest
|
|
||||||
// 7 = fastest
|
|
||||||
int speed;
|
|
||||||
float quality;
|
|
||||||
bool progressive;
|
|
||||||
int epf;
|
|
||||||
int nearLossless;
|
|
||||||
bool lossyPalette;
|
|
||||||
};
|
|
||||||
|
|
||||||
val encode(std::string image, int width, int height, JXLOptions options) {
|
|
||||||
jxl::CompressParams cparams;
|
|
||||||
jxl::PassesEncoderState passes_enc_state;
|
|
||||||
jxl::CodecInOut io;
|
|
||||||
jxl::PaddedBytes bytes;
|
|
||||||
jxl::ImageBundle* main = &io.Main();
|
|
||||||
|
|
||||||
cparams.epf = options.epf;
|
|
||||||
cparams.speed_tier = static_cast<jxl::SpeedTier>(options.speed);
|
|
||||||
cparams.near_lossless = options.nearLossless;
|
|
||||||
|
|
||||||
if (options.lossyPalette) {
|
|
||||||
cparams.lossy_palette = true;
|
|
||||||
cparams.palette_colors = 0;
|
|
||||||
cparams.options.predictor = jxl::Predictor::Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reduce memory usage of tree learning for lossless data.
|
|
||||||
// TODO(veluca93): this is a mitigation for excessive memory usage in the JXL encoder.
|
|
||||||
float megapixels = width * height * 0.000001;
|
|
||||||
if (megapixels > 8) {
|
|
||||||
cparams.options.nb_repeats = 0.1;
|
|
||||||
} else if (megapixels > 4) {
|
|
||||||
cparams.options.nb_repeats = 0.3;
|
|
||||||
} else {
|
|
||||||
// default is OK.
|
|
||||||
}
|
|
||||||
|
|
||||||
float quality = options.quality;
|
|
||||||
|
|
||||||
// Quality settings roughly match libjpeg qualities.
|
|
||||||
if (quality < 7 || quality == 100) {
|
|
||||||
cparams.modular_mode = true;
|
|
||||||
// Internal modular quality to roughly match VarDCT size.
|
|
||||||
cparams.quality_pair.first = cparams.quality_pair.second =
|
|
||||||
std::min(35 + (quality - 7) * 3.0f, 100.0f);
|
|
||||||
} else {
|
|
||||||
cparams.modular_mode = false;
|
|
||||||
if (quality >= 30) {
|
|
||||||
cparams.butteraugli_distance = 0.1 + (100 - quality) * 0.09;
|
|
||||||
} else {
|
|
||||||
cparams.butteraugli_distance = 6.4 + pow(2.5, (30 - quality) / 5.0f) / 6.25f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.progressive) {
|
|
||||||
cparams.qprogressive_mode = true;
|
|
||||||
cparams.responsive = 1;
|
|
||||||
if (!cparams.modular_mode) {
|
|
||||||
cparams.progressive_dc = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cparams.modular_mode) {
|
|
||||||
if (cparams.quality_pair.first != 100 || cparams.quality_pair.second != 100) {
|
|
||||||
cparams.color_transform = jxl::ColorTransform::kXYB;
|
|
||||||
} else {
|
|
||||||
cparams.color_transform = jxl::ColorTransform::kNone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cparams.near_lossless) {
|
|
||||||
// Near-lossless assumes -R 0
|
|
||||||
cparams.responsive = 0;
|
|
||||||
cparams.modular_mode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
io.metadata.m.SetAlphaBits(8);
|
|
||||||
if (!io.metadata.size.Set(width, height)) {
|
|
||||||
return val::null();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* inBuffer = (uint8_t*)image.c_str();
|
|
||||||
|
|
||||||
auto result = jxl::ConvertImage(
|
|
||||||
jxl::Span<const uint8_t>(reinterpret_cast<const uint8_t*>(image.data()), image.size()), width,
|
|
||||||
height, jxl::ColorEncoding::SRGB(/*is_gray=*/false), /*has_alpha=*/true,
|
|
||||||
/*alpha_is_premultiplied=*/false, /*bits_per_alpha=*/8, /*bits_per_sample=*/8,
|
|
||||||
/*big_endian=*/false, /*flipped_y=*/false, /*pool=*/nullptr, main);
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
return val::null();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto js_result = val::null();
|
|
||||||
if (EncodeFile(cparams, &io, &passes_enc_state, &bytes)) {
|
|
||||||
js_result = Uint8Array.new_(typed_memory_view(bytes.size(), bytes.data()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return js_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
EMSCRIPTEN_BINDINGS(my_module) {
|
|
||||||
value_object<JXLOptions>("JXLOptions")
|
|
||||||
.field("speed", &JXLOptions::speed)
|
|
||||||
.field("quality", &JXLOptions::quality)
|
|
||||||
.field("progressive", &JXLOptions::progressive)
|
|
||||||
.field("nearLossless", &JXLOptions::nearLossless)
|
|
||||||
.field("lossyPalette", &JXLOptions::lossyPalette)
|
|
||||||
.field("epf", &JXLOptions::epf);
|
|
||||||
|
|
||||||
function("encode", &encode);
|
|
||||||
}
|
|
||||||
21
codecs/jxl/enc/jxl_enc.d.ts
vendored
21
codecs/jxl/enc/jxl_enc.d.ts
vendored
@@ -1,21 +0,0 @@
|
|||||||
export interface EncodeOptions {
|
|
||||||
speed: number;
|
|
||||||
quality: number;
|
|
||||||
progressive: boolean;
|
|
||||||
epf: number;
|
|
||||||
nearLossless: number;
|
|
||||||
lossyPalette: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface JXLModule extends EmscriptenWasm.Module {
|
|
||||||
encode(
|
|
||||||
data: BufferSource,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
options: EncodeOptions,
|
|
||||||
): Uint8Array | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<JXLModule>;
|
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "jxl",
|
|
||||||
"scripts": {
|
|
||||||
"build": "../build-cpp.sh"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
codecs/mozjpeg_enc/.emscripten
Normal file
13
codecs/mozjpeg_enc/.emscripten
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import os
|
||||||
|
emsdk_path = "/emsdk/"
|
||||||
|
#NODE_JS = emsdk_path + '/node/12.18.1_64bit/bin/node'
|
||||||
|
# We need a newer version of Node that supports the most recent iteration of Wasm SIMD
|
||||||
|
# and need to enable that experimental support via flag so that autoconf can successfully
|
||||||
|
# detect SIMD support.
|
||||||
|
NODE_JS=["/root/.nvm/versions/node/v14.7.0/bin/node", "--experimental-wasm-simd"]
|
||||||
|
LLVM_ROOT = emsdk_path + '/upstream/bin'
|
||||||
|
BINARYEN_ROOT = emsdk_path + '/upstream'
|
||||||
|
EMSCRIPTEN_ROOT = emsdk_path + '/upstream/emscripten'
|
||||||
|
TEMP_DIR = emsdk_path + '/tmp'
|
||||||
|
COMPILER_ENGINE = NODE_JS
|
||||||
|
JS_ENGINES = [NODE_JS]
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
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.
|
|
||||||
@@ -2,25 +2,34 @@ CODEC_URL := https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz
|
|||||||
CODEC_DIR := node_modules/mozjpeg
|
CODEC_DIR := node_modules/mozjpeg
|
||||||
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
|
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
|
||||||
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
||||||
OUT_JS := mozjpeg_enc.js
|
OUT_JS := mozjpeg_enc_simd.js
|
||||||
OUT_WASM := $(OUT_JS:.js=.wasm)
|
OUT_WASM := $(OUT_JS:.js=.wasm)
|
||||||
|
|
||||||
|
CFLAGS += -msimd128 -msse --em-config /src/.emscripten
|
||||||
|
CXXFLAGS += -msimd128 -msse --em-config /src/.emscripten
|
||||||
|
|
||||||
|
#CFLAGS += --em-config /src/.emscripten
|
||||||
|
#CXXFLAGS += --em-config /src/.emscripten
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
all: $(OUT_JS)
|
all: $(OUT_JS)
|
||||||
|
|
||||||
%.js: %.cpp $(CODEC_OUT)
|
%.js: %.cpp $(CODEC_OUT)
|
||||||
|
# We just to disable the overridden NODE_JS binary because
|
||||||
|
# `--closure 1` can’t handle arrays in `.emscripten` it seems.
|
||||||
|
# https://github.com/emscripten-core/emsdk/issues/583
|
||||||
|
export EM_NODE_JS='/root/.nvm/versions/node/v14.7.0/bin/node' && \
|
||||||
$(CXX) \
|
$(CXX) \
|
||||||
-I $(CODEC_DIR) \
|
-I $(CODEC_DIR) \
|
||||||
${CXXFLAGS} \
|
${CXXFLAGS} \
|
||||||
${LDFLAGS} \
|
${LDFLAGS} \
|
||||||
--closure 1 \
|
|
||||||
--bind \
|
--bind \
|
||||||
|
--closure 1 \
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
-s MODULARIZE=1 \
|
-s MODULARIZE=1 \
|
||||||
-s TEXTDECODER=2 \
|
|
||||||
-s ENVIRONMENT='worker' \
|
|
||||||
-s EXPORT_ES6=1 \
|
-s EXPORT_ES6=1 \
|
||||||
|
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||||
-o $@ \
|
-o $@ \
|
||||||
$+
|
$+
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
- Source: <https://github.com/mozilla/mozjpeg>
|
- Source: <https://github.com/mozilla/mozjpeg>
|
||||||
- Version: v3.3.1
|
- Version: v3.3.1
|
||||||
- License: BSD
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
|
|||||||
62
codecs/mozjpeg_enc/bench.d8.js
Normal file
62
codecs/mozjpeg_enc/bench.d8.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import mozjpeg from "./mozjpeg_enc.js";
|
||||||
|
import mozjpegSimd from "./mozjpeg_enc_simd.js";
|
||||||
|
|
||||||
|
const width = 2048;
|
||||||
|
const height = 2048;
|
||||||
|
const size = width * height * 4;
|
||||||
|
const data = new Uint8ClampedArray(size);
|
||||||
|
for(let i = 0; i < size; i++) {
|
||||||
|
data[i] = Math.random() * 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
mozjpeg({
|
||||||
|
onRuntimeInitialized() {
|
||||||
|
const start = performance.now();
|
||||||
|
const result = this.encode(data, width, height, {
|
||||||
|
quality: 75,
|
||||||
|
baseline: false,
|
||||||
|
arithmetic: false,
|
||||||
|
progressive: true,
|
||||||
|
optimize_coding: true,
|
||||||
|
smoothing: 0,
|
||||||
|
color_space: 3,
|
||||||
|
quant_table: 3,
|
||||||
|
trellis_multipass: false,
|
||||||
|
trellis_opt_zero: false,
|
||||||
|
trellis_opt_table: false,
|
||||||
|
trellis_loops: 1,
|
||||||
|
auto_subsample: true,
|
||||||
|
chroma_subsample: 2,
|
||||||
|
separate_chroma_quality: false,
|
||||||
|
chroma_quality: 75,
|
||||||
|
});
|
||||||
|
const end = performance.now();
|
||||||
|
console.log("No SIMD", end - start);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mozjpegSimd({
|
||||||
|
onRuntimeInitialized() {
|
||||||
|
const start = performance.now();
|
||||||
|
const result = this.encode(data, width, height, {
|
||||||
|
quality: 75,
|
||||||
|
baseline: false,
|
||||||
|
arithmetic: false,
|
||||||
|
progressive: true,
|
||||||
|
optimize_coding: true,
|
||||||
|
smoothing: 0,
|
||||||
|
color_space: 3,
|
||||||
|
quant_table: 3,
|
||||||
|
trellis_multipass: false,
|
||||||
|
trellis_opt_zero: false,
|
||||||
|
trellis_opt_table: false,
|
||||||
|
trellis_loops: 1,
|
||||||
|
auto_subsample: true,
|
||||||
|
chroma_subsample: 2,
|
||||||
|
separate_chroma_quality: false,
|
||||||
|
chroma_quality: 75,
|
||||||
|
});
|
||||||
|
const end = performance.now();
|
||||||
|
console.log("SIMD", end - start);
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,27 +1,14 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<script type="module">
|
<script src='mozjpeg_enc.js'></script>
|
||||||
import mozjpeg_enc from './mozjpeg_enc.js';
|
<script>
|
||||||
|
const module = mozjpeg_enc({
|
||||||
async function loadImage(src) {
|
loadFile() {
|
||||||
// Load image
|
return "./mozjpeg_enc.wasm";
|
||||||
const img = document.createElement('img');
|
},
|
||||||
img.src = src;
|
async onRuntimeInitialized() {
|
||||||
await new Promise((resolve) => (img.onload = resolve));
|
//console.log('Version:', module.version().toString(16));
|
||||||
// Make canvas same size as image
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
[canvas.width, canvas.height] = [img.width, img.height];
|
|
||||||
// Draw image onto canvas
|
|
||||||
const ctx = canvas.getContext('2d');
|
|
||||||
ctx.drawImage(img, 0, 0);
|
|
||||||
return ctx.getImageData(0, 0, img.width, img.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const module = await mozjpeg_enc();
|
|
||||||
|
|
||||||
console.log('Version:', module.version().toString(16));
|
|
||||||
const image = await loadImage('../example.png');
|
const image = await loadImage('../example.png');
|
||||||
const result = module.encode(image.data, image.width, image.height, {
|
const result = this.encode(image.data, image.width, image.height, {
|
||||||
quality: 75,
|
quality: 75,
|
||||||
baseline: false,
|
baseline: false,
|
||||||
arithmetic: false,
|
arithmetic: false,
|
||||||
@@ -40,12 +27,26 @@
|
|||||||
chroma_quality: 75,
|
chroma_quality: 75,
|
||||||
});
|
});
|
||||||
|
|
||||||
const blob = new Blob([result], { type: 'image/jpeg' });
|
const blob = new Blob([result], {type: 'image/jpeg'});
|
||||||
const blobURL = URL.createObjectURL(blob);
|
const blobURL = URL.createObjectURL(blob);
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.src = blobURL;
|
img.src = blobURL;
|
||||||
document.body.appendChild(img);
|
document.body.appendChild(img);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadImage(src) {
|
||||||
|
// Load image
|
||||||
|
const img = document.createElement('img');
|
||||||
|
img.src = src;
|
||||||
|
await new Promise(resolve => img.onload = resolve);
|
||||||
|
// Make canvas same size as image
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
[canvas.width, canvas.height] = [img.width, img.height];
|
||||||
|
// Draw image onto canvas
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
ctx.drawImage(img, 0, 0);
|
||||||
|
return ctx.getImageData(0, 0, img.width, img.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
40
codecs/mozjpeg_enc/mozjpeg_enc.d.ts
vendored
40
codecs/mozjpeg_enc/mozjpeg_enc.d.ts
vendored
@@ -1,37 +1,7 @@
|
|||||||
export const enum MozJpegColorSpace {
|
import { EncodeOptions } from '../../src/codecs/mozjpeg/encoder-meta';
|
||||||
GRAYSCALE = 1,
|
|
||||||
RGB,
|
interface MozJPEGModule extends EmscriptenWasm.Module {
|
||||||
YCbCr,
|
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EncodeOptions {
|
export default function(opts: EmscriptenWasm.ModuleOpts): MozJPEGModule;
|
||||||
quality: number;
|
|
||||||
baseline: boolean;
|
|
||||||
arithmetic: boolean;
|
|
||||||
progressive: boolean;
|
|
||||||
optimize_coding: boolean;
|
|
||||||
smoothing: number;
|
|
||||||
color_space: MozJpegColorSpace;
|
|
||||||
quant_table: number;
|
|
||||||
trellis_multipass: boolean;
|
|
||||||
trellis_opt_zero: boolean;
|
|
||||||
trellis_opt_table: boolean;
|
|
||||||
trellis_loops: number;
|
|
||||||
auto_subsample: boolean;
|
|
||||||
chroma_subsample: number;
|
|
||||||
separate_chroma_quality: boolean;
|
|
||||||
chroma_quality: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MozJPEGModule extends EmscriptenWasm.Module {
|
|
||||||
encode(
|
|
||||||
data: BufferSource,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
options: EncodeOptions,
|
|
||||||
): Uint8Array;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare var moduleFactory: EmscriptenWasm.ModuleFactory<MozJPEGModule>;
|
|
||||||
|
|
||||||
export default moduleFactory;
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
BIN
codecs/mozjpeg_enc/mozjpeg_enc.wasm
Executable file → Normal file
BIN
codecs/mozjpeg_enc/mozjpeg_enc.wasm
Executable file → Normal file
Binary file not shown.
295
codecs/oxipng/Cargo.lock
generated
295
codecs/oxipng/Cargo.lock
generated
@@ -1,22 +1,16 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# 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]]
|
[[package]]
|
||||||
name = "adler32"
|
name = "adler32"
|
||||||
version = "1.2.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
|
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.0.1"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-vec"
|
name = "bit-vec"
|
||||||
@@ -44,9 +38,9 @@ checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.4.1"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac"
|
checksum = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
@@ -56,9 +50,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.62"
|
version = "1.0.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40"
|
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
@@ -66,12 +60,6 @@ version = "0.1.10"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cloudflare-zlib"
|
name = "cloudflare-zlib"
|
||||||
version = "0.2.5"
|
version = "0.2.5"
|
||||||
@@ -90,18 +78,6 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "color_quant"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "const_fn"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc"
|
name = "crc"
|
||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
@@ -113,57 +89,58 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.2.1"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
|
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-channel"
|
|
||||||
version = "0.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-deque"
|
name = "crossbeam-deque"
|
||||||
version = "0.8.0"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
|
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
|
||||||
"crossbeam-epoch",
|
"crossbeam-epoch",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
|
"maybe-uninit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-epoch"
|
name = "crossbeam-epoch"
|
||||||
version = "0.9.0"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f"
|
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"autocfg",
|
||||||
"const_fn",
|
"cfg-if",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
"maybe-uninit",
|
||||||
"memoffset",
|
"memoffset",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-queue"
|
||||||
version = "0.8.0"
|
version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5"
|
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"maybe-uninit",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.7.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if",
|
||||||
"const_fn",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -179,34 +156,27 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.6.1"
|
version = "1.5.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hashbrown"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.17"
|
version = "0.1.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
|
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.23.11"
|
version = "0.23.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4f0a8345b33b082aedec2f4d7d4a926b845cee184cbe78b703413066564431b"
|
checksum = "a2397fc43bd5648b7117aabb3c5e62d0e62c194826ec77b0b4d0c41e62744635"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"color_quant",
|
|
||||||
"num-iter",
|
"num-iter",
|
||||||
"num-rational",
|
"num-rational",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
@@ -215,12 +185,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.6.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
|
checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"hashbrown",
|
|
||||||
"rayon",
|
"rayon",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -241,42 +210,39 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.80"
|
version = "0.2.72"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
|
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libdeflate-sys"
|
name = "libdeflater"
|
||||||
version = "0.6.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f5b1582a0ebf8c55a46166c04d7c66f6bb17add3a6cbf69a082ac2219f31671"
|
checksum = "66dca08b13369865b2f6dca1dd05f833985cbe6c12a676b04d55f78b85e80246"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libdeflater"
|
name = "log"
|
||||||
version = "0.6.0"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "93edd93a53970951da84ef733a8b6e30189a8f8a9e19610f69e4cc5bb1f4d654"
|
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libdeflate-sys",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "maybe-uninit"
|
||||||
version = "0.4.11"
|
version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||||
dependencies = [
|
|
||||||
"cfg-if 0.1.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memoffset"
|
name = "memoffset"
|
||||||
version = "0.5.6"
|
version = "0.5.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa"
|
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
@@ -290,21 +256,11 @@ dependencies = [
|
|||||||
"adler32",
|
"adler32",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "miniz_oxide"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
|
|
||||||
dependencies = [
|
|
||||||
"adler",
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.44"
|
version = "0.1.43"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
@@ -312,9 +268,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-iter"
|
name = "num-iter"
|
||||||
version = "0.1.42"
|
version = "0.1.41"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
|
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
@@ -323,9 +279,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-rational"
|
name = "num-rational"
|
||||||
version = "0.3.2"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07"
|
checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
@@ -334,9 +290,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.14"
|
version = "0.2.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
@@ -351,60 +307,43 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "once_cell"
|
|
||||||
version = "1.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "oxipng"
|
name = "oxipng"
|
||||||
version = "4.0.1"
|
version = "3.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9fefb26bde273c3db896a313151301a69e698a7495ee577fe2168ed7065c29c4"
|
checksum = "d5fd695858078338d73862ff3755f820eff0bf4f3304e4b52f22aba53463183a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"cloudflare-zlib",
|
"cloudflare-zlib",
|
||||||
"crc",
|
"crc",
|
||||||
"crossbeam-channel",
|
|
||||||
"image",
|
"image",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools",
|
"itertools",
|
||||||
"libdeflater",
|
"libdeflater",
|
||||||
"log",
|
"log",
|
||||||
"miniz_oxide 0.4.3",
|
"miniz_oxide",
|
||||||
"rayon",
|
|
||||||
"rgb",
|
"rgb",
|
||||||
"rustc_version",
|
"zopfli",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pest"
|
|
||||||
version = "2.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
|
||||||
dependencies = [
|
|
||||||
"ucd-trie",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.16.7"
|
version = "0.16.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970"
|
checksum = "c150bf7479fafe3dd8740dbe48cc33b2a3efb7b0fe3483aced8bbc39f6d0238d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"deflate",
|
"deflate",
|
||||||
"miniz_oxide 0.3.7",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.24"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-xid",
|
"unicode-xid",
|
||||||
]
|
]
|
||||||
@@ -420,9 +359,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.5.0"
|
version = "1.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
|
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"crossbeam-deque",
|
"crossbeam-deque",
|
||||||
@@ -432,12 +371,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon-core"
|
name = "rayon-core"
|
||||||
version = "1.9.0"
|
version = "1.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
|
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
|
||||||
"crossbeam-deque",
|
"crossbeam-deque",
|
||||||
|
"crossbeam-queue",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
@@ -445,63 +384,33 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rgb"
|
name = "rgb"
|
||||||
version = "0.8.25"
|
version = "0.8.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "287f3c3f8236abb92d8b7e36797f19159df4b58f0a658cc3fb6dd3004b1f3bd3"
|
checksum = "90ef54b45ae131327a88597e2463fee4098ad6c88ba7b6af4b3987db8aad4098"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "65c94201b44764d6d1f7e37c15a8289ed55e546c1762c7f1d57f616966e0c181"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.10.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428"
|
|
||||||
dependencies = [
|
|
||||||
"pest",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "squoosh-oxipng"
|
name = "squoosh-oxipng"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-channel",
|
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
|
||||||
"oxipng",
|
"oxipng",
|
||||||
"rayon",
|
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.48"
|
version = "1.0.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
|
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -509,10 +418,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ucd-trie"
|
name = "typed-arena"
|
||||||
version = "0.1.3"
|
version = "1.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-xid"
|
name = "unicode-xid"
|
||||||
@@ -522,19 +431,19 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.68"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
|
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 0.1.10",
|
"cfg-if",
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.68"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f22b422e2a757c35a73774860af8e112bff612ce6cb604224e8e47641a9e4f68"
|
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -547,9 +456,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.68"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6b13312a745c08c469f0b292dd2fcd6411dba5f7160f593da6ef69b64e407038"
|
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
@@ -557,9 +466,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.68"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe"
|
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -570,6 +479,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.68"
|
version = "0.2.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
|
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
|
||||||
|
|
||||||
|
[[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",
|
||||||
|
]
|
||||||
|
|||||||
@@ -5,23 +5,14 @@ authors = ["Ingvar Stepanyan <me@rreverser.com>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.release]
|
|
||||||
wasm-opt = ["-O", "--no-validation"]
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
oxipng = { version = "4.0.0", default-features = false, features = ["libdeflater"] }
|
oxipng = { version = "3.0.0", default-features = false }
|
||||||
wasm-bindgen = "0.2.68"
|
wasm-bindgen = "0.2.64"
|
||||||
log = { version = "0.4.11", features = ["release_max_level_off"] }
|
log = { version = "0.4", features = ["release_max_level_off"] }
|
||||||
rayon = { version = "1.5.0", optional = true }
|
|
||||||
once_cell = { version = "1.5.2", optional = true }
|
|
||||||
crossbeam-channel = { version = "0.5.0", optional = true }
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
||||||
[features]
|
|
||||||
parallel = ["oxipng/parallel", "rayon", "crossbeam-channel", "once_cell"]
|
|
||||||
|
|||||||
12
codecs/oxipng/Dockerfile
Normal file
12
codecs/oxipng/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM rust
|
||||||
|
RUN rustup target add wasm32-unknown-unknown
|
||||||
|
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||||
|
|
||||||
|
RUN mkdir /opt/wabt && \
|
||||||
|
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz | tar -xzf - -C /opt/wabt --strip 1
|
||||||
|
|
||||||
|
RUN mkdir /opt/wasi-sdk && \
|
||||||
|
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar -xzf - -C /opt/wasi-sdk --strip 1
|
||||||
|
|
||||||
|
ENV PATH="/opt/wabt/bin:/opt/wasi-sdk/bin:${PATH}"
|
||||||
|
WORKDIR /src
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
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.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# OxiPNG
|
|
||||||
|
|
||||||
- Source: <https://github.com/shssoichiro/oxipng>
|
|
||||||
- Version: v3.0.0
|
|
||||||
- License: MIT
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
rm -rf pkg,{-parallel}
|
|
||||||
wasm-pack build -t web
|
|
||||||
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' wasm-pack build -t web -d pkg-parallel -- -Z build-std=panic_abort,std --features=parallel
|
|
||||||
# Workaround https://github.com/rustwasm/wasm-bindgen/issues/2133:
|
|
||||||
sed -i "s|maybe_memory:|maybe_memory?:|" pkg-parallel/squoosh_oxipng.d.ts
|
|
||||||
rm pkg{,-parallel}/.gitignore
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "oxipng",
|
"name": "oxipng",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "RUST_IMG=rustlang/rust@sha256:744aeea5a38f95aa7a96ec37269a65f0c6197a1cdd87d6534e12bb869141d807 ../build-rust.sh ./build.sh"
|
"build": "../build-rust.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# OxiPNG
|
|
||||||
|
|
||||||
- Source: <https://github.com/shssoichiro/oxipng>
|
|
||||||
- Version: v3.0.0
|
|
||||||
- License: MIT
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"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
46
codecs/oxipng/pkg-parallel/squoosh_oxipng.d.ts
vendored
@@ -1,46 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
/**
|
|
||||||
* @param {Uint8Array} data
|
|
||||||
* @param {number} level
|
|
||||||
* @returns {Uint8Array}
|
|
||||||
*/
|
|
||||||
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
|
||||||
/**
|
|
||||||
* @param {number} num
|
|
||||||
* @returns {any}
|
|
||||||
*/
|
|
||||||
export function worker_initializer(num: number): any;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function start_main_thread(): void;
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
export function start_worker_thread(): void;
|
|
||||||
|
|
||||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
||||||
|
|
||||||
export interface InitOutput {
|
|
||||||
readonly optimise: (a: number, b: number, c: number, d: number) => void;
|
|
||||||
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 __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>;
|
|
||||||
|
|
||||||
@@ -1,180 +0,0 @@
|
|||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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') {
|
|
||||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
|
|
||||||
Binary file not shown.
@@ -1,12 +0,0 @@
|
|||||||
/* tslint:disable */
|
|
||||||
/* eslint-disable */
|
|
||||||
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 worker_initializer(a: number): number;
|
|
||||||
export function start_main_thread(): void;
|
|
||||||
export function start_worker_thread(): 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;
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# OxiPNG
|
|
||||||
|
|
||||||
- Source: <https://github.com/shssoichiro/oxipng>
|
|
||||||
- Version: v3.0.0
|
|
||||||
- License: MIT
|
|
||||||
22
codecs/oxipng/pkg/squoosh_oxipng.d.ts
vendored
22
codecs/oxipng/pkg/squoosh_oxipng.d.ts
vendored
@@ -6,25 +6,3 @@
|
|||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
||||||
|
|
||||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
||||||
|
|
||||||
export interface InitOutput {
|
|
||||||
readonly memory: WebAssembly.Memory;
|
|
||||||
readonly optimise: (a: number, b: number, c: number, d: number) => void;
|
|
||||||
readonly malloc: (a: number) => number;
|
|
||||||
readonly free: (a: number) => void;
|
|
||||||
readonly __wbindgen_malloc: (a: number) => number;
|
|
||||||
readonly __wbindgen_free: (a: number, b: number) => 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
|
|
||||||
*
|
|
||||||
* @returns {Promise<InitOutput>}
|
|
||||||
*/
|
|
||||||
export default function init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
||||||
|
|
||||||
@@ -1,118 +1,2 @@
|
|||||||
|
import * as wasm from "./squoosh_oxipng_bg.wasm";
|
||||||
let wasm;
|
export * from "./squoosh_oxipng_bg.js";
|
||||||
|
|
||||||
let cachedTextDecoder = new TextDecoder('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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load(module, imports) {
|
|
||||||
if (typeof Response === 'function' && module instanceof Response) {
|
|
||||||
|
|
||||||
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 {
|
|
||||||
|
|
||||||
const instance = await WebAssembly.instantiate(module, imports);
|
|
||||||
|
|
||||||
if (instance instanceof WebAssembly.Instance) {
|
|
||||||
return { instance, module };
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function init(input) {
|
|
||||||
if (typeof input === 'undefined') {
|
|
||||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
|
||||||
}
|
|
||||||
const imports = {};
|
|
||||||
imports.wbg = {};
|
|
||||||
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);
|
|
||||||
|
|
||||||
wasm = instance.exports;
|
|
||||||
init.__wbindgen_wasm_module = module;
|
|
||||||
|
|
||||||
return wasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default init;
|
|
||||||
|
|
||||||
60
codecs/oxipng/pkg/squoosh_oxipng_bg.js
Normal file
60
codecs/oxipng/pkg/squoosh_oxipng_bg.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
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) {
|
||||||
|
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
||||||
|
var len0 = WASM_VECTOR_LEN;
|
||||||
|
wasm.optimise(8, ptr0, len0, level);
|
||||||
|
var r0 = getInt32Memory0()[8 / 4 + 0];
|
||||||
|
var r1 = getInt32Memory0()[8 / 4 + 1];
|
||||||
|
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||||
|
wasm.__wbindgen_free(r0, r1 * 1);
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const __wbindgen_throw = function(arg0, arg1) {
|
||||||
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
|
};
|
||||||
|
|
||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
nightly
|
|
||||||
@@ -1,21 +1,18 @@
|
|||||||
use oxipng::AlphaOptim;
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
mod malloc_shim;
|
mod malloc_shim;
|
||||||
|
|
||||||
#[cfg(feature = "parallel")]
|
use wasm_bindgen::prelude::*;
|
||||||
pub mod parallel;
|
use oxipng::AlphaOptim;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen(catch)]
|
||||||
pub fn optimise(data: &[u8], level: u8) -> Vec<u8> {
|
pub fn optimise(data: &[u8], level: u8) -> Vec<u8> {
|
||||||
let mut options = oxipng::Options::from_preset(level);
|
let mut options = oxipng::Options::from_preset(level);
|
||||||
options.alphas.insert(AlphaOptim::Black);
|
options.alphas.insert(AlphaOptim::Black);
|
||||||
options.alphas.insert(AlphaOptim::White);
|
options.alphas.insert(AlphaOptim::White);
|
||||||
options.alphas.insert(AlphaOptim::Up);
|
options.alphas.insert(AlphaOptim::Up);
|
||||||
options.alphas.insert(AlphaOptim::Down);
|
options.alphas.insert(AlphaOptim::Down);
|
||||||
options.alphas.insert(AlphaOptim::Left);
|
options.alphas.insert(AlphaOptim::Left);
|
||||||
options.alphas.insert(AlphaOptim::Right);
|
options.alphas.insert(AlphaOptim::Right);
|
||||||
|
|
||||||
options.deflate = oxipng::Deflaters::Libdeflater;
|
options.deflate = oxipng::Deflaters::Libdeflater;
|
||||||
oxipng::optimize_from_memory(data, &options).unwrap_throw()
|
oxipng::optimize_from_memory(data, &options).unwrap_throw()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
use crossbeam_channel::{bounded, Receiver, Sender};
|
|
||||||
use once_cell::sync::OnceCell;
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use wasm_bindgen::JsValue;
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern "C" {
|
|
||||||
#[wasm_bindgen(js_namespace = Array, js_name = of)]
|
|
||||||
fn array_of_2(a: JsValue, b: JsValue) -> JsValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is one of the parts that work around Chromium incorrectly implementing postMessage:
|
|
||||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1075645
|
|
||||||
//
|
|
||||||
// rayon::ThreadPoolBuilder (used below) executes spawn handler to populate the worker pool,
|
|
||||||
// and then blocks the current thread until each worker unblocks its (opaque) lock.
|
|
||||||
//
|
|
||||||
// Normally, we could use postMessage directly inside the spawn handler to
|
|
||||||
// post module + memory + threadPtr to each worker, and the block the current thread.
|
|
||||||
//
|
|
||||||
// However, that bug means that postMessage is currently delayed until the next event loop,
|
|
||||||
// which will never spin since we block the current thread, and so the other workers will
|
|
||||||
// never be able to unblock us.
|
|
||||||
//
|
|
||||||
// To work around this problem, we:
|
|
||||||
// 1) Expose `worker_initializer` that returns module + memory pair (without threadPtr)
|
|
||||||
// that workers can be initialised with to become native threads.
|
|
||||||
// JavaScript can postMessage this pair in advance, and asynchronously wait for workers
|
|
||||||
// to acknowledge the receipt.
|
|
||||||
// 2) Create a global communication channel on the Rust side using crossbeam.
|
|
||||||
// It will be used to send threadPtr to the pre-initialised workers
|
|
||||||
// instead of postMessage.
|
|
||||||
// 3) Provide a separate `start_main_thread` that expects all workers to be ready,
|
|
||||||
// and just uses the provided channel to send `threadPtr`s using the
|
|
||||||
// shared memory and blocks the current thread until they're all grabbed.
|
|
||||||
// 4) Provide a `worker_initializer` that is expected to be invoked from various workers,
|
|
||||||
// reads one `threadPtr` from the shared channel and starts running it.
|
|
||||||
static CHANNEL: OnceCell<(Sender<rayon::ThreadBuilder>, Receiver<rayon::ThreadBuilder>)> =
|
|
||||||
OnceCell::new();
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn worker_initializer(num: usize) -> JsValue {
|
|
||||||
CHANNEL.get_or_init(|| bounded(num));
|
|
||||||
array_of_2(wasm_bindgen::module(), wasm_bindgen::memory())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn start_main_thread() {
|
|
||||||
let (sender, _) = CHANNEL.get().unwrap();
|
|
||||||
|
|
||||||
rayon::ThreadPoolBuilder::new()
|
|
||||||
.num_threads(sender.capacity().unwrap())
|
|
||||||
.spawn_handler(|thread| Ok(sender.send(thread).unwrap_throw()))
|
|
||||||
.build_global()
|
|
||||||
.unwrap_throw()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn start_worker_thread() {
|
|
||||||
let (_, receiver) = CHANNEL.get().unwrap();
|
|
||||||
receiver.recv().unwrap_throw().run()
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2015 PistonDevelopers
|
|
||||||
|
|
||||||
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.
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Resize
|
|
||||||
|
|
||||||
- Source: <https://github.com/PistonDevelopers/resize>
|
|
||||||
- Version: v0.3.0
|
|
||||||
- License: MIT
|
|
||||||
68
codecs/resize/pkg/squoosh_resize.d.ts
vendored
68
codecs/resize/pkg/squoosh_resize.d.ts
vendored
@@ -1,60 +1,14 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* @param {Uint8Array} input_image
|
* @param {Uint8Array} input_image
|
||||||
* @param {number} input_width
|
* @param {number} input_width
|
||||||
* @param {number} input_height
|
* @param {number} input_height
|
||||||
* @param {number} output_width
|
* @param {number} output_width
|
||||||
* @param {number} output_height
|
* @param {number} output_height
|
||||||
* @param {number} typ_idx
|
* @param {number} typ_idx
|
||||||
* @param {boolean} premultiply
|
* @param {boolean} premultiply
|
||||||
* @param {boolean} color_space_conversion
|
* @param {boolean} color_space_conversion
|
||||||
* @returns {Uint8Array}
|
* @returns {Uint8Array}
|
||||||
*/
|
*/
|
||||||
export function resize(
|
export function resize(input_image: Uint8Array, input_width: number, input_height: number, output_width: number, output_height: number, typ_idx: number, premultiply: boolean, color_space_conversion: boolean): Uint8Array;
|
||||||
input_image: Uint8Array,
|
|
||||||
input_width: number,
|
|
||||||
input_height: number,
|
|
||||||
output_width: number,
|
|
||||||
output_height: number,
|
|
||||||
typ_idx: number,
|
|
||||||
premultiply: boolean,
|
|
||||||
color_space_conversion: boolean,
|
|
||||||
): Uint8Array;
|
|
||||||
|
|
||||||
export type InitInput =
|
|
||||||
| RequestInfo
|
|
||||||
| URL
|
|
||||||
| Response
|
|
||||||
| BufferSource
|
|
||||||
| WebAssembly.Module;
|
|
||||||
|
|
||||||
export interface InitOutput {
|
|
||||||
readonly memory: WebAssembly.Memory;
|
|
||||||
readonly resize: (
|
|
||||||
a: number,
|
|
||||||
b: number,
|
|
||||||
c: number,
|
|
||||||
d: number,
|
|
||||||
e: number,
|
|
||||||
f: number,
|
|
||||||
g: number,
|
|
||||||
h: number,
|
|
||||||
i: number,
|
|
||||||
j: number,
|
|
||||||
) => void;
|
|
||||||
readonly __wbindgen_malloc: (a: number) => number;
|
|
||||||
readonly __wbindgen_free: (a: number, b: number) => 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
|
|
||||||
*
|
|
||||||
* @returns {Promise<InitOutput>}
|
|
||||||
*/
|
|
||||||
export default function init(
|
|
||||||
module_or_path?: InitInput | Promise<InitInput>,
|
|
||||||
): Promise<InitOutput>;
|
|
||||||
|
|||||||
@@ -1,131 +1,2 @@
|
|||||||
let wasm;
|
import * as wasm from "./squoosh_resize_bg.wasm";
|
||||||
|
export * from "./squoosh_resize_bg.js";
|
||||||
let cachegetUint8Memory0 = null;
|
|
||||||
function getUint8Memory0() {
|
|
||||||
if (
|
|
||||||
cachegetUint8Memory0 === null ||
|
|
||||||
cachegetUint8Memory0.buffer !== wasm.memory.buffer
|
|
||||||
) {
|
|
||||||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
||||||
}
|
|
||||||
return cachegetUint8Memory0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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} input_image
|
|
||||||
* @param {number} input_width
|
|
||||||
* @param {number} input_height
|
|
||||||
* @param {number} output_width
|
|
||||||
* @param {number} output_height
|
|
||||||
* @param {number} typ_idx
|
|
||||||
* @param {boolean} premultiply
|
|
||||||
* @param {boolean} color_space_conversion
|
|
||||||
* @returns {Uint8Array}
|
|
||||||
*/
|
|
||||||
export function resize(
|
|
||||||
input_image,
|
|
||||||
input_width,
|
|
||||||
input_height,
|
|
||||||
output_width,
|
|
||||||
output_height,
|
|
||||||
typ_idx,
|
|
||||||
premultiply,
|
|
||||||
color_space_conversion,
|
|
||||||
) {
|
|
||||||
var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
|
|
||||||
var len0 = WASM_VECTOR_LEN;
|
|
||||||
wasm.resize(
|
|
||||||
8,
|
|
||||||
ptr0,
|
|
||||||
len0,
|
|
||||||
input_width,
|
|
||||||
input_height,
|
|
||||||
output_width,
|
|
||||||
output_height,
|
|
||||||
typ_idx,
|
|
||||||
premultiply,
|
|
||||||
color_space_conversion,
|
|
||||||
);
|
|
||||||
var r0 = getInt32Memory0()[8 / 4 + 0];
|
|
||||||
var r1 = getInt32Memory0()[8 / 4 + 1];
|
|
||||||
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
||||||
wasm.__wbindgen_free(r0, r1 * 1);
|
|
||||||
return v1;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function load(module, imports) {
|
|
||||||
if (typeof Response === 'function' && module instanceof Response) {
|
|
||||||
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 {
|
|
||||||
const instance = await WebAssembly.instantiate(module, imports);
|
|
||||||
|
|
||||||
if (instance instanceof WebAssembly.Instance) {
|
|
||||||
return { instance, module };
|
|
||||||
} else {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function init(input) {
|
|
||||||
if (typeof input === 'undefined') {
|
|
||||||
input = import.meta.url.replace(/\.js$/, '_bg.wasm');
|
|
||||||
}
|
|
||||||
const imports = {};
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
wasm = instance.exports;
|
|
||||||
init.__wbindgen_wasm_module = module;
|
|
||||||
|
|
||||||
return wasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default init;
|
|
||||||
52
codecs/resize/pkg/squoosh_resize_bg.js
Normal file
52
codecs/resize/pkg/squoosh_resize_bg.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import * as wasm from './squoosh_resize_bg.wasm';
|
||||||
|
|
||||||
|
let cachegetUint8Memory0 = null;
|
||||||
|
function getUint8Memory0() {
|
||||||
|
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
||||||
|
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
||||||
|
}
|
||||||
|
return cachegetUint8Memory0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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} input_image
|
||||||
|
* @param {number} input_width
|
||||||
|
* @param {number} input_height
|
||||||
|
* @param {number} output_width
|
||||||
|
* @param {number} output_height
|
||||||
|
* @param {number} typ_idx
|
||||||
|
* @param {boolean} premultiply
|
||||||
|
* @param {boolean} color_space_conversion
|
||||||
|
* @returns {Uint8Array}
|
||||||
|
*/
|
||||||
|
export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
|
||||||
|
var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
|
||||||
|
var len0 = WASM_VECTOR_LEN;
|
||||||
|
wasm.resize(8, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);
|
||||||
|
var r0 = getInt32Memory0()[8 / 4 + 0];
|
||||||
|
var r1 = getInt32Memory0()[8 / 4 + 1];
|
||||||
|
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
||||||
|
wasm.__wbindgen_free(r0, r1 * 1);
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,9 @@
|
|||||||
ARG RUST_IMG=rust:1.47
|
FROM emscripten/emsdk:1.39.19 AS wasm-tools
|
||||||
|
|
||||||
FROM emscripten/emsdk:2.0.8 AS wasm-tools
|
|
||||||
WORKDIR /opt/wasm-tools
|
WORKDIR /opt/wasm-tools
|
||||||
RUN wget -qO- https://github.com/rustwasm/wasm-pack/releases/download/v0.9.1/wasm-pack-v0.9.1-x86_64-unknown-linux-musl.tar.gz | tar -xzf - --strip 1
|
RUN wget -qO- https://github.com/rustwasm/wasm-pack/releases/download/v0.9.1/wasm-pack-v0.9.1-x86_64-unknown-linux-musl.tar.gz | tar -xzf - --strip 1
|
||||||
|
|
||||||
FROM $RUST_IMG AS rust
|
FROM rust:1.44-stretch AS rust
|
||||||
ARG RUST_IMG
|
|
||||||
RUN rustup target add wasm32-unknown-unknown
|
RUN rustup target add wasm32-unknown-unknown
|
||||||
RUN case $RUST_IMG in rustlang/rust@*) rustup component add rust-src; esac
|
|
||||||
COPY --from=wasm-tools /emsdk/upstream/bin/wasm-opt /emsdk/upstream/bin/clang /usr/local/bin/
|
COPY --from=wasm-tools /emsdk/upstream/bin/wasm-opt /emsdk/upstream/bin/clang /usr/local/bin/
|
||||||
COPY --from=wasm-tools /emsdk/upstream/lib/ /usr/local/lib/
|
COPY --from=wasm-tools /emsdk/upstream/lib/ /usr/local/lib/
|
||||||
COPY --from=wasm-tools /emsdk/upstream/emscripten/system/include/libc/ /wasm32/include/
|
COPY --from=wasm-tools /emsdk/upstream/emscripten/system/include/libc/ /wasm32/include/
|
||||||
@@ -16,4 +12,4 @@ COPY --from=wasm-tools /opt/wasm-tools/wasm-pack /usr/local/cargo/bin/
|
|||||||
|
|
||||||
ENV CPATH="/wasm32/include"
|
ENV CPATH="/wasm32/include"
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
CMD ["sh", "-c", "rm -rf pkg && wasm-pack build --target web -- --verbose --locked && rm pkg/.gitignore"]
|
CMD ["sh", "-c", "rm -rf pkg && wasm-pack build -- --verbose --locked && rm pkg/.gitignore"]
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
Copyright (c) 2010, Google Inc. 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 Google nor the names of its contributors may
|
|
||||||
be used to endorse or promote products derived from this software
|
|
||||||
without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
CODEC_URL := https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz
|
CODEC_URL := https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
|
||||||
CODEC_DIR = node_modules/libwebp
|
CODEC_DIR = node_modules/libwebp
|
||||||
CODEC_OUT_RELATIVE = src/.libs/libwebp.a
|
CODEC_OUT_RELATIVE = src/.libs/libwebp.a
|
||||||
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
||||||
@@ -18,9 +18,7 @@ all: $(OUT_JS)
|
|||||||
--closure 1 \
|
--closure 1 \
|
||||||
-s ALLOW_MEMORY_GROWTH=1 \
|
-s ALLOW_MEMORY_GROWTH=1 \
|
||||||
-s MODULARIZE=1 \
|
-s MODULARIZE=1 \
|
||||||
-s TEXTDECODER=2 \
|
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||||
-s ENVIRONMENT='worker' \
|
|
||||||
-s EXPORT_ES6=1 \
|
|
||||||
-o $@ \
|
-o $@ \
|
||||||
$+
|
$+
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# WebP
|
|
||||||
|
|
||||||
- Source: https://github.com/webmproject/libwebp
|
|
||||||
- Version: v1.0.2
|
|
||||||
- License: BSD
|
|
||||||
@@ -1,20 +1,22 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<script src='webp_dec.js'></script>
|
<script src='webp_dec.js'></script>
|
||||||
<script>
|
<script>
|
||||||
|
const Module = webp_dec();
|
||||||
|
|
||||||
async function loadFile(src) {
|
async function loadFile(src) {
|
||||||
const resp = await fetch(src);
|
const resp = await fetch(src);
|
||||||
return await resp.arrayBuffer();
|
return await resp.arrayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
webp_dec().then(async module => {
|
Module.onRuntimeInitialized = async _ => {
|
||||||
console.log('Version:', module.version().toString(16));
|
console.log('Version:', Module.version().toString(16));
|
||||||
const image = await loadFile('../../example.webp');
|
const image = await loadFile('../../example.webp');
|
||||||
const imageData = module.decode(image);
|
const imageData = Module.decode(image);
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = imageData.width;
|
canvas.width = result.width;
|
||||||
canvas.height = imageData.height;
|
canvas.height = result.height;
|
||||||
document.body.appendChild(canvas);
|
document.body.appendChild(canvas);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.putImageData(imageData, 0, 0);
|
ctx.putImageData(imageData, 0, 0);
|
||||||
});
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user