Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to (Update to FFmpeg 7.1 (#213)) [SHA: a7b50dd5f909e071affffe238d434d184da30aee]
  • Loading branch information
admin committed Oct 8, 2024
1 parent 7daf2f5 commit f328231
Show file tree
Hide file tree
Showing 74 changed files with 2,453 additions and 1,079 deletions.
1 change: 1 addition & 0 deletions ffmpeg-next/src/codec/audio_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl From<ffi::AVAudioServiceType> for AudioService {
ffi::AV_AUDIO_SERVICE_TYPE_VOICE_OVER => AudioService::VoiceOver,
ffi::AV_AUDIO_SERVICE_TYPE_KARAOKE => AudioService::Karaoke,
ffi::AV_AUDIO_SERVICE_TYPE_NB => AudioService::Main,

// non-exhaustive patterns: `10_u32..=u32::MAX` not covered
10_u32..=u32::MAX => todo!(),
}
Expand Down
11 changes: 11 additions & 0 deletions ffmpeg-next/src/codec/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@ bitflags! {
pub struct Capabilities: c_uint {
const DRAW_HORIZ_BAND = ffi::AV_CODEC_CAP_DRAW_HORIZ_BAND;
const DR1 = ffi::AV_CODEC_CAP_DR1;
// #[cfg(not(feature = "ffmpeg_6_0"))]
// const TRUNCATED = ffi::AV_CODEC_CAP_TRUNCATED;
const DELAY = ffi::AV_CODEC_CAP_DELAY;
const SMALL_LAST_FRAME = ffi::AV_CODEC_CAP_SMALL_LAST_FRAME;
// #[cfg(not(feature = "ffmpeg_4_0"))]
// const HWACCEL_VDPAU = ffi::AV_CODEC_CAP_HWACCEL_VDPAU;
const SUBFRAMES = ffi::AV_CODEC_CAP_SUBFRAMES;
const EXPERIMENTAL = ffi::AV_CODEC_CAP_EXPERIMENTAL;
const CHANNEL_CONF = ffi::AV_CODEC_CAP_CHANNEL_CONF;
const FRAME_THREADS = ffi::AV_CODEC_CAP_FRAME_THREADS;
const SLICE_THREADS = ffi::AV_CODEC_CAP_SLICE_THREADS;
const PARAM_CHANGE = ffi::AV_CODEC_CAP_PARAM_CHANGE;
// #[cfg(not(feature = "ffmpeg_6_0"))]
// const AUTO_THREADS = ffi::AV_CODEC_CAP_AUTO_THREADS;
// #[cfg(feature = "ffmpeg_6_0")]
const OTHER_THREADS = ffi::AV_CODEC_CAP_OTHER_THREADS;
const VARIABLE_FRAME_SIZE = ffi::AV_CODEC_CAP_VARIABLE_FRAME_SIZE;
// #[cfg(not(feature = "ffmpeg_6_0"))]
// const INTRA_ONLY = ffi::AV_CODEC_CAP_INTRA_ONLY;
// #[cfg(not(feature = "ffmpeg_6_0"))]
// const LOSSLESS = ffi::AV_CODEC_CAP_LOSSLESS;
const AVOID_PROBING = ffi::AV_CODEC_CAP_AVOID_PROBING;
const HARDWARE = ffi::AV_CODEC_CAP_HARDWARE;
const HYBRID = ffi::AV_CODEC_CAP_HYBRID;
Expand Down
5 changes: 3 additions & 2 deletions ffmpeg-next/src/codec/codec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::ffi::CStr;
use std::str::from_utf8_unchecked;

use super::{Audio, Capabilities, Id, Profile, Video};
use rsmpeg::ffi;
use {crate::media, crate::Error};

use super::{Audio, Capabilities, Id, Profile, Video};
use crate::{media, Error};

#[derive(PartialEq, Eq, Copy, Clone)]
pub struct Codec {
Expand Down
73 changes: 36 additions & 37 deletions ffmpeg-next/src/codec/compliance.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
// use rsmpeg::ffi;
// use libc::c_int;
//
// #[derive(Eq, PartialEq, Clone, Copy, Debug)]
// pub enum Compliance {
// VeryStrict,
// Strict,
// Normal,
// Unofficial,
// Experimental,
// }
//
// impl From<c_int> for Compliance {
// fn from(value: c_int) -> Self {
// let val_u32: u32 = value as u32;
// match val_u32 {
// ffi::FF_COMPLIANCE_VERY_STRICT => Compliance::VeryStrict,
// ffi::FF_COMPLIANCE_STRICT => Compliance::Strict,
// ffi::FF_COMPLIANCE_NORMAL => Compliance::Normal,
// ffi::FF_COMPLIANCE_UNOFFICIAL => Compliance::Unofficial,
// ffi::FF_COMPLIANCE_EXPERIMENTAL => Compliance::Experimental,
// _ => Compliance::Normal,
// }
// }
// }
//
// impl From<Compliance> for c_int {
// fn from(value: Compliance) -> c_int {
// match value {
// Compliance::VeryStrict => ffi::FF_COMPLIANCE_VERY_STRICT as i32,
// Compliance::Strict => ffi::FF_COMPLIANCE_STRICT as i32,
// Compliance::Normal => ffi::FF_COMPLIANCE_NORMAL as i32,
// Compliance::Unofficial => ffi::FF_COMPLIANCE_UNOFFICIAL,
// Compliance::Experimental => ffi::FF_COMPLIANCE_EXPERIMENTAL,
// }
// }
// }
use rsmpeg::ffi;
use libc::c_int;

#[derive(Eq, PartialEq, Clone, Copy, Debug)]
pub enum Compliance {
VeryStrict,
Strict,
Normal,
Unofficial,
Experimental,
}

impl From<c_int> for Compliance {
fn from(value: c_int) -> Self {
match value {
x if x == ffi::FF_COMPLIANCE_VERY_STRICT as i32 => Compliance::VeryStrict,
x if x == ffi::FF_COMPLIANCE_STRICT as i32 => Compliance::Strict,
x if x == ffi::FF_COMPLIANCE_NORMAL as i32 => Compliance::Normal,
x if x == ffi::FF_COMPLIANCE_UNOFFICIAL => Compliance::Unofficial,
x if x == ffi::FF_COMPLIANCE_EXPERIMENTAL => Compliance::Experimental,
_ => Compliance::Normal,
}
}
}

impl From<Compliance> for c_int {
fn from(value: Compliance) -> c_int {
match value {
Compliance::VeryStrict => ffi::FF_COMPLIANCE_VERY_STRICT as i32,
Compliance::Strict => ffi::FF_COMPLIANCE_STRICT as i32,
Compliance::Normal => ffi::FF_COMPLIANCE_NORMAL as i32,
Compliance::Unofficial => ffi::FF_COMPLIANCE_UNOFFICIAL,
Compliance::Experimental => ffi::FF_COMPLIANCE_EXPERIMENTAL,
}
}
}
31 changes: 19 additions & 12 deletions ffmpeg-next/src/codec/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ use std::any::Any;
use std::ptr;
use std::rc::Rc;

use super::decoder::Decoder;
use super::encoder::Encoder;
use super::{threading, Debug, Flags, Id, Parameters};
use super::{
decoder::Decoder,
encoder::Encoder,
threading, Compliance, Debug, Flags, Id, Parameters,
};

use crate::{
media,
Codec,
Error,
Rational,
};

use crate::media;
use {crate::Codec, crate::Error, crate::Rational};

use rsmpeg::ffi;
use libc::c_int;
use rsmpeg::ffi;

pub struct Context {
ptr: *mut ffi::AVCodecContext,
Expand Down Expand Up @@ -96,11 +102,11 @@ impl Context {
unsafe { Id::from((*self.as_ptr()).codec_id) }
}

// pub fn compliance(&mut self, value: Compliance) {
// unsafe {
// (*self.as_mut_ptr()).strict_std_compliance = value.into();
// }
// }
pub fn compliance(&mut self, value: Compliance) {
unsafe {
(*self.as_mut_ptr()).strict_std_compliance = value.into();
}
}

pub fn debug(&mut self, value: Debug) {
unsafe {
Expand All @@ -126,6 +132,7 @@ impl Context {
count: (*self.as_ptr()).thread_count as usize,
#[cfg(not(feature = "ffmpeg7"))]
safe: (*self.as_ptr()).thread_safe_callbacks != 0,
safe: true,
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions ffmpeg-next/src/codec/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ bitflags! {
const BITSTREAM = ffi::FF_DEBUG_BITSTREAM as i32;
const MB_TYPE = ffi::FF_DEBUG_MB_TYPE as i32;
const QP = ffi::FF_DEBUG_QP as i32;
// #[cfg(not(feature = "ffmpeg_4_0"))]
// const MV = ffi::FF_DEBUG_MV;
const DCT_COEFF = ffi::FF_DEBUG_DCT_COEFF as i32;
const SKIP = ffi::FF_DEBUG_SKIP as i32;
const STARTCODE = ffi::FF_DEBUG_STARTCODE as i32;
// #[cfg(not(feature = "ffmpeg_4_0"))]
// const PTS = ffi::FF_DEBUG_PTS;
const ER = ffi::FF_DEBUG_ER as i32;
const MMCO = ffi::FF_DEBUG_MMCO as i32;
const BUGS = ffi::FF_DEBUG_BUGS as i32;
// #[cfg(not(feature = "ffmpeg_4_0"))]
// const VIS_QP = ffi::FF_DEBUG_VIS_QP;
// #[cfg(not(feature = "ffmpeg_4_0"))]
// const VIS_MB_TYPE = ffi::FF_DEBUG_VIS_MB_TYPE;
const BUFFERS = ffi::FF_DEBUG_BUFFERS as i32;
const THREADS = ffi::FF_DEBUG_THREADS as i32;
const GREEN_MD = ffi::FF_DEBUG_GREEN_MD as i32;
Expand Down
12 changes: 9 additions & 3 deletions ffmpeg-next/src/codec/decoder/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use std::ops::{Deref, DerefMut};
use std::ptr;

use super::{Audio, Check, Conceal, Opened, Subtitle, Video};
use crate::codec::{traits, Context};
use {crate::Dictionary, crate::Discard, crate::Error, crate::Rational};
use rsmpeg::ffi;

use super::{Audio, Check, Conceal, Opened, Subtitle, Video};
use crate::{
codec::{traits, Context},
Dictionary,
Discard,
Error,
Rational,
};

pub struct Decoder(pub Context);

impl Decoder {
Expand Down
13 changes: 10 additions & 3 deletions ffmpeg-next/src/codec/decoder/opened.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use std::ops::{Deref, DerefMut};
use std::ptr;

use super::{Audio, Decoder, Subtitle, Video};
use crate::codec::{Context, Profile};
use {crate::media, crate::packet, crate::Error, crate::Frame, crate::Rational};
use rsmpeg::ffi;

use super::{Audio, Decoder, Subtitle, Video};
use crate::{
codec::{Context, Profile},
media,
packet,
Error,
Frame,
Rational,
};

pub struct Opened(pub Decoder);

impl Opened {
Expand Down
9 changes: 6 additions & 3 deletions ffmpeg-next/src/codec/decoder/subtitle.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use std::ops::{Deref, DerefMut};

use rsmpeg::ffi;
use libc::c_int;
use rsmpeg::ffi;

use super::Opened;
use crate::codec::Context;
use {crate::packet, crate::Error};
use crate::{
codec::Context,
packet,
Error,
};

pub struct Subtitle(pub Opened);

Expand Down
3 changes: 2 additions & 1 deletion ffmpeg-next/src/codec/discard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ impl From<ffi::AVDiscard> for Discard {
ffi::AVDISCARD_NONINTRA => Discard::NonIntra,
ffi::AVDISCARD_NONKEY => Discard::NonKey,
ffi::AVDISCARD_ALL => Discard::All,

// non-exhaustive patterns: `i32::MIN..=-17_i32`, `-15_i32..=-1_i32`, `1_i32..=7_i32` and 5 more not covered
_ => todo!(),
_ => todo!("unknown discard value {}", value),
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions ffmpeg-next/src/codec/encoder/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ use std::ptr;
use rsmpeg::ffi;

use super::Encoder as Super;
use crate::codec::{traits, Context};
use crate::util::format;
use {crate::ChannelLayout, crate::Dictionary, crate::Error};

use crate::{
codec::{traits, Context},
util::format,
ChannelLayout,
Dictionary,
Error,
};

pub struct Audio(pub Super);

Expand Down
11 changes: 8 additions & 3 deletions ffmpeg-next/src/codec/encoder/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
use std::ops::{Deref, DerefMut};
use std::ptr;

use rsmpeg::ffi;
use libc::c_int;
use rsmpeg::ffi;

use super::{audio, subtitle, video};
use crate::codec::Context;
use {crate::media, crate::packet, crate::Error, crate::Frame};
use crate::{
codec::Context,
media,
packet,
Error,
Frame,
};

pub struct Encoder(pub Context);

Expand Down
10 changes: 7 additions & 3 deletions ffmpeg-next/src/codec/encoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub use self::subtitle::Encoder as Subtitle;
pub mod motion_estimation;
pub use self::motion_estimation::MotionEstimation;

// #[cfg(not(feature = "ffmpeg_5_0"))]
// pub mod prediction;
// pub use self::prediction::Prediction;

pub mod comparison;
pub use self::comparison::Comparison;
Expand All @@ -22,9 +25,10 @@ pub use self::decision::Decision;

use std::ffi::CString;

use crate::codec::Context;
use crate::codec::Id;
use crate::Codec;
use crate::{
codec::{Context, Id},
Codec,
};

use rsmpeg::ffi;

Expand Down
7 changes: 5 additions & 2 deletions ffmpeg-next/src/codec/encoder/subtitle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use rsmpeg::ffi;
use libc::c_int;

use super::Encoder as Super;
use crate::codec::{traits, Context};
use {crate::Dictionary, crate::Error};
use crate::{
codec::{traits, Context},
Dictionary,
Error
};

pub struct Subtitle(pub Super);

Expand Down
Loading

0 comments on commit f328231

Please sign in to comment.