-
Notifications
You must be signed in to change notification settings - Fork 377
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
Require nasm for AV1 decoding, unless on arm64 macOS #7742
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
79361a2
Require `nasm` for AV1 decoding, unless on arm64 macOS
emilk fd68c06
Remove deprecated TODO
emilk 6c5f81a
Move `re_video::Time` to own file
emilk 6b8b8e8
Print out which video features is enabled when running `rerun --version`
emilk b309d1b
Make sure our pre-built binaries has the `nasm` feature-flag enabled
emilk 748a26b
cargo build via pixi
emilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,27 @@ | ||
//! Video decoding library. | ||
|
||
mod time; | ||
|
||
pub mod decode; | ||
pub mod demux; | ||
|
||
pub use decode::{Chunk, Frame, PixelFormat}; | ||
pub use demux::{Config, Sample, VideoData, VideoLoadError}; | ||
pub use re_mp4::{TrackId, TrackKind}; | ||
|
||
/// A value in time units. | ||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct Time(i64); | ||
|
||
impl Time { | ||
pub const ZERO: Self = Self(0); | ||
pub const MAX: Self = Self(i64::MAX); | ||
|
||
/// Create a new value in _time units_. | ||
/// | ||
/// ⚠️ Don't use this for regular timestamps in seconds/milliseconds/etc., | ||
/// use the proper constructors for those instead! | ||
/// This only exists for cases where you already have a value expressed in time units, | ||
/// such as those received from the `WebCodecs` APIs. | ||
#[inline] | ||
pub fn new(v: i64) -> Self { | ||
Self(v) | ||
} | ||
|
||
#[inline] | ||
pub fn from_secs(v: f64, timescale: Timescale) -> Self { | ||
Self((v * timescale.0 as f64).round() as i64) | ||
} | ||
|
||
#[inline] | ||
pub fn from_millis(v: f64, timescale: Timescale) -> Self { | ||
Self::from_secs(v / 1e3, timescale) | ||
} | ||
|
||
#[inline] | ||
pub fn from_micros(v: f64, timescale: Timescale) -> Self { | ||
Self::from_secs(v / 1e6, timescale) | ||
} | ||
|
||
#[inline] | ||
pub fn from_nanos(v: i64, timescale: Timescale) -> Self { | ||
Self::from_secs(v as f64 / 1e9, timescale) | ||
} | ||
|
||
/// Convert to a duration | ||
#[inline] | ||
pub fn duration(self, timescale: Timescale) -> std::time::Duration { | ||
std::time::Duration::from_nanos(self.into_nanos(timescale) as _) | ||
} | ||
|
||
#[inline] | ||
pub fn into_secs(self, timescale: Timescale) -> f64 { | ||
self.0 as f64 / timescale.0 as f64 | ||
} | ||
pub use self::{ | ||
decode::{Chunk, Frame, PixelFormat}, | ||
demux::{Config, Sample, VideoData, VideoLoadError}, | ||
time::{Time, Timescale}, | ||
}; | ||
|
||
#[inline] | ||
pub fn into_millis(self, timescale: Timescale) -> f64 { | ||
self.into_secs(timescale) * 1e3 | ||
/// Which features was this crate compiled with? | ||
pub fn features() -> Vec<&'static str> { | ||
// TODO(emilk): is there a helper crate for this? | ||
let mut features = vec![]; | ||
if cfg!(feature = "av1") { | ||
features.push("av1"); | ||
} | ||
|
||
#[inline] | ||
pub fn into_micros(self, timescale: Timescale) -> f64 { | ||
self.into_secs(timescale) * 1e6 | ||
} | ||
|
||
#[inline] | ||
pub fn into_nanos(self, timescale: Timescale) -> i64 { | ||
(self.into_secs(timescale) * 1e9).round() as i64 | ||
} | ||
} | ||
|
||
impl std::ops::Add for Time { | ||
type Output = Self; | ||
|
||
#[inline] | ||
fn add(self, rhs: Self) -> Self::Output { | ||
Self(self.0.saturating_add(rhs.0)) | ||
} | ||
} | ||
|
||
impl std::ops::Sub for Time { | ||
type Output = Self; | ||
|
||
#[inline] | ||
fn sub(self, rhs: Self) -> Self::Output { | ||
Self(self.0.saturating_sub(rhs.0)) | ||
} | ||
} | ||
|
||
/// The number of time units per second. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct Timescale(u64); | ||
|
||
impl Timescale { | ||
pub(crate) fn new(v: u64) -> Self { | ||
Self(v) | ||
if cfg!(feature = "nasm") { | ||
features.push("nasm"); | ||
} | ||
features | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/// The number of time units per second. | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct Timescale(u64); | ||
|
||
impl Timescale { | ||
pub(crate) fn new(v: u64) -> Self { | ||
Self(v) | ||
} | ||
} | ||
|
||
/// A value in time units. | ||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
pub struct Time(pub i64); | ||
|
||
impl Time { | ||
pub const ZERO: Self = Self(0); | ||
pub const MAX: Self = Self(i64::MAX); | ||
|
||
/// Create a new value in _time units_. | ||
/// | ||
/// ⚠️ Don't use this for regular timestamps in seconds/milliseconds/etc., | ||
/// use the proper constructors for those instead! | ||
/// This only exists for cases where you already have a value expressed in time units, | ||
/// such as those received from the `WebCodecs` APIs. | ||
#[inline] | ||
pub fn new(v: i64) -> Self { | ||
Self(v) | ||
} | ||
|
||
#[inline] | ||
pub fn from_secs(v: f64, timescale: Timescale) -> Self { | ||
Self((v * timescale.0 as f64).round() as i64) | ||
} | ||
|
||
#[inline] | ||
pub fn from_millis(v: f64, timescale: Timescale) -> Self { | ||
Self::from_secs(v / 1e3, timescale) | ||
} | ||
|
||
#[inline] | ||
pub fn from_micros(v: f64, timescale: Timescale) -> Self { | ||
Self::from_secs(v / 1e6, timescale) | ||
} | ||
|
||
#[inline] | ||
pub fn from_nanos(v: i64, timescale: Timescale) -> Self { | ||
Self::from_secs(v as f64 / 1e9, timescale) | ||
} | ||
|
||
/// Convert to a duration | ||
#[inline] | ||
pub fn duration(self, timescale: Timescale) -> std::time::Duration { | ||
std::time::Duration::from_nanos(self.into_nanos(timescale) as _) | ||
} | ||
|
||
#[inline] | ||
pub fn into_secs(self, timescale: Timescale) -> f64 { | ||
self.0 as f64 / timescale.0 as f64 | ||
} | ||
|
||
#[inline] | ||
pub fn into_millis(self, timescale: Timescale) -> f64 { | ||
self.into_secs(timescale) * 1e3 | ||
} | ||
|
||
#[inline] | ||
pub fn into_micros(self, timescale: Timescale) -> f64 { | ||
self.into_secs(timescale) * 1e6 | ||
} | ||
|
||
#[inline] | ||
pub fn into_nanos(self, timescale: Timescale) -> i64 { | ||
(self.into_secs(timescale) * 1e9).round() as i64 | ||
} | ||
} | ||
|
||
impl std::ops::Add for Time { | ||
type Output = Self; | ||
|
||
#[inline] | ||
fn add(self, rhs: Self) -> Self::Output { | ||
Self(self.0.saturating_add(rhs.0)) | ||
} | ||
} | ||
|
||
impl std::ops::Sub for Time { | ||
type Output = Self; | ||
|
||
#[inline] | ||
fn sub(self, rhs: Self) -> Self::Output { | ||
Self(self.0.saturating_sub(rhs.0)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to do something smarter in a follow-up PR