Skip to content

Commit

Permalink
fix some missing API bits; bump version to 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gerwin3 committed May 14, 2024
1 parent 6b21322 commit dfb8533
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "video-rs"
description = "High-level video toolkit based on ffmpeg."
keywords = ["video", "ffmpeg", "encoding", "decoding", "muxing"]
categories = ["multimedia", "multimedia::video"]
version = "0.8.0"
version = "0.8.1"
authors = ["Oddity.ai Developers <[email protected]>"]
license = "MIT OR Apache-2.0"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Encoder {
/// * `source_timestamp` - Frame timestamp of original source. This is necessary to make sure
/// the output will be timed correctly.
#[cfg(feature = "ndarray")]
pub fn encode(&mut self, frame: &Frame, source_timestamp: &Time) -> Result<()> {
pub fn encode(&mut self, frame: &Frame, source_timestamp: Time) -> Result<()> {
let (height, width, channels) = frame.dim();
if height != self.scaler_height as usize
|| width != self.scaler_width as usize
Expand Down
6 changes: 3 additions & 3 deletions src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ impl Packet {

/// Set packet PTS (presentation timestamp).
#[inline]
pub fn set_pts(&mut self, timestamp: &Time) {
pub fn set_pts(&mut self, timestamp: Time) {
self.inner
.set_pts(timestamp.aligned_with_rational(self.time_base).into_value());
}

/// Set packet DTS (decoder timestamp).
#[inline]
pub fn set_dts(&mut self, timestamp: &Time) {
pub fn set_dts(&mut self, timestamp: Time) {
self.inner
.set_dts(timestamp.aligned_with_rational(self.time_base).into_value());
}

/// Set duration.
#[inline]
pub fn set_duration(&mut self, timestamp: &Time) {
pub fn set_duration(&mut self, timestamp: Time) {
if let Some(duration) = timestamp.aligned_with_rational(self.time_base).into_value() {
self.inner.set_duration(duration);
}
Expand Down
14 changes: 7 additions & 7 deletions src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Time {
/// # Return value
///
/// Two timestamps that are aligned.
pub fn aligned_with(&self, rhs: &Time) -> Aligned {
pub fn aligned_with(&self, rhs: Time) -> Aligned {
Aligned {
lhs: self.time,
rhs: rhs
Expand Down Expand Up @@ -329,7 +329,7 @@ mod tests {
fn test_aligned_with() {
let a = Time::from_units(3, 16);
let b = Time::from_units(1, 8);
let aligned = a.aligned_with(&b);
let aligned = a.aligned_with(b);
assert_eq!(aligned.lhs, Some(3));
assert_eq!(aligned.rhs, Some(2));
}
Expand All @@ -338,7 +338,7 @@ mod tests {
fn test_into_aligned_with() {
let a = Time::from_units(2, 7);
let b = Time::from_units(2, 3);
let aligned = a.aligned_with(&b);
let aligned = a.aligned_with(b);
assert_eq!(aligned.lhs, Some(2));
assert_eq!(aligned.rhs, Some(5));
}
Expand Down Expand Up @@ -379,22 +379,22 @@ mod tests {
fn test_add() {
let a = Time::from_secs(0.2);
let b = Time::from_secs(0.3);
assert_eq!(a.aligned_with(&b).add(), Time::from_secs(0.5));
assert_eq!(a.aligned_with(b).add(), Time::from_secs(0.5));
}

#[test]
fn test_subtract() {
let a = Time::from_secs(0.8);
let b = Time::from_secs(0.4);
assert_eq!(a.aligned_with(&b).subtract(), Time::from_secs(0.4));
assert_eq!(a.aligned_with(b).subtract(), Time::from_secs(0.4));
}

#[test]
fn test_apply() {
let a = Time::from_secs(2.0);
let b = Time::from_secs(0.25);
assert_eq!(
a.aligned_with(&b).apply(|x, y| (2 * x) + (3 * y)),
a.aligned_with(b).apply(|x, y| (2 * x) + (3 * y)),
Time::from_secs(4.75)
);
}
Expand All @@ -404,7 +404,7 @@ mod tests {
let a = Time::new(Some(3), AvRational::new(2, 32));
let b = Time::from_nth_of_a_second(4);
assert!(
(a.aligned_with(&b).apply(|x, y| x + y).as_secs()
(a.aligned_with(b).apply(|x, y| x + y).as_secs()
- Time::from_secs(7.0 / 16.0).as_secs())
.abs()
< 0.001
Expand Down

0 comments on commit dfb8533

Please sign in to comment.