Skip to content

Commit

Permalink
⬆️ Upgrade libjxl v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
inflation committed Jan 17, 2024
1 parent a72176a commit f4498b1
Show file tree
Hide file tree
Showing 23 changed files with 315 additions and 296 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "libjxl"]
path = jpegxl-src/libjxl
url = https://github.com/libjxl/libjxl
branch = tags/v0.8.2
branch = tags/v0.9.1
8 changes: 4 additions & 4 deletions jpegxl-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later"
name = "jpegxl-rs"
readme = "README.md"
repository = "https://github.com/inflation/jpegxl-rs"
version = "0.8.3+libjxl-0.8.2"
version = "0.9.0+libjxl-0.9.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -29,20 +29,20 @@ bench = []
[dependencies]
derive_builder = "0.12.0"
image = { version = "0.24.7", optional = true, default-features = false }
thiserror = "1.0.50"
thiserror = "1.0.51"
half = "2.3.1"
byteorder = "1.5.0"

[dependencies.jpegxl-sys]
version = "0.8.2"
version = "0.9.0"
path = "../jpegxl-sys"

[dev-dependencies]
image = { version = "0.24.7", default-features = false, features = [
"jpeg",
"png",
] }
lcms2 = "6.0.0"
lcms2 = "6.0.3"
testresult = "0.3.0"

[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
Expand Down
5 changes: 3 additions & 2 deletions jpegxl-rs/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.
use byteorder::{ByteOrder, NativeEndian, BE, LE};
use half::f16;
use jpegxl_sys::{JxlDataType, JxlPixelFormat};

use jpegxl_sys::types::{JxlDataType, JxlPixelFormat};

/// Endianness of the pixels
pub type Endianness = jpegxl_sys::JxlEndianness;
pub type Endianness = jpegxl_sys::types::JxlEndianness;

mod private {
pub trait Sealed {}
Expand Down
17 changes: 7 additions & 10 deletions jpegxl-rs/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.
use std::{mem::MaybeUninit, ptr::null};

#[allow(clippy::wildcard_imports)]
use jpegxl_sys::*;
use jpegxl_sys::{
codestream_header::{JxlBasicInfo, JxlOrientation},
decode::*,
types::{JxlDataType, JxlPixelFormat},
};

use crate::{
common::{Endianness, PixelType},
Expand Down Expand Up @@ -84,7 +88,7 @@ impl Default for PixelFormat {
pub struct JxlDecoder<'pr, 'mm> {
/// Opaque pointer to the underlying decoder
#[builder(setter(skip))]
dec: *mut jpegxl_sys::JxlDecoder,
dec: *mut jpegxl_sys::decode::JxlDecoder,

/// Override desired pixel format
pub pixel_format: Option<PixelFormat>,
Expand Down Expand Up @@ -298,7 +302,6 @@ impl<'pr, 'mm> JxlDecoder<'pr, 'mm> {
}
s::NeedPreviewOutBuffer => todo!(),
s::BoxNeedMoreOutput => todo!(),
s::Extensions => todo!(),
s::PreviewImage => todo!(),
s::Frame => todo!(),
s::Box => todo!(),
Expand Down Expand Up @@ -351,19 +354,13 @@ impl<'pr, 'mm> JxlDecoder<'pr, 'mm> {
fn get_icc_profile(&self, icc_profile: &mut Vec<u8>) -> Result<(), DecodeError> {
let mut icc_size = 0;
check_dec_status(unsafe {
JxlDecoderGetICCProfileSize(
self.dec,
null(),
JxlColorProfileTarget::Data,
&mut icc_size,
)
JxlDecoderGetICCProfileSize(self.dec, JxlColorProfileTarget::Data, &mut icc_size)
})?;
icc_profile.resize(icc_size, 0);

check_dec_status(unsafe {
JxlDecoderGetColorAsICCProfile(
self.dec,
null(),
JxlColorProfileTarget::Data,
icc_profile.as_mut_ptr(),
icc_size,
Expand Down
2 changes: 1 addition & 1 deletion jpegxl-rs/src/decode/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.
*/

use half::f16;
use jpegxl_sys::{JxlDataType, JxlPixelFormat};
use jpegxl_sys::types::{JxlDataType, JxlPixelFormat};

use super::Orientation;
use crate::common::PixelType;
Expand Down
13 changes: 8 additions & 5 deletions jpegxl-rs/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.

//! Encoder of JPEG XL format
#[allow(clippy::wildcard_imports)]
use jpegxl_sys::*;
use std::{marker::PhantomData, mem::MaybeUninit, ops::Deref, ptr::null};

#[allow(clippy::wildcard_imports)]
use jpegxl_sys::{
color_encoding::JxlColorEncoding,
encode::*,
types::{JxlEndianness, JxlPixelFormat},
};

use crate::{
common::PixelType, errors::EncodeError, memory::MemoryManager, parallel::JxlParallelRunner,
};
Expand Down Expand Up @@ -165,7 +170,7 @@ impl<U: PixelType> Deref for EncoderResult<U> {
pub struct JxlEncoder<'prl, 'mm> {
/// Opaque pointer to the underlying encoder
#[builder(setter(skip))]
enc: *mut jpegxl_sys::JxlEncoder,
enc: *mut jpegxl_sys::encode::JxlEncoder,
/// Opaque pointer to the encoder options
#[builder(setter(skip))]
options_ptr: *mut JxlEncoderFrameSettings,
Expand Down Expand Up @@ -289,8 +294,6 @@ impl JxlEncoder<'_, '_> {
JxlEncoderError::NotSupported => Err(EncodeError::NotSupported),
JxlEncoderError::ApiUsage => Err(EncodeError::ApiUsage),
},
#[allow(deprecated)]
JxlEncoderStatus::NotSupported => Err(EncodeError::NotSupported),
JxlEncoderStatus::NeedMoreOutput => Err(EncodeError::NeedMoreOutput),
}
}
Expand Down
4 changes: 2 additions & 2 deletions jpegxl-rs/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.

//! Decoder and encoder errors
#[allow(clippy::wildcard_imports)]
use jpegxl_sys::*;
use thiserror::Error;

use jpegxl_sys::{decode::JxlDecoderStatus, encode::JxlEncoderError};

/// Errors derived from [`JxlDecoderStatus`]
#[derive(Error, Debug)]
#[non_exhaustive]
Expand Down
2 changes: 1 addition & 1 deletion jpegxl-rs/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.
use std::mem::MaybeUninit;

use image::{DynamicImage, ImageBuffer};
use jpegxl_sys::{JxlDataType, JxlPixelFormat};
use jpegxl_sys::types::{JxlDataType, JxlPixelFormat};

use crate::{
common::PixelType,
Expand Down
2 changes: 1 addition & 1 deletion jpegxl-rs/src/tests/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn gray() -> TestResult {
)?;
_ = decoder.decode(&result)?;

encoder.set_frame_option(jpegxl_sys::FrameSetting::BrotliEffort, 1)?;
encoder.set_frame_option(jpegxl_sys::encode::FrameSetting::BrotliEffort, 1)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion jpegxl-rs/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>.

//! Utils functions when a decoder or encoder is not needed
use jpegxl_sys::{JxlSignature, JxlSignatureCheck};
use jpegxl_sys::decode::{JxlSignature, JxlSignatureCheck};

/// Check if the signature of the input is valid.
/// Return `None` if it needs more data.
Expand Down
4 changes: 3 additions & 1 deletion jpegxl-src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ license = "BSD-3-Clause"
name = "jpegxl-src"
readme = "README.md"
repository = "https://github.com/inflation/jpegxl-rs"
version = "0.8.2"
version = "0.9.1"
exclude = [
"libjxl/third_party/libpng",
"libjxl/third_party/sjpeg",
Expand All @@ -33,3 +33,5 @@ exclude = [

[dependencies]
cmake = "0.1.50"

[features]
2 changes: 1 addition & 1 deletion jpegxl-src/libjxl
Submodule libjxl updated 783 files
33 changes: 10 additions & 23 deletions jpegxl-src/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::{
env,
num::NonZeroUsize,
path::{Path, PathBuf},
};

Expand All @@ -17,15 +16,9 @@ fn source_dir() -> PathBuf {
pub fn build() {
let source = source_dir();

env::set_var(
"CMAKE_BUILD_PARALLEL_LEVEL",
format!(
"{}",
std::thread::available_parallelism()
.map(NonZeroUsize::get)
.unwrap_or(1)
),
);
if let Ok(p) = std::thread::available_parallelism() {
env::set_var("CMAKE_BUILD_PARALLEL_LEVEL", format!("{}", p))
}

let mut config = cmake::Config::new(source);
config
Expand All @@ -41,23 +34,17 @@ pub fn build() {
.define("JPEGXL_ENABLE_OPENEXR", "OFF");

let mut prefix = config.build();
println!("cargo:rustc-link-lib=static=jxl");
println!("cargo:rustc-link-lib=static=jxl_threads");

println!("cargo:rustc-link-lib=static=hwy");
prefix.push("lib");
println!("cargo:rustc-link-search=native={}", prefix.display());
prefix.pop();

prefix.push("build");
prefix.push("third_party");
println!("cargo:rustc-link-search=native={}", prefix.display());
println!("cargo:rustc-link-lib=static=jxl");
println!("cargo:rustc-link-lib=static=jxl_cms");
println!("cargo:rustc-link-lib=static=jxl_threads");

println!("cargo:rustc-link-lib=static=brotlicommon-static");
println!("cargo:rustc-link-lib=static=brotlidec-static");
println!("cargo:rustc-link-lib=static=brotlienc-static");
prefix.push("brotli");
println!("cargo:rustc-link-search=native={}", prefix.display());
println!("cargo:rustc-link-lib=static=hwy");
println!("cargo:rustc-link-lib=static=brotlicommon");
println!("cargo:rustc-link-lib=static=brotlidec");
println!("cargo:rustc-link-lib=static=brotlienc");

#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
println!("cargo:rustc-link-lib=c++");
Expand Down
6 changes: 3 additions & 3 deletions jpegxl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ links = "jxl"
name = "jpegxl-sys"
readme = "README.md"
repository = "https://github.com/inflation/jpegxl-rs"
version = "0.8.2+libjxl-0.8.2"
version = "0.9.0+libjxl-0.9.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -21,10 +21,10 @@ module_name_repetitions = "allow"
features = ["docs"]

[build-dependencies]
pkg-config = "0.3.27"
pkg-config = "0.3.28"

[build-dependencies.jpegxl-src]
version = "0.8.2"
version = "0.9.0"
path = "../jpegxl-src"
optional = true

Expand Down
76 changes: 0 additions & 76 deletions jpegxl-sys/src/butteraugli.rs

This file was deleted.

Loading

0 comments on commit f4498b1

Please sign in to comment.