mirror of
https://github.com/encounter/rust-ffmpeg-zmwangx.git
synced 2026-07-10 21:18:40 -07:00
Merge branch 'zmwangx:master' into master
This commit is contained in:
@@ -38,6 +38,41 @@ jobs:
|
||||
run: |
|
||||
cargo fmt -- --check
|
||||
|
||||
# Remove when ffmpeg 6.0 is available here https://github.com/jrottenberg/ffmpeg/
|
||||
build-test-lint-linux-latest:
|
||||
name: Linux - Latest ffmpeg - build, test and lint
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y software-properties-common
|
||||
sudo add-apt-repository -y ppa:savoury1/ffmpeg6
|
||||
sudo add-apt-repository -y ppa:savoury1/ffmpeg4
|
||||
sudo apt update
|
||||
sudo apt install -y --no-install-recommends clang curl pkg-config ffmpeg libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavfilter-dev libavdevice-dev libswresample-dev
|
||||
- name: Set up Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
- name: Build
|
||||
run: |
|
||||
cargo build --examples
|
||||
- name: Test
|
||||
run: |
|
||||
cargo test --examples
|
||||
- name: Lint
|
||||
run: |
|
||||
cargo clippy --examples -- -D warnings
|
||||
- name: Check format
|
||||
run: |
|
||||
cargo fmt -- --check
|
||||
|
||||
build-test-lint-macos:
|
||||
name: macOS - FFmpeg latest - build, test and lint
|
||||
runs-on: macos-latest
|
||||
|
||||
@@ -121,7 +121,7 @@ impl Packet {
|
||||
pub fn pts(&self) -> Option<i64> {
|
||||
match self.0.pts {
|
||||
AV_NOPTS_VALUE => None,
|
||||
pts => Some(pts as i64),
|
||||
pts => Some(pts),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ impl Packet {
|
||||
pub fn dts(&self) -> Option<i64> {
|
||||
match self.0.dts {
|
||||
AV_NOPTS_VALUE => None,
|
||||
dts => Some(dts as i64),
|
||||
dts => Some(dts),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ impl Packet {
|
||||
|
||||
#[inline]
|
||||
pub fn duration(&self) -> i64 {
|
||||
self.0.duration as i64
|
||||
self.0.duration
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -189,6 +189,9 @@ impl<'a> SideData<'a> {
|
||||
}
|
||||
|
||||
pub fn data(&self) -> &[u8] {
|
||||
unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) }
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
unsafe {
|
||||
slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ impl Subtitle {
|
||||
}
|
||||
|
||||
pub fn start(&self) -> u32 {
|
||||
self.0.start_display_time as u32
|
||||
self.0.start_display_time
|
||||
}
|
||||
|
||||
pub fn set_start(&mut self, value: u32) {
|
||||
@@ -81,7 +81,7 @@ impl Subtitle {
|
||||
}
|
||||
|
||||
pub fn end(&self) -> u32 {
|
||||
self.0.end_display_time as u32
|
||||
self.0.end_display_time
|
||||
}
|
||||
|
||||
pub fn set_end(&mut self, value: u32) {
|
||||
|
||||
@@ -26,7 +26,10 @@ impl<'a> Chapter<'a> {
|
||||
}
|
||||
|
||||
pub fn id(&self) -> i64 {
|
||||
unsafe { (*self.as_ptr()).id as i64 }
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
unsafe {
|
||||
(*self.as_ptr()).id as i64
|
||||
}
|
||||
}
|
||||
|
||||
pub fn time_base(&self) -> Rational {
|
||||
|
||||
@@ -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 {
|
||||
let mut result = Owned::new();
|
||||
|
||||
for &(ref key, ref value) in iterator {
|
||||
for (key, value) in iterator {
|
||||
result.set(key, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,7 @@ impl Audio {
|
||||
|
||||
#[inline]
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channel_layout = value.bits() as u64;
|
||||
}
|
||||
unsafe { (*self.as_mut_ptr()).channel_layout = value.bits() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -140,7 +138,7 @@ impl Audio {
|
||||
panic!("out of bounds");
|
||||
}
|
||||
|
||||
if !<T as Sample>::is_valid(self.format(), self.channels() as u16) {
|
||||
if !<T as Sample>::is_valid(self.format(), self.channels()) {
|
||||
panic!("unsupported type");
|
||||
}
|
||||
|
||||
@@ -153,7 +151,7 @@ impl Audio {
|
||||
panic!("out of bounds");
|
||||
}
|
||||
|
||||
if !<T as Sample>::is_valid(self.format(), self.channels() as u16) {
|
||||
if !<T as Sample>::is_valid(self.format(), self.channels()) {
|
||||
panic!("unsupported type");
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ impl Frame {
|
||||
pub fn packet(&self) -> Packet {
|
||||
unsafe {
|
||||
Packet {
|
||||
duration: (*self.as_ptr()).pkt_duration as i64,
|
||||
position: (*self.as_ptr()).pkt_pos as i64,
|
||||
duration: (*self.as_ptr()).pkt_duration,
|
||||
position: (*self.as_ptr()).pkt_pos,
|
||||
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 as i64),
|
||||
pts => Some(pts),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ impl Frame {
|
||||
unsafe {
|
||||
match (*self.as_ptr()).best_effort_timestamp {
|
||||
AV_NOPTS_VALUE => None,
|
||||
t => Some(t as i64),
|
||||
t => Some(t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,10 @@ impl<'a> SideData<'a> {
|
||||
|
||||
#[inline]
|
||||
pub fn data(&self) -> &[u8] {
|
||||
unsafe { slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize) }
|
||||
#[allow(clippy::unnecessary_cast)]
|
||||
unsafe {
|
||||
slice::from_raw_parts((*self.as_ptr()).data, (*self.as_ptr()).size as usize)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
+2
-2
@@ -3,12 +3,12 @@ use Error;
|
||||
|
||||
#[inline(always)]
|
||||
pub fn current() -> i64 {
|
||||
unsafe { av_gettime() as i64 }
|
||||
unsafe { av_gettime() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn relative() -> i64 {
|
||||
unsafe { av_gettime_relative() as i64 }
|
||||
unsafe { av_gettime_relative() }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
Reference in New Issue
Block a user