mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 07:35:02 +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.
craft-video
Clean-room pure-Rust video codecs for the Craft apps, one feature per codec: DNxHD/DNxHR, VP8, ProRes and H.264.
- Input and output are byte slices and planar sample buffers; the crate opens no files itself and performs no filesystem I/O.
- Implemented from published standards and RFCs (SMPTE ST 2019-1, RFC 6386, SMPTE RDD 36 and ITU-T H.264).
- Tested against ffmpeg as an external oracle with roundtrips, hostile fuzzing, and conformance vectors.
No
unsafe, no panics on corrupt streams. Builds forwasm32-unknown-unknown. - Containers (MP4/MOV, Matroska/WebM), bit-level I/O (
craft_media::bitstream) and shared identifiers (CodecId,CodecParams) come fromcraft-media.
Cargo features
No codec feature is on by default.
| Feature | Module | Codec |
|---|---|---|
dnx |
dnx |
Avid DNxHD / DNxHR (SMPTE ST 2019-1 VC-3): decoder and encoder |
apv |
apv |
APV (Advanced Professional Video, RFC 9924): decoder (apv-decode alone) and encoder (apv-encode alone) |
vp8 |
vp8 |
VP8 (RFC 6386): decoder |
mpeg2 |
mpeg2 |
MPEG-2 video (ITU-T H.262) and MPEG-1 video (ISO/IEC 11172-2): decoder (mpeg2-decode alone); MPEG-2 encoder with I, P and B pictures (mpeg2-encode, which also turns on the decoder) |
mpeg4 |
mpeg4 |
MPEG-4 Part 2 video (ISO/IEC 14496-2, the Xvid/DivX format): Simple profile encoder (mpeg4-encode) |
prores |
prores |
Apple ProRes (SMPTE RDD 36): decoder and encoder |
h264 |
h264 |
ITU-T H.264 / AVC: decoder (h264-decode alone) and encoder (h264-encode alone) |
hevc |
hevc |
ITU-T H.265 / HEVC: decoder (hevc-decode alone) and encoder (hevc-encode alone) |
vp9 |
vp9 |
VP9: decoder (vp9-decode alone) and encoder (vp9-encode alone) |
av1 |
av1 |
AV1 (AOMedia Video 1): decoder (av1-decode alone) and clean-room encoder (av1-encode); tiled rav1e fallback for large frames (av1-large-encode) |
threads |
— | Multi-threaded slice/row parallelism via rayon |