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

Always-on AV1 in --release; opt-in to nasm-optimizations #7661

Merged
merged 5 commits into from
Oct 9, 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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6234,6 +6234,7 @@ dependencies = [
"re_smart_channel",
"re_tracing",
"re_types",
"re_video",
"re_viewer",
"re_web_viewer_server",
"re_ws_comms",
Expand Down
9 changes: 6 additions & 3 deletions crates/store/re_video/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions crates/store/re_video/src/decode/av1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ impl SyncDav1dDecoder {
pub fn new() -> Result<Self> {
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();

Expand Down
10 changes: 6 additions & 4 deletions crates/top/rerun-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
14 changes: 10 additions & 4 deletions crates/top/rerun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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"]
6 changes: 1 addition & 5 deletions crates/viewer/re_renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions crates/viewer/re_renderer/src/video/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,24 @@ 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(),
});
}

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()))?;

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);
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions crates/viewer/re_renderer/src/video/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 0 additions & 4 deletions crates/viewer/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down
6 changes: 5 additions & 1 deletion rerun_py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ default = ["extension-module"]

## The features we turn on when building the `rerun-sdk` PyPi package
## for <https://pypi.org/project/rerun-sdk/>.
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
Expand All @@ -28,6 +28,10 @@ pypi = ["extension-module", "web_viewer"]
## * <https://pyo3.rs/main/building-and-distribution#building-python-extension-modules>
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,
Expand Down
Loading