From e0440f994296fe964b674e119de714af76ebddda Mon Sep 17 00:00:00 2001 From: alehel Date: Tue, 17 Nov 2026 09:39:25 +0100 Subject: [PATCH] video: the VMD decoder is behind vmd-decode, with vmd turning it on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit craft-audio names its VMD decoder feature `vmd-decode`, and craft-video names a codec's decoder `-decode` wherever the codec may also have an encoder (mpeg2, mpeg4, vp8…). The video decoder now follows that: `vmd-decode` gates the module and its VideoFrame conversion, and `vmd` turns it on, so `vmd` keeps working and an encoder can be added later without renaming. Co-Authored-By: Claude Opus 5.5 --- crates/video/Cargo.toml | 7 ++++--- crates/video/README.md | 2 +- crates/video/src/frame/convert.rs | 4 ++-- crates/video/src/lib.rs | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/video/Cargo.toml b/crates/video/Cargo.toml index a57cc4acd..6a8cb336a 100644 --- a/crates/video/Cargo.toml +++ b/crates/video/Cargo.toml @@ -62,8 +62,9 @@ av1-decode = [] av1-encode = ["craft-media/isobmff"] # Tiled AV1 fallback for frames that exceed the clean-room encoder's single-tile limits. av1-large-encode = ["av1-encode", "dep:rav1e"] -# Sierra VMD video (8-bit paletted): decoder. -vmd = [] +# Sierra VMD video (8-bit paletted): decoder; `vmd` turns it on too. +vmd = ["vmd-decode"] +vmd-decode = [] # Decode and encode across worker threads (rayon) in the codecs that support it. threads = ["dep:rayon", "rav1e?/threading"] @@ -84,7 +85,7 @@ craft-media = { workspace = true, features = ["avi", "vmd"] } [[test]] name = "vmd" -required-features = ["vmd"] +required-features = ["vmd-decode"] [[test]] name = "hap" diff --git a/crates/video/README.md b/crates/video/README.md index 2c1ca31c6..197d94672 100644 --- a/crates/video/README.md +++ b/crates/video/README.md @@ -30,7 +30,7 @@ No codec feature is on by default. | `hevc` | [`hevc`](src/hevc/decode/README.md) | ITU-T H.265 / HEVC: decoder (`hevc-decode` alone) and encoder (`hevc-encode` alone) | | `vp9` | [`vp9`](src/vp9/decode/README.md) | VP9: decoder (`vp9-decode` alone) and encoder (`vp9-encode` alone) | | `av1` | [`av1`](src/av1/decode/README.md) | AV1 (AOMedia Video 1): decoder (`av1-decode` alone) and clean-room encoder (`av1-encode`); tiled rav1e fallback for large frames (`av1-large-encode`) | -| `vmd` | `vmd` | Sierra VMD video (the 8-bit paletted pictures of Sierra and Coktel Vision game videos): decoder | +| `vmd` | `vmd` | Sierra VMD video (the 8-bit paletted pictures of Sierra and Coktel Vision game videos): decoder (`vmd-decode`) | | `threads` | — | Multi-threaded slice/row parallelism via `rayon` | ## Decoded frames diff --git a/crates/video/src/frame/convert.rs b/crates/video/src/frame/convert.rs index 314d07fea..f90de281c 100644 --- a/crates/video/src/frame/convert.rs +++ b/crates/video/src/frame/convert.rs @@ -370,7 +370,7 @@ impl TryFrom for VideoFrame { } } -#[cfg(feature = "vmd")] +#[cfg(feature = "vmd-decode")] impl TryFrom<&crate::vmd::Decoder> for VideoFrame { type Error = FrameError; @@ -384,7 +384,7 @@ impl TryFrom<&crate::vmd::Decoder> for VideoFrame { /// A picture of palette indices, `width` a row, as 8-bit R, G, B planes. Matrix 0 (identity), the /// other colour tags unspecified. -#[cfg(feature = "vmd")] +#[cfg(feature = "vmd-decode")] fn paletted(width: usize, height: usize, indices: &[u8], palette: &[[u8; 3]; 256]) -> Result { let too_large = FrameError::Shape("picture size does not fit in u32"); let (w, h) = (u32::try_from(width).map_err(|_| too_large.clone())?, u32::try_from(height).map_err(|_| too_large)?); diff --git a/crates/video/src/lib.rs b/crates/video/src/lib.rs index 65b126066..249f1a1b4 100644 --- a/crates/video/src/lib.rs +++ b/crates/video/src/lib.rs @@ -18,7 +18,7 @@ //! | `hevc` | [`hevc`] | ITU-T H.265 / HEVC: decoder (`hevc-decode`) and encoder (`hevc-encode`) | //! | `vp9` | [`vp9`] | VP9: decoder (`vp9-decode`) and encoder (`vp9-encode`) | //! | `av1` | [`av1`] | AV1 (AOMedia Video 1): decoder (`av1-decode`) and encoder (`av1-encode`) | -//! | `vmd` | [`vmd`] | Sierra VMD video (8-bit paletted): decoder | +//! | `vmd` | [`vmd`] | Sierra VMD video (8-bit paletted): decoder (`vmd-decode`) | //! //! No codec is on by default. Feature `threads` spreads the work of the codecs that support it //! over rayon worker threads. @@ -80,5 +80,5 @@ pub mod raw_video; #[cfg(feature = "screen-video")] pub mod screen_video; -#[cfg(feature = "vmd")] +#[cfg(feature = "vmd-decode")] pub mod vmd;