Cargo Features

[dependencies]
zenjpeg = { version = "0.6.1", default-features = false, features = ["std", "decoder", "parallel", "archmage-simd", "trellis", "cms", "ffi-tests", "corpus-tests", "cms-lcms2", "cms-moxcms", "debug-tokens", "profile", "alloc-instrument", "test-utils", "wasm-simd", "sharp-yuv", "mozjpeg-tables", "optimized-tables", "wasm-trace", "yuv", "ultrahdr"] }
default = archmage-simd, std, trellis, yuv

These default features are set whenever zenjpeg is added without default-features = false somewhere in the dependency tree.

std default alloc-instrument? parallel? test-utils? ultrahdr?

Enable std library support (io::Write, std::error::Error impl).
Disable for no_std environments - only requires core + alloc.

decoder ultrahdr?

Enable the decoder API. The decoder is still in prerelease with frequent breaking changes.
When disabled, no decoder types or functions are available in the public API.

Affects ycbcr::rgb_u8_swap_rb_inplace, ycbcr::rgb_u8_to_rgba_u8, ycbcr::rgb_u8_to_bgra_u8, ycbcr::rgb_u8_to_bgrx_u8, entropy::arithmetic, entropy::decoder, zenjpeg::decoder, zenjpeg::lossless, zenjpeg::decode

parallel = std

Enable parallel encoding (multi-threaded DCT/quantization)

Enables rayon

For parallel encoding

Affects config::ComputedConfig.parallel, encoder_types::ParallelEncoding, encode::parallel

archmage-simd default

Token-based safe SIMD using archmage + magetypes (f32x4, i32x4 etc. with capability tokens) Provides ~10-20% speedup on x86_64. Without this, all SIMD uses safe wide crate.

Enables archmage ^0.5.0

Token-based safe SIMD intrinsics

and magetypes ^0.5.0

Token-gated SIMD types (wraps archmage tokens)

and safe_unaligned_simd

Safe unaligned SIMD load/store wrappers (eliminates unsafe for memory ops)

Affects idct_int::idct_int_avx2_raw, upsample::upsample_h2v2_i16_fancy_simd, encode::mage_simd, encode::arm_simd, encode::wasm_simd

trellis default

Rate-distortion trellis quantization (mozjpeg-style). Enables encode::trellis module with TrellisConfig, HybridConfig, and Viterbi-based coefficient optimization.
When disabled, the encoder uses standard zero-bias quantization.

Affects config::ComputedConfig.hybrid_config, config::ComputedConfig.trellis, encoder_types::ExpertConfig, encode::search

cms = cms-lcms2

Default CMS backend

ffi-tests

FFI tests against C++ jpegli for parity verification (local development only)
Requires: git submodule, cmake, C++ toolchain. Not usable from crates.io.
Tests check for this feature with #[cfg(feature = "ffi-tests")]

corpus-tests

Enable corpus comparison tests (requires local codec-corpus directory)

cms-lcms2 cms?

Enables lcms2 and zune-jpeg

zune-jpeg:

For CMS decode helper

Affects icc::apply_icc_transform, icc::apply_icc_transform_f32, icc::decode_jpeg_with_icc

cms-moxcms

Enables moxcms ^0.6 and zune-jpeg

Affects icc::apply_icc_transform, icc::apply_icc_transform_f32, icc::decode_jpeg_with_icc

debug-tokens

Enable debug token serialization for C++ comparison

Affects cluster::ClusterResult.merge_log

profile

Enable internal profiling instrumentation (scope timers)

Affects profile::ProfileStats, profile::ProfileGuard

alloc-instrument = std

Enable Vec allocation instrumentation (logs utilization on drop)
Use for profiling allocation patterns - zero overhead when disabled

Affects instrumented_vec::ProfiledVec, instrumented_vec::set_stats_enabled, instrumented_vec::set_min_waste_report

test-utils = std

Enable test utilities (image generation, quality verification)
Requires std for file path operations

Affects zenjpeg::encode, zenjpeg::color, zenjpeg::entropy, zenjpeg::foundation, zenjpeg::huffman, zenjpeg::quant, zenjpeg::types, zenjpeg::test_utils, zenjpeg::decode

wasm-simd

Enable WASM SIMD128 tests (requires wasm runtime with SIMD support)
Build with: RUSTFLAGS="-C target-feature=+simd128" cargo build --target wasm32-wasip1
Supported runtimes (2025): Wasmtime, Wasmer, Node.js, all major browsers

sharp-yuv

Enable sharp-yuv comparison tests (requires yuv crate, not in default deps)

mozjpeg-tables

Enable mozjpeg-compatible quantization table presets (Robidoux, MSSIM, Klein, etc.)
Provides MozjpegTables::generate() helper for producing tables compatible with mozjpeg

Affects tables::presets

optimized-tables

Enable SA-optimized piecewise quantization tables (+6.5 mean pareto vs jpegli defaults)
Provides OptimizedTables::generate() with 20-anchor interpolated tables

Affects encode::optimized_tables

wasm-trace

Enable WASM console tracing for debugging browser-specific issues

Enables web-sys

WASM console logging for debugging browser-specific issues

yuv default

Fast SIMD RGB→YCbCr conversion using the yuv crate (10-150x faster)
Uses 15-bit fixed-point Professional mode (max error: 0.5 levels, invisible after JPEG quantization)

Enables yuv

Fast SIMD RGB→YCbCr conversion (AVX-512/AVX2/SSE/NEON) - 10-150x faster than f32 math

Affects color::fast_yuv, encode_simd::rgb_to_ycbcr_strided_reuse, encode_simd::bgr_to_ycbcr_strided_reuse

ultrahdr = decoder, std

UltraHDR (HDR gain map) support - requires decoder for gain map reconstruction Provides: tonemap, compute_gainmap, apply_gainmap, XMP metadata, adaptive tonemapper

Enables ultrahdr-core ^0.1.0

UltraHDR (HDR gain map) encoding/decoding support

Affects ultrahdr_reader::UltraHdrReaderConfig.hdr_format, ultrahdr_reader::UltraHdrReader, zenjpeg::ultrahdr