Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cfg-if and noop-proc-macro crates #19

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ tracing = [
]

[dependencies]
cfg-if = "1.0"
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 }
Expand Down
7 changes: 5 additions & 2 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Check warning on line 18 in src/frame.rs

View check run for this annotation

Codecov / codecov/patch

src/frame.rs#L18

Added line #L18 was not covered by tests
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Frame<T: Pixel> {
/// Planes constituting the frame.
pub planes: [Plane<T>; 3],
Expand Down
21 changes: 0 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,6 @@ pub mod math;
pub mod pixel;
pub mod plane;

mod serialize {
cfg_if::cfg_if! {
if #[cfg(feature="serialize")] {
pub use serde::*;
} else {
pub use noop_proc_macro::{Deserialize, Serialize};
}
}
}

mod wasm_bindgen {
cfg_if::cfg_if! {
// Only use wasm_bindgen with wasm32-unknown-unknown, not wasm32-wasi
if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] {
pub use wasm_bindgen::prelude::*;
} else {
pub use noop_proc_macro::wasm_bindgen;
}
}
}

pub mod prelude {
pub use crate::math::*;
pub use crate::pixel::*;
Expand Down
8 changes: 4 additions & 4 deletions src/pixel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// 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};

use num_derive::FromPrimitive;
use num_traits::{AsPrimitive, PrimInt, Signed};
Expand Down Expand Up @@ -146,8 +146,8 @@
}

/// Chroma subsampling format
#[wasm_bindgen]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, FromPrimitive, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, FromPrimitive)]

Check warning on line 149 in src/pixel.rs

View check run for this annotation

Codecov / codecov/patch

src/pixel.rs#L149

Added line #L149 was not covered by tests
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[repr(C)]
pub enum ChromaSampling {
/// Both vertically and horizontally subsampled.
Expand Down
24 changes: 12 additions & 12 deletions src/plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@

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)]

Check warning on line 25 in src/plane.rs

View check run for this annotation

Codecov / codecov/patch

src/plane.rs#L25

Added line #L25 was not covered by tests
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct PlaneConfig {
/// Data stride.
pub stride: usize,
Expand Down Expand Up @@ -121,15 +124,11 @@
}

impl<T: Pixel> PlaneData<T> {
// Data alignment in bytes.
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
// FIXME: wasm32 allocator fails for alignment larger than 3
const DATA_ALIGNMENT: usize = 1 << 3;
} else {
const DATA_ALIGNMENT: usize = 1 << 6;
}
}
#[cfg(target_arch = "wasm32")]
// FIXME: wasm32 allocator fails for alignment larger than 3
const DATA_ALIGNMENT: usize = 1 << 3;
#[cfg(not(target_arch = "wasm32"))]
const DATA_ALIGNMENT: usize = 1 << 6;

pub fn new(len: usize) -> Self {
Self {
Expand All @@ -151,7 +150,8 @@
/// 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)]

Check warning on line 153 in src/plane.rs

View check run for this annotation

Codecov / codecov/patch

src/plane.rs#L153

Added line #L153 was not covered by tests
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Plane<T: Pixel> {
// 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.
Expand Down