From ed9703b739fb86d4ed20b40d9d9ddda7163a812c Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Thu, 2 Feb 2023 13:25:17 -0500 Subject: [PATCH] Fix an issue where compilation may fail on some non-x64 platforms --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- src/codec/packet/packet.rs | 6 +++--- src/codec/packet/side_data.rs | 2 +- src/codec/subtitle/mod.rs | 4 ++-- src/format/chapter/chapter.rs | 2 +- src/lib.rs | 2 ++ src/util/dictionary/owned.rs | 2 +- src/util/frame/audio.rs | 6 +++--- src/util/frame/mod.rs | 8 ++++---- src/util/frame/side_data.rs | 2 +- src/util/time.rs | 4 ++-- 12 files changed, 25 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d82485e..1f14a75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Version 1.1.1 + +- Fix compilation on some non-x64 platforms + ## Version 1.1.0 - Add `serialize` feature, off by default, which derives `serde::{Serialize, Deserialize}` for as many types as possible diff --git a/Cargo.toml b/Cargo.toml index 6096582..d5e89f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ffmpeg-the-third" -version = "1.1.0+ffmpeg-5.1.2" +version = "1.1.1+ffmpeg-5.1.2" build = "build.rs" authors = ["meh. ", "Zhiming Wang "] diff --git a/src/codec/packet/packet.rs b/src/codec/packet/packet.rs index 72a38ea..0dd27f5 100644 --- a/src/codec/packet/packet.rs +++ b/src/codec/packet/packet.rs @@ -121,7 +121,7 @@ impl Packet { pub fn pts(&self) -> Option { match self.0.pts { AV_NOPTS_VALUE => None, - pts => Some(pts), + pts => Some(pts as i64), } } @@ -134,7 +134,7 @@ impl Packet { pub fn dts(&self) -> Option { match self.0.dts { AV_NOPTS_VALUE => None, - dts => Some(dts), + dts => Some(dts as i64), } } @@ -150,7 +150,7 @@ impl Packet { #[inline] pub fn duration(&self) -> i64 { - self.0.duration + self.0.duration as i64 } #[inline] diff --git a/src/codec/packet/side_data.rs b/src/codec/packet/side_data.rs index 4ebf096..a8274a0 100644 --- a/src/codec/packet/side_data.rs +++ b/src/codec/packet/side_data.rs @@ -195,6 +195,6 @@ impl<'a> SideData<'a> { } pub fn data(&self) -> &[u8] { - unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size) } + unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) } } } diff --git a/src/codec/subtitle/mod.rs b/src/codec/subtitle/mod.rs index d42552a..a833179 100644 --- a/src/codec/subtitle/mod.rs +++ b/src/codec/subtitle/mod.rs @@ -79,7 +79,7 @@ impl Subtitle { } pub fn start(&self) -> u32 { - self.0.start_display_time + self.0.start_display_time as u32 } pub fn set_start(&mut self, value: u32) { @@ -87,7 +87,7 @@ impl Subtitle { } pub fn end(&self) -> u32 { - self.0.end_display_time + self.0.end_display_time as u32 } pub fn set_end(&mut self, value: u32) { diff --git a/src/format/chapter/chapter.rs b/src/format/chapter/chapter.rs index 6e8d0ff..603452b 100644 --- a/src/format/chapter/chapter.rs +++ b/src/format/chapter/chapter.rs @@ -26,7 +26,7 @@ impl<'a> Chapter<'a> { } pub fn id(&self) -> i64 { - unsafe { (*self.as_ptr()).id } + unsafe { (*self.as_ptr()).id as i64 } } pub fn time_base(&self) -> Rational { diff --git a/src/lib.rs b/src/lib.rs index 9117fcc..aff3dca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,8 @@ #![allow(clippy::missing_safety_doc)] #![allow(clippy::module_inception)] #![allow(clippy::too_many_arguments)] +// FFI Types may differ across platforms, making casts necessary +#![allow(clippy::unnecessary_cast)] #[macro_use] extern crate bitflags; diff --git a/src/util/dictionary/owned.rs b/src/util/dictionary/owned.rs index 16f2ba0..0891320 100644 --- a/src/util/dictionary/owned.rs +++ b/src/util/dictionary/owned.rs @@ -81,7 +81,7 @@ impl<'a, 'b> FromIterator<&'b (String, String)> for Owned<'a> { fn from_iter>(iterator: T) -> Self { let mut result = Owned::new(); - for &(ref key, ref value) in iterator { + for (key, value) in iterator { result.set(key, value); } diff --git a/src/util/frame/audio.rs b/src/util/frame/audio.rs index 19672ff..9c9a671 100644 --- a/src/util/frame/audio.rs +++ b/src/util/frame/audio.rs @@ -69,7 +69,7 @@ impl Audio { #[inline] pub fn set_channel_layout(&mut self, value: ChannelLayout) { unsafe { - (*self.as_mut_ptr()).channel_layout = value.bits(); + (*self.as_mut_ptr()).channel_layout = value.bits() as u64; } } @@ -140,7 +140,7 @@ impl Audio { panic!("out of bounds"); } - if !::is_valid(self.format(), self.channels()) { + if !::is_valid(self.format(), self.channels() as u16) { panic!("unsupported type"); } @@ -153,7 +153,7 @@ impl Audio { panic!("out of bounds"); } - if !::is_valid(self.format(), self.channels()) { + if !::is_valid(self.format(), self.channels() as u16) { panic!("unsupported type"); } diff --git a/src/util/frame/mod.rs b/src/util/frame/mod.rs index 0ab7c38..0f6a944 100644 --- a/src/util/frame/mod.rs +++ b/src/util/frame/mod.rs @@ -79,8 +79,8 @@ impl Frame { pub fn packet(&self) -> Packet { unsafe { Packet { - duration: (*self.as_ptr()).pkt_duration, - position: (*self.as_ptr()).pkt_pos, + duration: (*self.as_ptr()).pkt_duration as i64, + position: (*self.as_ptr()).pkt_pos as i64, size: (*self.as_ptr()).pkt_size as usize, #[cfg(not(feature = "ffmpeg_5_0"))] @@ -95,7 +95,7 @@ impl Frame { unsafe { match (*self.as_ptr()).pts { AV_NOPTS_VALUE => None, - pts => Some(pts), + pts => Some(pts as i64), } } } @@ -112,7 +112,7 @@ impl Frame { unsafe { match (*self.as_ptr()).best_effort_timestamp { AV_NOPTS_VALUE => None, - t => Some(t), + t => Some(t as i64), } } } diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index c2abbb4..bcf088a 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -219,7 +219,7 @@ impl<'a> SideData<'a> { #[inline] pub fn data(&self) -> &[u8] { - unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size) } + unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) } } #[inline] diff --git a/src/util/time.rs b/src/util/time.rs index 9757953..373a5ea 100644 --- a/src/util/time.rs +++ b/src/util/time.rs @@ -3,12 +3,12 @@ use Error; #[inline(always)] pub fn current() -> i64 { - unsafe { av_gettime() } + unsafe { av_gettime() as i64 } } #[inline(always)] pub fn relative() -> i64 { - unsafe { av_gettime_relative() } + unsafe { av_gettime_relative() as i64 } } #[inline(always)]