Skip to content

Commit

Permalink
Disable re_rav1d on Linux arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Oct 16, 2024
1 parent c114e4b commit 85f8270
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5937,6 +5937,7 @@ dependencies = [
name = "re_video"
version = "0.19.0-alpha.10"
dependencies = [
"cfg_aliases 0.2.1",
"crossbeam",
"econtext",
"indicatif",
Expand Down
11 changes: 9 additions & 2 deletions crates/store/re_video/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ parking_lot.workspace = true
re_mp4.workspace = true
thiserror.workspace = true

# Native dependencies:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# We enable re_rav1d on native, UNLESS we're on Linux Arm64
# See https://github.com/rerun-io/rerun/issues/7755
[target.'cfg(all(not(target_arch = "wasm32"), not(all(target_os = "linux", target_arch = "arm64"))))'.dependencies]


# If this package fails to build, install `nasm` locally, or build through `pixi`.
# NOTE: we use `dav1d` as an alias for our own re_rav1d crate
Expand All @@ -62,5 +64,10 @@ dav1d = { workspace = true, optional = true, default-features = false, features
indicatif.workspace = true


# For build.rs:
[build-dependencies]
cfg_aliases.workspace = true


[[example]]
name = "frames"
12 changes: 12 additions & 0 deletions crates/store/re_video/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main() {
// uncomment these when we update to Rust 1.80: https://blog.rust-lang.org/2024/05/06/check-cfg.html
// println!("cargo::rustc-check-cfg=cfg(native)");
// println!("cargo::rustc-check-cfg=cfg(linux_arm64)");
// println!("cargo::rustc-check-cfg=cfg(with_dav1d)");

cfg_aliases::cfg_aliases! {
native: { not(target_arch = "wasm32") },
linux_arm64: { all(target_os = "linux", target_arch = "arm64") },
with_dav1d: { all(native, not(linux_arm64)) }, // https://github.com/rerun-io/rerun/issues/7755
}
}
25 changes: 18 additions & 7 deletions crates/store/re_video/src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
//! supporting HDR content at which point more properties will be important!
//!
#[cfg(feature = "av1")]
#[cfg(with_dav1d)]
#[cfg(not(target_arch = "wasm32"))]
pub mod av1;

Expand All @@ -96,15 +96,19 @@ pub enum Error {
#[error("Unsupported codec: {0}")]
UnsupportedCodec(String),

#[cfg(feature = "av1")]
#[cfg(with_dav1d)]
#[cfg(not(target_arch = "wasm32"))]
#[error("dav1d: {0}")]
Dav1d(#[from] dav1d::Error),

#[cfg(feature = "av1")]
#[cfg(with_dav1d)]
#[cfg(not(target_arch = "wasm32"))]
#[error("To enabled native AV1 decoding, compile Rerun with the `nasm` feature enabled.")]
Dav1dWithoutNasm,

#[error("Rerun does not yet support native AV1 decoding on Linux ARM64. See https://github.com/rerun-io/rerun/issues/7755")]
#[cfg(linux_arm64)]
NoDav1dOnLinuxArm64,
}

pub type Result<T = (), E = Error> = std::result::Result<T, E>;
Expand All @@ -127,18 +131,25 @@ pub fn new_decoder(
debug_name: String,
video: &crate::VideoData,
) -> Result<Box<dyn SyncDecoder + Send + 'static>> {
#![allow(unused_variables)] // With some feature flags
#![allow(unused_variables, clippy::needless_return)] // With some feature flags

re_log::trace!(
"Looking for decoder for {}",
video.human_readable_codec_string()
);

match &video.config.stsd.contents {
#[cfg(feature = "av1")]
re_mp4::StsdBoxContent::Av01(_av01_box) => {
re_log::trace!("Decoding AV1…");
Ok(Box::new(av1::SyncDav1dDecoder::new(debug_name)?))
#[cfg(linux_arm64)]
{
return Err(Error::NoDav1dOnLinuxArm64);
}

#[cfg(with_dav1d)]
{
re_log::trace!("Decoding AV1…");
return Ok(Box::new(av1::SyncDav1dDecoder::new(debug_name)?));
}
}

_ => Err(Error::UnsupportedCodec(video.human_readable_codec_string())),
Expand Down

0 comments on commit 85f8270

Please sign in to comment.