diff --git a/Cargo.lock b/Cargo.lock index 17d91117815a..6aff8cbde065 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6234,6 +6234,7 @@ dependencies = [ "re_smart_channel", "re_tracing", "re_types", + "re_video", "re_viewer", "re_web_viewer_server", "re_ws_comms", diff --git a/crates/store/re_video/Cargo.toml b/crates/store/re_video/Cargo.toml index 43af5bb9c48f..2dcad53f341a 100644 --- a/crates/store/re_video/Cargo.toml +++ b/crates/store/re_video/Cargo.toml @@ -24,12 +24,15 @@ no-default-features = true features = ["all"] [features] -default = [] +default = ["av1"] -## Opt-in to native AV1 decoding. -## You need to install [nasm](https://nasm.us/) to compile with this feature. +## Native AV1 decoding. av1 = ["dep:dav1d"] +## Enable faster native video decoding with assembly. +## You need to install [nasm](https://nasm.us/) to compile with this feature. +nasm = ["dav1d?/default"] # The default feature set of dav1d has asm enabled + [dependencies] re_log.workspace = true re_tracing.workspace = true diff --git a/crates/store/re_video/src/decode/av1.rs b/crates/store/re_video/src/decode/av1.rs index 320d523535ea..d4e69276a96e 100644 --- a/crates/store/re_video/src/decode/av1.rs +++ b/crates/store/re_video/src/decode/av1.rs @@ -16,6 +16,14 @@ impl SyncDav1dDecoder { pub fn new() -> Result { re_tracing::profile_function!(); + if !cfg!(feature = "nasm") { + re_log::warn_once!( + "NOTE: native AV1 video decoder is running extra slowly. \ + Speed it up by compiling Rerun with the `nasm` feature enabled. \ + You'll need to also install nasm: https://nasm.us/" + ); + } + // See https://videolan.videolan.me/dav1d/structDav1dSettings.html for settings docs let mut settings = dav1d::Settings::new(); diff --git a/crates/top/rerun-cli/Cargo.toml b/crates/top/rerun-cli/Cargo.toml index aac1e268b54c..405e07cb176d 100644 --- a/crates/top/rerun-cli/Cargo.toml +++ b/crates/top/rerun-cli/Cargo.toml @@ -20,6 +20,8 @@ repository.workspace = true rust-version.workspace = true version.workspace = true +default-run = "rerun" # If someone types `cargo run` in this workspace, this is what we staert + [lints] workspace = true @@ -39,14 +41,14 @@ doc = false # so wer have all the bells and wistles here default = ["native_viewer", "web_viewer"] +## Enable faster native video decoding with assembly. +## You need to install [nasm](https://nasm.us/) to compile with this feature. +nasm = ["rerun/nasm"] + ## Support spawning a native viewer. ## This adds a lot of extra dependencies, so only enable this feature if you need it! native_viewer = ["rerun/native_viewer"] -## Support for native AV1 video decoding. -## You need to install [nasm](https://nasm.us/) to compile with this feature. -video_av1 = ["rerun/video_av1"] - ## Support serving a web viewer over HTTP. ## ## Enabling this inflates the binary size quite a bit, since it embeds the viewer wasm. diff --git a/crates/top/rerun/Cargo.toml b/crates/top/rerun/Cargo.toml index af546f31a6c8..4a3c6adf6dd5 100644 --- a/crates/top/rerun/Cargo.toml +++ b/crates/top/rerun/Cargo.toml @@ -71,6 +71,10 @@ ecolor = ["re_types?/ecolor"] ## Integration with the [`log`](https://crates.io/crates/log/) crate. log = ["dep:env_logger", "dep:log"] +## Enable faster native video decoding with assembly. +## You need to install [nasm](https://nasm.us/) to compile with this feature. +nasm = ["re_video/nasm"] + ## Support spawning a native viewer. ## This adds a lot of extra dependencies, so only enable this feature if you need it! native_viewer = ["dep:re_viewer"] @@ -94,10 +98,6 @@ server = ["re_sdk_comms?/server"] ## Embed the Rerun SDK & built-in types and re-export all of their public symbols. sdk = ["dep:re_sdk", "dep:re_types"] -## Support for native AV1 video decoding. -## You need to install [nasm](https://nasm.us/) to compile with this feature. -video_av1 = ["re_viewer?/video_av1"] - ## Support serving a web viewer over HTTP. ## ## Enabling this inflates the binary size quite a bit, since it embeds the viewer wasm. @@ -117,10 +117,12 @@ re_entity_db.workspace = true re_error.workspace = true re_format.workspace = true re_log_types.workspace = true +re_video.workspace = true re_log.workspace = true re_memory.workspace = true re_smart_channel.workspace = true re_tracing.workspace = true + anyhow.workspace = true document-features.workspace = true itertools.workspace = true @@ -155,3 +157,7 @@ unindent = { workspace = true, optional = true } [build-dependencies] re_build_tools.workspace = true + +[package.metadata.cargo-machete] +# We only depend on re_video so we can enable extra features for it +ignored = ["re_video"] diff --git a/crates/viewer/re_renderer/Cargo.toml b/crates/viewer/re_renderer/Cargo.toml index fcff282a15b9..690e7e3eb35a 100644 --- a/crates/viewer/re_renderer/Cargo.toml +++ b/crates/viewer/re_renderer/Cargo.toml @@ -35,10 +35,6 @@ default = ["import-obj", "import-gltf", "import-stl"] ## Support for Arrow datatypes for end-to-end zero-copy. arrow = ["dep:arrow2"] -## Support for native AV1 video decoding. -## You need to install [nasm](https://nasm.us/) to compile with this feature. -video_av1 = ["re_video/av1"] - ## Support importing .obj files import-obj = ["dep:tobj"] @@ -56,7 +52,7 @@ re_error.workspace = true re_log.workspace = true re_math.workspace = true re_tracing.workspace = true -re_video.workspace = true +re_video = { workspace = true, default-features = true } ahash.workspace = true anyhow.workspace = true diff --git a/crates/viewer/re_renderer/src/video/decoder/mod.rs b/crates/viewer/re_renderer/src/video/decoder/mod.rs index 6f19ff5c40f8..97ecd40dfcbd 100644 --- a/crates/viewer/re_renderer/src/video/decoder/mod.rs +++ b/crates/viewer/re_renderer/src/video/decoder/mod.rs @@ -127,7 +127,9 @@ impl VideoDecoder { if #[cfg(target_arch = "wasm32")] { let decoder = web::WebVideoDecoder::new(data.clone(), hw_acceleration)?; return Ok(Self::from_chunk_decoder(render_ctx, data, decoder)); - } else if #[cfg(feature = "video_av1")] { + } else { + // Native AV1 video decoding: + if !data.config.is_av1() { return Err(DecodingError::UnsupportedCodec { codec: data.human_readable_codec_string(), @@ -135,7 +137,7 @@ impl VideoDecoder { } if cfg!(debug_assertions) { - return Err(DecodingError::NoNativeDebug); // because debug builds of rav1d are so slow + return Err(DecodingError::NoNativeDebug); // because debug builds of rav1d are EXTREMELY slow } else { let av1_decoder = re_video::decode::av1::SyncDav1dDecoder::new() .map_err(|err| DecodingError::StartDecoder(err.to_string()))?; @@ -143,8 +145,6 @@ impl VideoDecoder { let decoder = native_decoder::NativeDecoder::new(debug_name, Box::new(av1_decoder))?; return Ok(Self::from_chunk_decoder(render_ctx, data, decoder)); }; - } else { - return Err(DecodingError::NoNativeSupport); } } } diff --git a/crates/viewer/re_renderer/src/video/mod.rs b/crates/viewer/re_renderer/src/video/mod.rs index 5cc072758ce2..517c6ecc08c2 100644 --- a/crates/viewer/re_renderer/src/video/mod.rs +++ b/crates/viewer/re_renderer/src/video/mod.rs @@ -54,17 +54,11 @@ pub enum DecodingError { BadData, #[cfg(not(target_arch = "wasm32"))] - #[error("No native video support. Try compiling rerun with the `video_av1` feature flag")] - NoNativeSupport, - - #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "video_av1")] #[error("Unsupported codec: {codec:?}. Only AV1 is currently supported on native.")] UnsupportedCodec { codec: String }, #[cfg(not(target_arch = "wasm32"))] - #[cfg(feature = "video_av1")] - #[error("Video decoding not supported in native debug builds.")] + #[error("Native video decoding not supported in native debug builds.")] NoNativeDebug, } diff --git a/crates/viewer/re_viewer/Cargo.toml b/crates/viewer/re_viewer/Cargo.toml index 6216ddee5851..7cf74b51cdd5 100644 --- a/crates/viewer/re_viewer/Cargo.toml +++ b/crates/viewer/re_viewer/Cargo.toml @@ -36,10 +36,6 @@ default = ["analytics"] ## Enable telemetry using our analytics SDK. analytics = ["dep:re_analytics"] -## Support for native AV1 video decoding. -## You need to install [nasm](https://nasm.us/) to compile with this feature. -video_av1 = ["re_renderer/video_av1"] - [dependencies] # Internal: diff --git a/pixi.toml b/pixi.toml index 1bf01bdd8239..56ab2208126c 100644 --- a/pixi.toml +++ b/pixi.toml @@ -122,18 +122,18 @@ man = "cargo --quiet run --package rerun-cli --all-features -- man > docs/conten # Compile and run the rerun viewer. # # You can also give an argument for what to view (e.g. an .rrd file). -rerun = "cargo run --package rerun-cli --no-default-features --features native_viewer,video_av1 --" +rerun = "cargo run --package rerun-cli --no-default-features --features native_viewer,nasm --" # Compile `rerun-cli` without the web-viewer. -rerun-build = "cargo build --package rerun-cli --no-default-features --features native_viewer,video_av1" +rerun-build = "cargo build --package rerun-cli --no-default-features --features native_viewer,nasm" # Compile `rerun-cli` without the web-viewer. -rerun-build-release = "cargo build --package rerun-cli --release --no-default-features --features native_viewer,video_av1" +rerun-build-release = "cargo build --package rerun-cli --release --no-default-features --features native_viewer,nasm" # Compile and run the rerun viewer with --release. # # You can also give an argument for what to view (e.g. an .rrd file). -rerun-release = "cargo run --package rerun-cli --no-default-features --features native_viewer,video_av1 --release --" +rerun-release = "cargo run --package rerun-cli --no-default-features --features native_viewer,nasm --release --" # Compile and run the web-viewer via rerun-cli. # diff --git a/rerun_py/Cargo.toml b/rerun_py/Cargo.toml index 9695a6bf9764..2b5994ab5de9 100644 --- a/rerun_py/Cargo.toml +++ b/rerun_py/Cargo.toml @@ -19,7 +19,7 @@ default = ["extension-module"] ## The features we turn on when building the `rerun-sdk` PyPi package ## for . -pypi = ["extension-module", "web_viewer"] +pypi = ["extension-module", "nasm", "web_viewer"] ## We need to enable the `pyo3/extension-module` when building the SDK, ## but we cannot enable it when building tests and benchmarks, so we @@ -28,6 +28,10 @@ pypi = ["extension-module", "web_viewer"] ## * extension-module = ["pyo3/extension-module"] +## Enable faster native video decoding with assembly. +## You need to install [nasm](https://nasm.us/) to compile with this feature. +nasm = ["re_video/nasm"] + ## Support serving a web viewer over HTTP with `serve()`. ## ## Enabling this adds quite a bit to the binary size,