mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 07:44:40 +00:00
* image-codecs: decode AVIF pixels with craft-video's pure-Rust AV1 decoder New optional `avif-decode` feature (native targets) reads still AVIF files: the HEIF/ISOBMFF item graph, grids, clap/irot/imir, alpha auxiliary images (including premultiplied), 8/10/12-bit 4:0:0, 4:2:0, 4:2:2 and 4:4:4, nclx/ICC colour, Exif and XMP, and PQ/HLG to linear F32 through cicp::linearize as the HEIF path does. The container walk follows LightCraft #3017 by @emmertex. Every size is checked against the caller's Limits before the AV1 decoder runs, the decoder's memory budget is capped by max_alloc, and the decode is wrapped in catch_unwind so a decoder panic becomes an error. Fixtures are tiny ffmpeg/libaom files; the 4:2:0 planes match libdav1d bit for bit. Adds a decode_avif fuzz target. Part of storytold/craft-libs#778. * image-codecs, video: address review on the AVIF decoder - clap: width and height are unsigned fractions, the offsets have signed numerators, so 0x80000000/0x40000000 is a width of 2, not -2. - An item with clap, irot or imir more than once (repeated ipma records) is refused before any canvas work, instead of rotating 261120 times. - Matrix coefficients 10 (BT.2020 constant luminance) is refused rather than converted with the non-constant-luminance equations. - An alpha plane whose own transforms differ from the colour's is refused rather than composed in the wrong place; none, or the colour's, still decode. - craft-video: Decoder::set_shown_budget lowers the per-chunk byte cap on shown pictures (never above 1 GiB), and the AVIF decoder sets it to max_alloc, so a payload of many shown pictures is refused before they are built.
59 lines
2.4 KiB
TOML
59 lines
2.4 KiB
TOML
[package]
|
|
name = "craft-image-codecs"
|
|
description = "Bounded, depth- and metadata-preserving codecs for flat raster image formats"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
rust-version.workspace = true
|
|
repository.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[features]
|
|
corpus = []
|
|
default = []
|
|
avif = ["image/avif", "dep:ravif", "dep:rav1e", "dep:avif-serialize"]
|
|
heif = ["dep:craft-heif"]
|
|
# AVIF decode: craft-video's clean-room pure-Rust AV1 decoder. Native targets only (on wasm32 a
|
|
# decoder panic aborts instead of becoming an error), so wasm32 builds leave AVIF unreadable.
|
|
avif-decode = ["dep:craft-video", "craft-video/av1-decode"]
|
|
|
|
[dependencies]
|
|
crc32fast = "1.5"
|
|
thiserror = { workspace = true }
|
|
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tiff", "gif", "bmp", "tga", "ico", "qoi", "hdr"] }
|
|
png = "0.18"
|
|
tiff = { version = "0.11", default-features = false, features = ["deflate", "fax", "jpeg", "lzw"] }
|
|
exr = { version = "1.73", default-features = false }
|
|
half = "2"
|
|
serde_json = { workspace = true }
|
|
flate2 = { version = "1.1.10", default-features = false, features = ["zlib-rs", "runtime_detection"] }
|
|
image-webp = "0.2"
|
|
zune-jpeg = "0.5"
|
|
zune-core = "0.5"
|
|
jpeg-encoder = "0.6"
|
|
craft-jpeg = { workspace = true }
|
|
craft-metadata = { workspace = true }
|
|
zune-jpegxl = { version = "=0.5.2", default-features = false, features = ["std"] }
|
|
craft-heif = { workspace = true, optional = true }
|
|
ravif = { version = "0.13", default-features = false, optional = true }
|
|
rav1e = { version = "0.8", default-features = false, optional = true }
|
|
avif-serialize = { version = "0.8", optional = true }
|
|
hayro-jpeg2000 = { version = "=0.3.5", default-features = false, features = ["std", "simd"] }
|
|
|
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
|
rayon = { workspace = true }
|
|
craft-video = { workspace = true, optional = true }
|
|
exr = { version = "1.73", default-features = false, features = ["rayon"] }
|
|
|
|
[dev-dependencies]
|
|
proptest = { workspace = true }
|
|
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tiff"] }
|
|
sha2 = { version = "0.10", default-features = false, features = ["std"] }
|
|
craft-media-testkit = { workspace = true }
|
|
|
|
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
|
craft-video = { workspace = true, features = ["av1-decode"] }
|
|
jxl-oxide = { version = "=0.12.6", default-features = false, features = ["rayon"] }
|