[package]
name = "jpegli-rs"
version = "0.3.0"
edition = "2021"
license = "AGPL-3.0-or-later"
repository = "https://github.com/imazen/jpegli-rs"
documentation = "https://docs.rs/jpegli-rs"
readme = "README.md"
description = "Pure Rust JPEG encoder/decoder - port of Google's jpegli with perceptual optimizations"
keywords = ["jpeg", "image", "encoder", "decoder", "compression"]
categories = ["multimedia::images", "encoding"]
authors = ["Lilith River <lilith@imazen.io>"]
rust-version = "1.70"

[lib]
name = "jpegli"  # Keep import name as `use jpegli` for compatibility

[dependencies]
wide = { workspace = true }
bytemuck = { workspace = true }
arrayref = { workspace = true }
rgb = { workspace = true }
imgref = { workspace = true }
multiversion = { workspace = true }
lcms2 = { workspace = true, optional = true }
moxcms = { workspace = true, optional = true }
jpeg-decoder = { workspace = true, optional = true }
butteraugli = { workspace = true }
# Hybrid trellis quantization from mozjpeg
mozjpeg-rs = { workspace = true, optional = true }
# For FFI comparison testing against C++ jpegli (internal development only)
# This dependency is NOT published to crates.io - it requires building the C++ jpegli
# from source via cmake. Only works in a local checkout with the C++ submodule:
#   git submodule update --init --recursive internal/jpegli-cpp
# jpegli-internals-sys = { path = "../internal/jpegli-internals-sys", features = ["butteraugli"], optional = true }
# For corpus comparison testing
codec-eval = { version = "0.2", optional = true }

[dev-dependencies]
chrono = "0.4"
approx = { workspace = true }
proptest = { workspace = true }
criterion = { workspace = true }
test-case = { workspace = true }
png = { workspace = true }
dssim = { workspace = true }
ssimulacra2 = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
bincode = { workspace = true }
zune-jpeg = { workspace = true }
mozjpeg = { workspace = true }
jpeg-decoder = { workspace = true }

[features]
default = ["simd", "cms"]
simd = []
cms = ["cms-lcms2"]  # Default CMS backend
# FFI tests against C++ jpegli for parity verification (local development only)
# Requires: git submodule, cmake, C++ toolchain. Not usable from crates.io.
# To enable locally, uncomment jpegli-internals-sys above and change to:
#   ffi-tests = ["dep:jpegli-internals-sys"]
ffi-tests = []
# Enable corpus comparison tests (requires codec-eval)
corpus-tests = ["dep:codec-eval"]
cms-lcms2 = ["dep:lcms2", "dep:jpeg-decoder"]
cms-moxcms = ["dep:moxcms", "dep:jpeg-decoder"]
# Enable debug token serialization for C++ comparison
debug-tokens = []
# Enable test utilities (image generation, quality verification)
test-utils = []
# Enable hybrid trellis quantization (combines jpegli AQ + mozjpeg trellis)
experimental-hybrid-trellis = ["dep:mozjpeg-rs"]

[[bench]]
name = "encode"
harness = false

[[bench]]
name = "decode"
harness = false

[lints]
workspace = true

# Examples that require test-utils feature
[[example]]
name = "benchmark_xyb_vs_ycbcr"
required-features = ["test-utils"]

[[example]]
name = "compare_coefficients"
required-features = ["test-utils"]

[[example]]
name = "compare_decoded"
required-features = ["test-utils"]

[[example]]
name = "compare_quality"
required-features = ["test-utils"]

[[example]]
name = "compare_quant_tables"
required-features = ["test-utils"]

[[example]]
name = "compare_to_original"
required-features = ["test-utils"]

[[example]]
name = "compare_xyb_constants"
required-features = ["test-utils", "ffi-tests"]

[[example]]
name = "debug_aq_values"
required-features = ["test-utils"]

[[example]]
name = "debug_quant_field"
required-features = ["test-utils"]

[[example]]
name = "generate_cpp_reference"
required-features = ["test-utils"]

[[example]]
name = "low_q_report"
required-features = ["test-utils"]

[[example]]
name = "quality_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_butteraugli_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_distance_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_same_size_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_ssimulacra2_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_vs_ycbcr_comparison"
required-features = ["test-utils"]

[[example]]
name = "xyb_ycbcr_pareto"
required-features = ["test-utils"]

# This example requires the `image` crate which is not in workspace dependencies
[[example]]
name = "test_multiple_decoders"
required-features = ["test-utils"]

# These examples use APIs that are not fully implemented yet
[[example]]
name = "debug_roundtrip"
required-features = ["test-utils"]

[[example]]
name = "debug_scans_separate"
required-features = ["test-utils"]
