-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
Session
to expose decoding steps
- Loading branch information
Showing
10 changed files
with
639 additions
and
266 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"default": true, | ||
"MD024": { | ||
"siblings_only": true | ||
} | ||
} |
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,49 +1,49 @@ | ||
# Changelog | ||
|
||
## [Unreleased] | ||
|
||
## [0.11.1+libjxl-0.11.0](https://github.com/inflation/jpegxl-rs/compare/jpegxl-rs-v0.11.0+libjxl-0.11.0...jpegxl-rs-v0.11.1+libjxl-0.11.0) - 2024-10-01 | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- Fix doc gen | ||
|
||
### 📚 Documentation | ||
|
||
- Remove docsrs-specific reference to deleted "threads" feature | ||
|
||
## [0.11.0+libjxl-0.11.0](https://github.com/inflation/jpegxl-rs/compare/jpegxl-rs-v0.10.4+libjxl-0.10.3...jpegxl-rs-v0.11.0+libjxl-0.11.0) - 2024-09-27 | ||
|
||
### ⛰️ Features | ||
|
||
- Update JPEG quality setting in encoder ([#74](https://github.com/inflation/jpegxl-rs/pull/74)) | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- Update release configuration for jpegxl-rs and jpegxl-sys packages | ||
- Change ffi function types to use `c-unwind` ABI | ||
- Change `JxlBoxType` to use system char type | ||
|
||
### 🚜 Refactor | ||
|
||
- Move `libjxl` functions into modules | ||
- Remove threads feature and update dependencies. | ||
- Don't use `-sys` in `-rs` with default features enabled | ||
|
||
### 📚 Documentation | ||
|
||
- Convert `libjxl` doc to rustdoc format with help from @copilot | ||
- Remove unnecessary feature attribute in thread pool implementations | ||
- Update how docs are generated ([#73](https://github.com/inflation/jpegxl-rs/pull/73)) | ||
|
||
### 📦 Dependencies | ||
|
||
- Bump thiserror from 1.0.61 to 1.0.64 | ||
- Bump pretty_assertions from 1.4.0 to 1.4.1 | ||
- Bump derive_builder from 0.20.0 to 0.20.1 | ||
- Bump testresult from 0.4.0 to 0.4.1 | ||
- Bump image from 0.25.1 to 0.25.2 | ||
|
||
### ⚙️ Miscellaneous Tasks | ||
|
||
- Update release-plz workflow and config | ||
# Changelog | ||
|
||
## [Unreleased] | ||
|
||
## [0.11.1+libjxl-0.11.0](https://github.com/inflation/jpegxl-rs/compare/jpegxl-rs-v0.11.0+libjxl-0.11.0...jpegxl-rs-v0.11.1+libjxl-0.11.0) - 2024-10-01 | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- Fix doc gen | ||
|
||
### 📚 Documentation | ||
|
||
- Remove docsrs-specific reference to deleted "threads" feature | ||
|
||
## [0.11.0+libjxl-0.11.0](https://github.com/inflation/jpegxl-rs/compare/jpegxl-rs-v0.10.4+libjxl-0.10.3...jpegxl-rs-v0.11.0+libjxl-0.11.0) - 2024-09-27 | ||
|
||
### ⛰️ Features | ||
|
||
- Update JPEG quality setting in encoder ([#74](https://github.com/inflation/jpegxl-rs/pull/74)) | ||
|
||
### 🐛 Bug Fixes | ||
|
||
- Update release configuration for jpegxl-rs and jpegxl-sys packages | ||
- Change ffi function types to use `c-unwind` ABI | ||
- Change `JxlBoxType` to use system char type | ||
|
||
### 🚜 Refactor | ||
|
||
- Move `libjxl` functions into modules | ||
- Remove threads feature and update dependencies. | ||
- Don't use `-sys` in `-rs` with default features enabled | ||
|
||
### 📚 Documentation | ||
|
||
- Convert `libjxl` doc to rustdoc format with help from @copilot | ||
- Remove unnecessary feature attribute in thread pool implementations | ||
- Update how docs are generated ([#73](https://github.com/inflation/jpegxl-rs/pull/73)) | ||
|
||
### 📦 Dependencies | ||
|
||
- Bump thiserror from 1.0.61 to 1.0.64 | ||
- Bump pretty_assertions from 1.4.0 to 1.4.1 | ||
- Bump derive_builder from 0.20.0 to 0.20.1 | ||
- Bump testresult from 0.4.0 to 0.4.1 | ||
- Bump image from 0.25.1 to 0.25.2 | ||
|
||
### ⚙️ Miscellaneous Tasks | ||
|
||
- Update release-plz workflow and config |
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,71 +1,71 @@ | ||
[package] | ||
authors = ["Inflation <[email protected]>"] | ||
categories = ["api-bindings", "encoding", "multimedia::images"] | ||
description = "Safe Rust wrapper for JPEG XL reference implementation" | ||
edition = "2021" | ||
keywords = ["jpeg-xl", "jxl"] | ||
license = "GPL-3.0-or-later" | ||
name = "jpegxl-rs" | ||
readme = "README.md" | ||
repository = "https://github.com/inflation/jpegxl-rs" | ||
version = "0.11.1+libjxl-0.11.0" | ||
rust-version.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lints.rust] | ||
missing_docs = "warn" | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] } | ||
|
||
[lints.clippy] | ||
pedantic = "warn" | ||
|
||
[features] | ||
default = ["image"] | ||
image = ["dep:image"] | ||
vendored = ["jpegxl-sys/vendored"] | ||
docs = ["jpegxl-sys/docs"] | ||
bench = [] | ||
|
||
[dependencies] | ||
derive_builder = "0.20.1" | ||
image = { version = "0.25.2", optional = true, default-features = false } | ||
thiserror = "1.0.64" | ||
half = "2.4.1" | ||
byteorder = "1.5.0" | ||
|
||
[dependencies.jpegxl-sys] | ||
version = "0.11.1" | ||
path = "../jpegxl-sys" | ||
default-features = false | ||
|
||
[dev-dependencies] | ||
image = { version = "0.25.2", default-features = false, features = [ | ||
"jpeg", | ||
"png", | ||
] } | ||
lcms2 = "6.1.0" | ||
pretty_assertions = "1.4.1" | ||
testresult = "0.4.1" | ||
|
||
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies] | ||
criterion = "0.5.1" | ||
|
||
|
||
[package.metadata.docs.rs] | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
features = ["docs"] | ||
|
||
[lib] | ||
bench = false | ||
path = "src/lib.rs" | ||
|
||
[[bench]] | ||
harness = false | ||
name = "decode" | ||
required-features = ["bench"] | ||
|
||
[[bench]] | ||
harness = false | ||
name = "encode" | ||
required-features = ["bench"] | ||
[package] | ||
authors = ["Inflation <[email protected]>"] | ||
categories = ["api-bindings", "encoding", "multimedia::images"] | ||
description = "Safe Rust wrapper for JPEG XL reference implementation" | ||
edition = "2021" | ||
keywords = ["jpeg-xl", "jxl"] | ||
license = "GPL-3.0-or-later" | ||
name = "jpegxl-rs" | ||
readme = "README.md" | ||
repository = "https://github.com/inflation/jpegxl-rs" | ||
version = "0.11.1+libjxl-0.11.0" | ||
rust-version.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lints.rust] | ||
missing_docs = "warn" | ||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] } | ||
|
||
[lints.clippy] | ||
pedantic = "warn" | ||
|
||
[features] | ||
default = ["image"] | ||
image = ["dep:image"] | ||
vendored = ["jpegxl-sys/vendored"] | ||
docs = ["jpegxl-sys/docs"] | ||
bench = [] | ||
|
||
[dependencies] | ||
derive_builder = "0.20.1" | ||
image = { version = "0.25.2", optional = true, default-features = false } | ||
thiserror = "1.0.64" | ||
half = "2.4.1" | ||
byteorder = "1.5.0" | ||
|
||
[dependencies.jpegxl-sys] | ||
version = "0.11.1" | ||
path = "../jpegxl-sys" | ||
default-features = false | ||
|
||
[dev-dependencies] | ||
image = { version = "0.25.2", default-features = false, features = [ | ||
"jpeg", | ||
"png", | ||
] } | ||
lcms2 = "6.1.0" | ||
pretty_assertions = "1.4.1" | ||
testresult = "0.4.1" | ||
|
||
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies] | ||
criterion = "0.5.1" | ||
|
||
|
||
[package.metadata.docs.rs] | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
features = ["docs"] | ||
|
||
[lib] | ||
bench = false | ||
path = "src/lib.rs" | ||
|
||
[[bench]] | ||
harness = false | ||
name = "decode" | ||
required-features = ["bench"] | ||
|
||
[[bench]] | ||
harness = false | ||
name = "encode" | ||
required-features = ["bench"] |
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,55 @@ | ||
use std::ffi::c_int; | ||
|
||
use jpegxl_sys::common::types::JxlPixelFormat; | ||
/// Target of the color profile. | ||
pub use jpegxl_sys::decode::JxlColorProfileTarget as ColorProfileTarget; | ||
|
||
use super::{ColorEncodingConfig, Config}; | ||
|
||
/// Events that can be subscribed to. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
pub enum Event { | ||
/// Basic information. | ||
BasicInfo, | ||
/// Color encoding. | ||
ColorEncoding(ColorEncodingConfig), | ||
/// Preview image. | ||
PreviewImage { | ||
/// Pixel format. | ||
pixel_format: JxlPixelFormat, | ||
}, | ||
/// JPEG reconstruction. | ||
JpegReconstruction { | ||
/// Initial buffer size. Increase it to reduce the number of reallocations. | ||
init_buffer_size: usize, | ||
}, | ||
} | ||
|
||
impl From<Event> for c_int { | ||
fn from(value: Event) -> Self { | ||
match value { | ||
Event::BasicInfo => 0x40, | ||
Event::ColorEncoding(_) => 0x100, | ||
Event::PreviewImage { .. } => 0x200, | ||
Event::JpegReconstruction { .. } => 0x2000, | ||
} | ||
} | ||
} | ||
|
||
pub(crate) fn parse_events<I>(iter: I) -> (c_int, Config) | ||
where | ||
I: IntoIterator<Item = Event>, | ||
{ | ||
iter.into_iter() | ||
.fold((0, Config::default()), |(flag, mut config), x| { | ||
let flag = flag | c_int::from(x); | ||
let config = match x { | ||
Event::ColorEncoding(val) => { | ||
config.color_profile = Some(val); | ||
config | ||
} | ||
_ => config, | ||
}; | ||
(flag, config) | ||
}) | ||
} |
Oops, something went wrong.