-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/high-resolution-screenshot
- Loading branch information
Showing
17 changed files
with
554 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 William Silversmith | ||
* 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. | ||
*/ | ||
|
||
import { decodeJxl } from "#src/async_computation/decode_jxl_request.js"; | ||
import { registerAsyncComputation } from "#src/async_computation/handler.js"; | ||
import { decompressJxl } from "#src/sliceview/jxl/index.js"; | ||
|
||
registerAsyncComputation( | ||
decodeJxl, | ||
async ( | ||
data: Uint8Array, | ||
area: number | undefined, | ||
numComponents: number | undefined, | ||
bytesPerPixel: number, | ||
) => { | ||
const result = await decompressJxl( | ||
data, | ||
area, | ||
numComponents, | ||
bytesPerPixel, | ||
); | ||
return { value: result, transfer: [result.uint8Array.buffer] }; | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 William Silversmith | ||
* 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. | ||
*/ | ||
import type { DecodedImage } from "#src/async_computation/decode_png_request.js"; | ||
import { asyncComputation } from "#src/async_computation/index.js"; | ||
|
||
export const decodeJxl = | ||
asyncComputation< | ||
( | ||
data: Uint8Array, | ||
area: number | undefined, | ||
numComponents: number | undefined, | ||
bytesPerPixel: number, | ||
) => DecodedImage | ||
>("decodeJxl"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import "#src/async_computation/decode_jpeg.js"; | ||
import "#src/async_computation/decode_jxl.js"; | ||
import "#src/async_computation/decode_gzip.js"; | ||
import "#src/async_computation/decode_compresso.js"; | ||
import "#src/async_computation/decode_png.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license | ||
* Copyright 2016 Google Inc. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { decodeJxl } from "#src/async_computation/decode_jxl_request.js"; | ||
import { requestAsyncComputation } from "#src/async_computation/request.js"; | ||
import { postProcessRawData } from "#src/sliceview/backend_chunk_decoders/postprocess.js"; | ||
import type { VolumeChunk } from "#src/sliceview/volume/backend.js"; | ||
import type { CancellationToken } from "#src/util/cancellation.js"; | ||
|
||
export async function decodeJxlChunk( | ||
chunk: VolumeChunk, | ||
cancellationToken: CancellationToken, | ||
response: ArrayBuffer, | ||
) { | ||
const chunkDataSize = chunk.chunkDataSize!; | ||
const { uint8Array: decoded } = await requestAsyncComputation( | ||
decodeJxl, | ||
cancellationToken, | ||
[response], | ||
new Uint8Array(response), | ||
chunkDataSize[0] * chunkDataSize[1] * chunkDataSize[2], | ||
chunkDataSize[3] || 1, | ||
1, // bytesPerPixel | ||
); | ||
await postProcessRawData(chunk, cancellationToken, decoded); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "jxl-wasm" | ||
version = "1.0.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
jxl-oxide = "0.9.1" | ||
|
||
[profile.release] | ||
lto = true | ||
|
||
[package.metadata.wasm-opt] | ||
memory = { initial = 10, maximum = 100 } # Set initial and max memory in MiB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM rust:slim-bullseye | ||
|
||
RUN rustup target add wasm32-unknown-unknown | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash -xve | ||
|
||
# This script builds `jxl_decoder.wasm` using emsdk in a docker container. | ||
|
||
cd "$(dirname "$0")" | ||
|
||
docker build . | ||
docker run \ | ||
--rm \ | ||
-v ${PWD}:/src \ | ||
-u $(id -u):$(id -g) \ | ||
$(docker build -q .) \ | ||
/src/build_wasm.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash -xve | ||
|
||
cd /src | ||
cargo build --target wasm32-unknown-unknown --release | ||
cp /src/target/wasm32-unknown-unknown/release/jxl_wasm.wasm /src/jxl_decoder.wasm | ||
rm -r target |
Oops, something went wrong.