Fix an issue where compilation may fail on some non-x64 platforms

This commit is contained in:
Josh Holmer 2023-02-02 13:25:17 -05:00
parent fe89e158c0
commit ed9703b739
12 changed files with 25 additions and 19 deletions

View File

@ -1,3 +1,7 @@
## Version 1.1.1
- Fix compilation on some non-x64 platforms
## Version 1.1.0 ## Version 1.1.0
- Add `serialize` feature, off by default, which derives `serde::{Serialize, Deserialize}` for as many types as possible - Add `serialize` feature, off by default, which derives `serde::{Serialize, Deserialize}` for as many types as possible

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ffmpeg-the-third" name = "ffmpeg-the-third"
version = "1.1.0+ffmpeg-5.1.2" version = "1.1.1+ffmpeg-5.1.2"
build = "build.rs" build = "build.rs"
authors = ["meh. <meh@schizofreni.co>", "Zhiming Wang <i@zhimingwang.org>"] authors = ["meh. <meh@schizofreni.co>", "Zhiming Wang <i@zhimingwang.org>"]

View File

@ -121,7 +121,7 @@ impl Packet {
pub fn pts(&self) -> Option<i64> { pub fn pts(&self) -> Option<i64> {
match self.0.pts { match self.0.pts {
AV_NOPTS_VALUE => None, AV_NOPTS_VALUE => None,
pts => Some(pts), pts => Some(pts as i64),
} }
} }
@ -134,7 +134,7 @@ impl Packet {
pub fn dts(&self) -> Option<i64> { pub fn dts(&self) -> Option<i64> {
match self.0.dts { match self.0.dts {
AV_NOPTS_VALUE => None, AV_NOPTS_VALUE => None,
dts => Some(dts), dts => Some(dts as i64),
} }
} }
@ -150,7 +150,7 @@ impl Packet {
#[inline] #[inline]
pub fn duration(&self) -> i64 { pub fn duration(&self) -> i64 {
self.0.duration self.0.duration as i64
} }
#[inline] #[inline]

View File

@ -195,6 +195,6 @@ impl<'a> SideData<'a> {
} }
pub fn data(&self) -> &[u8] { 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) }
} }
} }

View File

@ -79,7 +79,7 @@ impl Subtitle {
} }
pub fn start(&self) -> u32 { 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) { pub fn set_start(&mut self, value: u32) {
@ -87,7 +87,7 @@ impl Subtitle {
} }
pub fn end(&self) -> u32 { 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) { pub fn set_end(&mut self, value: u32) {

View File

@ -26,7 +26,7 @@ impl<'a> Chapter<'a> {
} }
pub fn id(&self) -> i64 { pub fn id(&self) -> i64 {
unsafe { (*self.as_ptr()).id } unsafe { (*self.as_ptr()).id as i64 }
} }
pub fn time_base(&self) -> Rational { pub fn time_base(&self) -> Rational {

View File

@ -2,6 +2,8 @@
#![allow(clippy::missing_safety_doc)] #![allow(clippy::missing_safety_doc)]
#![allow(clippy::module_inception)] #![allow(clippy::module_inception)]
#![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_arguments)]
// FFI Types may differ across platforms, making casts necessary
#![allow(clippy::unnecessary_cast)]
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;

View File

@ -81,7 +81,7 @@ impl<'a, 'b> FromIterator<&'b (String, String)> for Owned<'a> {
fn from_iter<T: IntoIterator<Item = &'b (String, String)>>(iterator: T) -> Self { fn from_iter<T: IntoIterator<Item = &'b (String, String)>>(iterator: T) -> Self {
let mut result = Owned::new(); let mut result = Owned::new();
for &(ref key, ref value) in iterator { for (key, value) in iterator {
result.set(key, value); result.set(key, value);
} }

View File

@ -69,7 +69,7 @@ impl Audio {
#[inline] #[inline]
pub fn set_channel_layout(&mut self, value: ChannelLayout) { pub fn set_channel_layout(&mut self, value: ChannelLayout) {
unsafe { 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"); panic!("out of bounds");
} }
if !<T as Sample>::is_valid(self.format(), self.channels()) { if !<T as Sample>::is_valid(self.format(), self.channels() as u16) {
panic!("unsupported type"); panic!("unsupported type");
} }
@ -153,7 +153,7 @@ impl Audio {
panic!("out of bounds"); panic!("out of bounds");
} }
if !<T as Sample>::is_valid(self.format(), self.channels()) { if !<T as Sample>::is_valid(self.format(), self.channels() as u16) {
panic!("unsupported type"); panic!("unsupported type");
} }

View File

@ -79,8 +79,8 @@ impl Frame {
pub fn packet(&self) -> Packet { pub fn packet(&self) -> Packet {
unsafe { unsafe {
Packet { Packet {
duration: (*self.as_ptr()).pkt_duration, duration: (*self.as_ptr()).pkt_duration as i64,
position: (*self.as_ptr()).pkt_pos, position: (*self.as_ptr()).pkt_pos as i64,
size: (*self.as_ptr()).pkt_size as usize, size: (*self.as_ptr()).pkt_size as usize,
#[cfg(not(feature = "ffmpeg_5_0"))] #[cfg(not(feature = "ffmpeg_5_0"))]
@ -95,7 +95,7 @@ impl Frame {
unsafe { unsafe {
match (*self.as_ptr()).pts { match (*self.as_ptr()).pts {
AV_NOPTS_VALUE => None, AV_NOPTS_VALUE => None,
pts => Some(pts), pts => Some(pts as i64),
} }
} }
} }
@ -112,7 +112,7 @@ impl Frame {
unsafe { unsafe {
match (*self.as_ptr()).best_effort_timestamp { match (*self.as_ptr()).best_effort_timestamp {
AV_NOPTS_VALUE => None, AV_NOPTS_VALUE => None,
t => Some(t), t => Some(t as i64),
} }
} }
} }

View File

@ -219,7 +219,7 @@ impl<'a> SideData<'a> {
#[inline] #[inline]
pub fn data(&self) -> &[u8] { 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] #[inline]

View File

@ -3,12 +3,12 @@ use Error;
#[inline(always)] #[inline(always)]
pub fn current() -> i64 { pub fn current() -> i64 {
unsafe { av_gettime() } unsafe { av_gettime() as i64 }
} }
#[inline(always)] #[inline(always)]
pub fn relative() -> i64 { pub fn relative() -> i64 {
unsafe { av_gettime_relative() } unsafe { av_gettime_relative() as i64 }
} }
#[inline(always)] #[inline(always)]