Skip to content

Commit

Permalink
Revert "Update rusty_ffmpeg requirement from 0.13.3 to 0.16.1"
Browse files Browse the repository at this point in the history
This reverts commit 5250aa6.
  • Loading branch information
dominikWin committed Oct 4, 2024
1 parent c5a8d54 commit 260e197
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion vidformer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/ixlab/vidformer"
categories = ["multimedia", "multimedia::video"]

[dependencies]
rusty_ffmpeg = {version = "0.16.1", features = ["link_system_ffmpeg"]}
rusty_ffmpeg = {version = "0.13.3", features = ["link_system_ffmpeg"]}
log = "0.4.20"
"num-traits" = "0.2"
"num-rational" = { version = "0.4", features=["serde"] }
Expand Down
4 changes: 2 additions & 2 deletions vidformer/src/av/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Demuxer {
.enumerate()
{
if i != stream_idx {
stream.discard = ffi::AVDISCARD_ALL;
stream.discard = ffi::AVDiscard_AVDISCARD_ALL;
continue;
}

Expand All @@ -194,7 +194,7 @@ impl Demuxer {
unsafe { ffi::avcodec_find_decoder(local_codec_params.codec_id).as_ref() }
.expect("ERROR unsupported codec!");

if local_codec_params.codec_type == ffi::AVMEDIA_TYPE_VIDEO {
if local_codec_params.codec_type == ffi::AVMediaType_AVMEDIA_TYPE_VIDEO {
if video_stream_index.is_none() {
video_stream_index = Some(i);
codec_ptr = local_codec;
Expand Down
6 changes: 3 additions & 3 deletions vidformer/src/av/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Encoder {
let codec = match &config.encoder {
Some(enc_cfg) => enc_cfg.avcodec()?,
None => {
let codec = unsafe { ffi::avcodec_find_encoder(ffi::AV_CODEC_ID_H264) };
let codec = unsafe { ffi::avcodec_find_encoder(ffi::AVCodecID_AV_CODEC_ID_H264) };
match unsafe { codec.as_ref() } {
Some(codec) => codec,
None => panic!("Failed to find default h264 encoder"),
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Encoder {

let pix_fmt_name = CString::new(config.output_pix_fmt.clone()).unwrap();
let output_pix_fmt = unsafe { ffi::av_get_pix_fmt(pix_fmt_name.as_ptr()) };
if output_pix_fmt == ffi::AV_PIX_FMT_NONE {
if output_pix_fmt == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(crate::Error::ConfigError(format!(
"Failed to find output pix fmt `{}`",
config.output_pix_fmt
Expand Down Expand Up @@ -133,7 +133,7 @@ impl Encoder {
unsafe {
// It's none of our business what the input frame type is
// Also, we don't want the encoder to complain if something looks weird
(*frame.inner).pict_type = ffi::AV_PICTURE_TYPE_NONE;
(*frame.inner).pict_type = ffi::AVPictureType_AV_PICTURE_TYPE_NONE;
}

let time_scaled = pts / self.time_base;
Expand Down
2 changes: 1 addition & 1 deletion vidformer/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'de> Deserialize<'de> for Frame {
let fmt_cstr = std::ffi::CString::new(format_str).unwrap();

let format = unsafe { ffi::av_get_pix_fmt(fmt_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(serde::de::Error::custom(format!(
"Invalid pixel format {:?}",
format_str
Expand Down
26 changes: 13 additions & 13 deletions vidformer/src/filter/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn avfilter_backed_uniframe(
unsafe {
(*f).width = (*frame.inner).width;
(*f).height = (*frame.inner).height;
(*f).format = ffi::AV_PIX_FMT_YUV420P;
(*f).format = ffi::AVPixelFormat_AV_PIX_FMT_YUV420P;

if ffi::av_frame_get_buffer(f, 0) < 0 {
panic!(
Expand Down Expand Up @@ -221,7 +221,7 @@ where
unsafe {
(*f).width = width;
(*f).height = height;
(*f).format = ffi::AV_PIX_FMT_YUV420P;
(*f).format = ffi::AVPixelFormat_AV_PIX_FMT_YUV420P;

if ffi::av_frame_get_buffer(f, 0) < 0 {
panic!("ERROR could not allocate frame data");
Expand Down Expand Up @@ -295,7 +295,7 @@ impl super::Filter for PlaceholderFrame {
unsafe {
(*f).width = width as i32;
(*f).height = height as i32;
(*f).format = ffi::AV_PIX_FMT_YUV420P;
(*f).format = ffi::AVPixelFormat_AV_PIX_FMT_YUV420P;

if ffi::av_frame_get_buffer(f, 0) < 0 {
panic!("ERROR could not allocate frame data");
Expand Down Expand Up @@ -333,7 +333,7 @@ impl super::Filter for PlaceholderFrame {
Ok(FrameType::new(
width as usize,
height as usize,
ffi::AV_PIX_FMT_YUV420P,
ffi::AVPixelFormat_AV_PIX_FMT_YUV420P,
))
}
}
Expand All @@ -353,13 +353,13 @@ impl super::Filter for Annotate {
_ => panic!("Expected frame"),
};

assert_eq!(input_frame.format, ffi::AV_PIX_FMT_YUV420P);
assert_eq!(input_frame.format, ffi::AVPixelFormat_AV_PIX_FMT_YUV420P);

let f = unsafe { ffi::av_frame_alloc() };
unsafe {
(*f).width = input_frame.width;
(*f).height = input_frame.height;
(*f).format = ffi::AV_PIX_FMT_YUV420P;
(*f).format = ffi::AVPixelFormat_AV_PIX_FMT_YUV420P;

if ffi::av_frame_get_buffer(f, 0) < 0 {
panic!("ERROR could not allocate frame data");
Expand Down Expand Up @@ -624,7 +624,7 @@ impl super::Filter for Scale {
Val::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down Expand Up @@ -728,7 +728,7 @@ impl super::Filter for Scale {
ValType::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down Expand Up @@ -807,7 +807,7 @@ impl super::Filter for Pad {
unsafe {
(*f).width = width as i32;
(*f).height = height as i32;
(*f).format = ffi::AV_PIX_FMT_YUV420P;
(*f).format = ffi::AVPixelFormat_AV_PIX_FMT_YUV420P;

if ffi::av_frame_get_buffer(f, 0) < 0 {
panic!("ERROR could not allocate frame data");
Expand Down Expand Up @@ -1043,7 +1043,7 @@ impl super::Filter for HStack {
Val::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down Expand Up @@ -1225,7 +1225,7 @@ impl super::Filter for HStack {
ValType::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down Expand Up @@ -1272,7 +1272,7 @@ impl super::Filter for VStack {
Val::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down Expand Up @@ -1454,7 +1454,7 @@ impl super::Filter for VStack {
ValType::String(s) => {
let format_cstr = CString::new(s.as_str()).unwrap();
let format = unsafe { ffi::av_get_pix_fmt(format_cstr.as_ptr()) };
if format == ffi::AV_PIX_FMT_NONE {
if format == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
return Err(Error::InvalidFilterArgValue(
s.clone(),
"Invalid pixel format".to_string(),
Expand Down
32 changes: 17 additions & 15 deletions vidformer/src/filter/builtin/drawutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub(crate) unsafe fn ff_draw_init(
ff_draw_init2(
draw,
format,
ffi::AVCOL_SPC_UNSPECIFIED,
ffi::AVCOL_RANGE_UNSPECIFIED,
ffi::AVColorSpace_AVCOL_SPC_UNSPECIFIED,
ffi::AVColorRange_AVCOL_RANGE_UNSPECIFIED,
flags,
)
}
Expand Down Expand Up @@ -76,11 +76,11 @@ pub(crate) unsafe fn ff_draw_init2(
}

let mut csp = csp;
if csp == ffi::AVCOL_SPC_UNSPECIFIED {
if csp == ffi::AVColorSpace_AVCOL_SPC_UNSPECIFIED {
csp = if (*desc).flags & ffi::AV_PIX_FMT_FLAG_RGB as u64 != 0 {
ffi::AVCOL_SPC_RGB
ffi::AVColorSpace_AVCOL_SPC_RGB
} else {
ffi::AVCOL_SPC_SMPTE170M
ffi::AVColorSpace_AVCOL_SPC_SMPTE170M
};
}

Expand All @@ -94,19 +94,21 @@ pub(crate) unsafe fn ff_draw_init2(
}

let mut range = range;
if range == ffi::AVCOL_RANGE_UNSPECIFIED {
if range == ffi::AVColorRange_AVCOL_RANGE_UNSPECIFIED {
range = match format {
ffi::AV_PIX_FMT_YUVJ420P
| ffi::AV_PIX_FMT_YUVJ422P
| ffi::AV_PIX_FMT_YUVJ444P
| ffi::AV_PIX_FMT_YUVJ411P
| ffi::AV_PIX_FMT_YUVJ440P
| _ if csp == ffi::AVCOL_SPC_RGB => ffi::AVCOL_RANGE_JPEG,
_ => ffi::AVCOL_RANGE_MPEG,
ffi::AVPixelFormat_AV_PIX_FMT_YUVJ420P
| ffi::AVPixelFormat_AV_PIX_FMT_YUVJ422P
| ffi::AVPixelFormat_AV_PIX_FMT_YUVJ444P
| ffi::AVPixelFormat_AV_PIX_FMT_YUVJ411P
| ffi::AVPixelFormat_AV_PIX_FMT_YUVJ440P
| _ if csp == ffi::AVColorSpace_AVCOL_SPC_RGB => ffi::AVColorRange_AVCOL_RANGE_JPEG,
_ => ffi::AVColorRange_AVCOL_RANGE_MPEG,
};
}

if range != ffi::AVCOL_RANGE_JPEG && range != ffi::AVCOL_RANGE_MPEG {
if range != ffi::AVColorRange_AVCOL_RANGE_JPEG
&& range != ffi::AVColorRange_AVCOL_RANGE_MPEG
{
return ffi::AVERROR(ffi::EINVAL);
}

Expand Down Expand Up @@ -244,7 +246,7 @@ pub(crate) unsafe fn ff_draw_color(
// Adjust YUV values according to the color range
for i in 0..3 {
let chroma = (desc.flags & ffi::AV_PIX_FMT_FLAG_RGB as u64 == 0) && i > 0;
if draw.range == ffi::AVCOL_RANGE_MPEG {
if draw.range == ffi::AVColorRange_AVCOL_RANGE_MPEG {
yuvad[i] *= if chroma { 224.0 / 255.0 } else { 219.0 / 255.0 };
yuvad[i] += if chroma { 128.0 / 255.0 } else { 16.0 / 255.0 };
} else if chroma {
Expand Down
4 changes: 2 additions & 2 deletions vidformer/src/filter/builtin/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl crate::filter::Filter for IPC {
) -> Result<FrameType, Error> {
for (i, arg) in args.iter().enumerate() {
if let ValType::Frame(ft) = arg {
if ft.format != ffi::AV_PIX_FMT_RGB24 {
if ft.format != ffi::AVPixelFormat_AV_PIX_FMT_RGB24 {
return Err(Error::FilterInternalError(format!(
"Unsupported pixel format {} in argument {}",
crate::util::pixel_fmt_str(ft.format),
Expand All @@ -154,7 +154,7 @@ impl crate::filter::Filter for IPC {

for (key, val) in kwargs.iter() {
if let ValType::Frame(ft) = val {
if ft.format != ffi::AV_PIX_FMT_RGB24 {
if ft.format != ffi::AVPixelFormat_AV_PIX_FMT_RGB24 {
return Err(Error::FilterInternalError(format!(
"Unsupported pixel format {:?} in keyword argument {}",
crate::util::pixel_fmt_str(ft.format),
Expand Down
4 changes: 2 additions & 2 deletions vidformer/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn codecs() -> Vec<CodecDescriptor> {
!codec.is_null()
} {
let codec = &*codec;
if codec.type_ != ffi::AVMEDIA_TYPE_VIDEO {
if codec.type_ != ffi::AVMediaType_AVMEDIA_TYPE_VIDEO {
continue;
}

Expand Down Expand Up @@ -91,7 +91,7 @@ pub(crate) fn fmt_av_codec(format: &ffi::AVCodec) -> String {
pub(crate) fn pixel_fmt_str_to_av_pix_fmt(s: &str) -> Result<ffi::AVPixelFormat, String> {
let s = CString::new(s).unwrap();
let fmt = unsafe { ffi::av_get_pix_fmt(s.as_ptr()) };
if fmt == ffi::AV_PIX_FMT_NONE {
if fmt == ffi::AVPixelFormat_AV_PIX_FMT_NONE {
Err(format!("Invalid pixel format: {}", s.to_str().unwrap()))
} else {
Ok(fmt)
Expand Down

0 comments on commit 260e197

Please sign in to comment.