From a7e641c0626effcf683510e9976acdb153e56efd Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 28 Dec 2023 23:06:53 +0100 Subject: [PATCH] Remove noop_proc_macro dependency --- Cargo.toml | 1 - src/frame.rs | 7 +++++-- src/lib.rs | 16 ---------------- src/pixel.rs | 12 ++++++++---- src/plane.rs | 10 +++++++--- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7266720..96ed058 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,6 @@ tracing = [ [dependencies] num-traits = "0.2" num-derive = "0.4" -noop_proc_macro = "0.3.0" serde = { version = "1.0", features = ["derive"], optional = true } profiling = { version = "1" } tracing = { version = "0.1.40", optional = true } diff --git a/src/frame.rs b/src/frame.rs index f2ca551..4986659 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -10,10 +10,13 @@ use crate::math::*; use crate::pixel::*; use crate::plane::*; -use crate::serialize::{Deserialize, Serialize}; + +#[cfg(feature = "serialize")] +use serde::{Deserialize, Serialize}; /// Represents a raw video frame -#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct Frame { /// Planes constituting the frame. pub planes: [Plane; 3], diff --git a/src/lib.rs b/src/lib.rs index 3963e17..cd9b74b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,22 +83,6 @@ pub mod math; pub mod pixel; pub mod plane; -mod serialize { - #[cfg(feature = "serialize")] - pub use serde::*; - - #[cfg(not(feature = "serialize"))] - pub use noop_proc_macro::{Deserialize, Serialize}; -} - -mod wasm_bindgen { - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] - pub use wasm_bindgen::prelude::*; - - #[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))] - pub use noop_proc_macro::wasm_bindgen; -} - pub mod prelude { pub use crate::math::*; pub use crate::pixel::*; diff --git a/src/pixel.rs b/src/pixel.rs index 8c75b31..6f9558e 100644 --- a/src/pixel.rs +++ b/src/pixel.rs @@ -7,8 +7,11 @@ // Media Patent License 1.0 was not distributed with this source code in the // PATENTS file, you can obtain it at www.aomedia.org/license/patent. -use crate::serialize::{Deserialize, Serialize}; -use crate::wasm_bindgen::*; +#[cfg(feature = "serialize")] +use serde::{Serialize, Deserialize}; + +#[cfg(feature = "wasm")] +use wasm_bindgen::prelude::*; use num_derive::FromPrimitive; use num_traits::{AsPrimitive, PrimInt, Signed}; @@ -146,8 +149,9 @@ impl Coefficient for i32 { } /// Chroma subsampling format -#[wasm_bindgen] -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, FromPrimitive, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, FromPrimitive)] +#[cfg_attr(feature = "wasm", wasm_bindgen)] +#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] #[repr(C)] pub enum ChromaSampling { /// Both vertically and horizontally subsampled. diff --git a/src/plane.rs b/src/plane.rs index fa7b203..69656a0 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -17,10 +17,13 @@ use aligned_vec::{ABox, AVec, ConstAlign}; use crate::math::*; use crate::pixel::*; -use crate::serialize::{Deserialize, Serialize}; + +#[cfg(feature = "serialize")] +use serde::{Deserialize, Serialize}; /// Plane-specific configuration. -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct PlaneConfig { /// Data stride. pub stride: usize, @@ -147,7 +150,8 @@ impl PlaneData { /// One data plane of a frame. /// /// For example, a plane can be a Y luma plane or a U or V chroma plane. -#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))] pub struct Plane { // TODO: it is used by encoder to copy by plane and by tiling, make it // private again once tiling is moved and a copy_plane fn is added.