Skip to content

Commit 0bfca26

Browse files
Merge pull request #133 from AdrianEddy/master
Add ffmpeg 6.0 support
2 parents 7118b0c + 57bc381 commit 0bfca26

File tree

9 files changed

+234
-7
lines changed

9 files changed

+234
-7
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ffmpeg-next"
3-
version = "5.1.1"
3+
version = "6.0.0"
44
build = "build.rs"
55

66
authors = ["meh. <[email protected]>", "Zhiming Wang <[email protected]>"]
@@ -113,5 +113,5 @@ version = "0.23"
113113
optional = true
114114

115115
[dependencies.ffmpeg-sys-next]
116-
version = "5.1.1"
116+
version = "6.0.1"
117117
default-features = false

src/codec/capabilities.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ bitflags! {
55
pub struct Capabilities: c_uint {
66
const DRAW_HORIZ_BAND = AV_CODEC_CAP_DRAW_HORIZ_BAND;
77
const DR1 = AV_CODEC_CAP_DR1;
8+
#[cfg(not(feature = "ffmpeg_6_0"))]
89
const TRUNCATED = AV_CODEC_CAP_TRUNCATED;
910
const DELAY = AV_CODEC_CAP_DELAY;
1011
const SMALL_LAST_FRAME = AV_CODEC_CAP_SMALL_LAST_FRAME;
@@ -16,9 +17,14 @@ bitflags! {
1617
const FRAME_THREADS = AV_CODEC_CAP_FRAME_THREADS;
1718
const SLICE_THREADS = AV_CODEC_CAP_SLICE_THREADS;
1819
const PARAM_CHANGE = AV_CODEC_CAP_PARAM_CHANGE;
20+
#[cfg(not(feature = "ffmpeg_6_0"))]
1921
const AUTO_THREADS = AV_CODEC_CAP_AUTO_THREADS;
22+
#[cfg(feature = "ffmpeg_6_0")]
23+
const OTHER_THREADS = AV_CODEC_CAP_OTHER_THREADS;
2024
const VARIABLE_FRAME_SIZE = AV_CODEC_CAP_VARIABLE_FRAME_SIZE;
25+
#[cfg(not(feature = "ffmpeg_6_0"))]
2126
const INTRA_ONLY = AV_CODEC_CAP_INTRA_ONLY;
27+
#[cfg(not(feature = "ffmpeg_6_0"))]
2228
const LOSSLESS = AV_CODEC_CAP_LOSSLESS;
2329
}
2430
}

src/codec/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ impl Context {
101101
unsafe {
102102
(*self.as_mut_ptr()).thread_type = config.kind.into();
103103
(*self.as_mut_ptr()).thread_count = config.count as c_int;
104-
(*self.as_mut_ptr()).thread_safe_callbacks = if config.safe { 1 } else { 0 };
104+
#[cfg(not(feature = "ffmpeg_6_0"))]
105+
{
106+
(*self.as_mut_ptr()).thread_safe_callbacks = if config.safe { 1 } else { 0 };
107+
}
105108
}
106109
}
107110

@@ -110,6 +113,7 @@ impl Context {
110113
threading::Config {
111114
kind: threading::Type::from((*self.as_ptr()).active_thread_type),
112115
count: (*self.as_ptr()).thread_count as usize,
116+
#[cfg(not(feature = "ffmpeg_6_0"))]
113117
safe: (*self.as_ptr()).thread_safe_callbacks != 0,
114118
}
115119
}

src/codec/flag.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bitflags! {
1212
const PASS2 = AV_CODEC_FLAG_PASS2;
1313
const GRAY = AV_CODEC_FLAG_GRAY;
1414
const PSNR = AV_CODEC_FLAG_PSNR;
15+
#[cfg(not(feature = "ffmpeg_6_0"))]
1516
const TRUNCATED = AV_CODEC_FLAG_TRUNCATED;
1617
const INTERLACED_DCT = AV_CODEC_FLAG_INTERLACED_DCT;
1718
const LOW_DELAY = AV_CODEC_FLAG_LOW_DELAY;

src/codec/id.rs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,37 @@ pub enum Id {
613613
PHM,
614614
#[cfg(feature = "ffmpeg_5_1")]
615615
DFPWM,
616+
617+
#[cfg(feature = "ffmpeg_6_0")]
618+
RADIANCE_HDR,
619+
#[cfg(feature = "ffmpeg_6_0")]
620+
WBMP,
621+
#[cfg(feature = "ffmpeg_6_0")]
622+
MEDIA100,
623+
#[cfg(feature = "ffmpeg_6_0")]
624+
VQC,
625+
#[cfg(feature = "ffmpeg_6_0")]
626+
ADPCM_XMD,
627+
#[cfg(feature = "ffmpeg_6_0")]
628+
WADY_DPCM,
629+
#[cfg(feature = "ffmpeg_6_0")]
630+
CBD2_DPCM,
631+
#[cfg(feature = "ffmpeg_6_0")]
632+
BONK,
633+
#[cfg(feature = "ffmpeg_6_0")]
634+
MISC4,
635+
#[cfg(feature = "ffmpeg_6_0")]
636+
APAC,
637+
#[cfg(feature = "ffmpeg_6_0")]
638+
FTR,
639+
#[cfg(feature = "ffmpeg_6_0")]
640+
WAVARC,
641+
#[cfg(feature = "ffmpeg_6_0")]
642+
RKA,
643+
#[cfg(feature = "ffmpeg_6_0")]
644+
VNULL,
645+
#[cfg(feature = "ffmpeg_6_0")]
646+
ANULL,
616647
}
617648

618649
impl Id {
@@ -1233,6 +1264,37 @@ impl From<AVCodecID> for Id {
12331264
AV_CODEC_ID_PHM => Id::PHM,
12341265
#[cfg(feature = "ffmpeg_5_1")]
12351266
AV_CODEC_ID_DFPWM => Id::DFPWM,
1267+
1268+
#[cfg(feature = "ffmpeg_6_0")]
1269+
AV_CODEC_ID_RADIANCE_HDR => Id::RADIANCE_HDR,
1270+
#[cfg(feature = "ffmpeg_6_0")]
1271+
AV_CODEC_ID_WBMP => Id::WBMP,
1272+
#[cfg(feature = "ffmpeg_6_0")]
1273+
AV_CODEC_ID_MEDIA100 => Id::MEDIA100,
1274+
#[cfg(feature = "ffmpeg_6_0")]
1275+
AV_CODEC_ID_VQC => Id::VQC,
1276+
#[cfg(feature = "ffmpeg_6_0")]
1277+
AV_CODEC_ID_ADPCM_XMD => Id::ADPCM_XMD,
1278+
#[cfg(feature = "ffmpeg_6_0")]
1279+
AV_CODEC_ID_WADY_DPCM => Id::WADY_DPCM,
1280+
#[cfg(feature = "ffmpeg_6_0")]
1281+
AV_CODEC_ID_CBD2_DPCM => Id::CBD2_DPCM,
1282+
#[cfg(feature = "ffmpeg_6_0")]
1283+
AV_CODEC_ID_BONK => Id::BONK,
1284+
#[cfg(feature = "ffmpeg_6_0")]
1285+
AV_CODEC_ID_MISC4 => Id::MISC4,
1286+
#[cfg(feature = "ffmpeg_6_0")]
1287+
AV_CODEC_ID_APAC => Id::APAC,
1288+
#[cfg(feature = "ffmpeg_6_0")]
1289+
AV_CODEC_ID_FTR => Id::FTR,
1290+
#[cfg(feature = "ffmpeg_6_0")]
1291+
AV_CODEC_ID_WAVARC => Id::WAVARC,
1292+
#[cfg(feature = "ffmpeg_6_0")]
1293+
AV_CODEC_ID_RKA => Id::RKA,
1294+
#[cfg(feature = "ffmpeg_6_0")]
1295+
AV_CODEC_ID_VNULL => Id::VNULL,
1296+
#[cfg(feature = "ffmpeg_6_0")]
1297+
AV_CODEC_ID_ANULL => Id::ANULL,
12361298
}
12371299
}
12381300
}
@@ -1845,6 +1907,37 @@ impl From<Id> for AVCodecID {
18451907
Id::PHM => AV_CODEC_ID_PHM,
18461908
#[cfg(feature = "ffmpeg_5_1")]
18471909
Id::DFPWM => AV_CODEC_ID_DFPWM,
1910+
1911+
#[cfg(feature = "ffmpeg_6_0")]
1912+
Id::RADIANCE_HDR => AV_CODEC_ID_RADIANCE_HDR,
1913+
#[cfg(feature = "ffmpeg_6_0")]
1914+
Id::WBMP => AV_CODEC_ID_WBMP,
1915+
#[cfg(feature = "ffmpeg_6_0")]
1916+
Id::MEDIA100 => AV_CODEC_ID_MEDIA100,
1917+
#[cfg(feature = "ffmpeg_6_0")]
1918+
Id::VQC => AV_CODEC_ID_VQC,
1919+
#[cfg(feature = "ffmpeg_6_0")]
1920+
Id::ADPCM_XMD => AV_CODEC_ID_ADPCM_XMD,
1921+
#[cfg(feature = "ffmpeg_6_0")]
1922+
Id::WADY_DPCM => AV_CODEC_ID_WADY_DPCM,
1923+
#[cfg(feature = "ffmpeg_6_0")]
1924+
Id::CBD2_DPCM => AV_CODEC_ID_CBD2_DPCM,
1925+
#[cfg(feature = "ffmpeg_6_0")]
1926+
Id::BONK => AV_CODEC_ID_BONK,
1927+
#[cfg(feature = "ffmpeg_6_0")]
1928+
Id::MISC4 => AV_CODEC_ID_MISC4,
1929+
#[cfg(feature = "ffmpeg_6_0")]
1930+
Id::APAC => AV_CODEC_ID_APAC,
1931+
#[cfg(feature = "ffmpeg_6_0")]
1932+
Id::FTR => AV_CODEC_ID_FTR,
1933+
#[cfg(feature = "ffmpeg_6_0")]
1934+
Id::WAVARC => AV_CODEC_ID_WAVARC,
1935+
#[cfg(feature = "ffmpeg_6_0")]
1936+
Id::RKA => AV_CODEC_ID_RKA,
1937+
#[cfg(feature = "ffmpeg_6_0")]
1938+
Id::VNULL => AV_CODEC_ID_VNULL,
1939+
#[cfg(feature = "ffmpeg_6_0")]
1940+
Id::ANULL => AV_CODEC_ID_ANULL,
18481941
}
18491942
}
18501943
}

src/codec/threading.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use libc::c_int;
55
pub struct Config {
66
pub kind: Type,
77
pub count: usize,
8+
#[cfg(not(feature = "ffmpeg_6_0"))]
89
pub safe: bool,
910
}
1011

@@ -23,6 +24,7 @@ impl Config {
2324
}
2425
}
2526

27+
#[cfg(not(feature = "ffmpeg_6_0"))]
2628
pub fn safe(value: bool) -> Self {
2729
Config {
2830
safe: value,
@@ -36,6 +38,7 @@ impl Default for Config {
3638
Config {
3739
kind: Type::None,
3840
count: 0,
41+
#[cfg(not(feature = "ffmpeg_6_0"))]
3942
safe: false,
4043
}
4144
}

src/filter/filter.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ impl Filter {
4747
if ptr.is_null() {
4848
None
4949
} else {
50-
Some(PadIter::new((*self.as_ptr()).inputs))
50+
#[cfg(not(feature = "ffmpeg_6_0"))]
51+
let nb_inputs = avfilter_pad_count((*self.as_ptr()).inputs) as isize;
52+
#[cfg(feature = "ffmpeg_6_0")]
53+
let nb_inputs = (*self.as_ptr()).nb_inputs as isize;
54+
55+
Some(PadIter::new((*self.as_ptr()).inputs, nb_inputs))
5156
}
5257
}
5358
}
@@ -59,7 +64,12 @@ impl Filter {
5964
if ptr.is_null() {
6065
None
6166
} else {
62-
Some(PadIter::new((*self.as_ptr()).outputs))
67+
#[cfg(not(feature = "ffmpeg_6_0"))]
68+
let nb_outputs = avfilter_pad_count((*self.as_ptr()).outputs) as isize;
69+
#[cfg(feature = "ffmpeg_6_0")]
70+
let nb_outputs = (*self.as_ptr()).nb_outputs as isize;
71+
72+
Some(PadIter::new((*self.as_ptr()).outputs, nb_outputs))
6373
}
6474
}
6575
}
@@ -71,15 +81,17 @@ impl Filter {
7181

7282
pub struct PadIter<'a> {
7383
ptr: *const AVFilterPad,
84+
count: isize,
7485
cur: isize,
7586

7687
_marker: PhantomData<&'a ()>,
7788
}
7889

7990
impl<'a> PadIter<'a> {
80-
pub fn new(ptr: *const AVFilterPad) -> Self {
91+
pub fn new(ptr: *const AVFilterPad, count: isize) -> Self {
8192
PadIter {
8293
ptr,
94+
count,
8395
cur: 0,
8496
_marker: PhantomData,
8597
}
@@ -91,7 +103,7 @@ impl<'a> Iterator for PadIter<'a> {
91103

92104
fn next(&mut self) -> Option<Self::Item> {
93105
unsafe {
94-
if self.cur >= avfilter_pad_count(self.ptr) as isize {
106+
if self.cur >= self.count {
95107
return None;
96108
}
97109

src/util/format/pixel.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,39 @@ pub enum Pixel {
368368
#[cfg(feature = "ffmpeg_5_0")]
369369
P416LE,
370370

371+
#[cfg(feature = "ffmpeg_6_0")]
372+
VUYA,
373+
#[cfg(feature = "ffmpeg_6_0")]
374+
RGBAF16BE,
375+
#[cfg(feature = "ffmpeg_6_0")]
376+
RGBAF16LE,
377+
#[cfg(feature = "ffmpeg_6_0")]
378+
VUYX,
379+
#[cfg(feature = "ffmpeg_6_0")]
380+
P012LE,
381+
#[cfg(feature = "ffmpeg_6_0")]
382+
P012BE,
383+
#[cfg(feature = "ffmpeg_6_0")]
384+
Y212BE,
385+
#[cfg(feature = "ffmpeg_6_0")]
386+
Y212LE,
387+
#[cfg(feature = "ffmpeg_6_0")]
388+
XV30BE,
389+
#[cfg(feature = "ffmpeg_6_0")]
390+
XV30LE,
391+
#[cfg(feature = "ffmpeg_6_0")]
392+
XV36BE,
393+
#[cfg(feature = "ffmpeg_6_0")]
394+
XV36LE,
395+
#[cfg(feature = "ffmpeg_6_0")]
396+
RGBF32BE,
397+
#[cfg(feature = "ffmpeg_6_0")]
398+
RGBF32LE,
399+
#[cfg(feature = "ffmpeg_6_0")]
400+
RGBAF32BE,
401+
#[cfg(feature = "ffmpeg_6_0")]
402+
RGBAF32LE,
403+
371404
#[cfg(feature = "rpi")]
372405
RPI,
373406
#[cfg(feature = "rpi")]
@@ -730,6 +763,39 @@ impl From<AVPixelFormat> for Pixel {
730763
#[cfg(feature = "ffmpeg_5_0")]
731764
AV_PIX_FMT_P416LE => Pixel::P416LE,
732765

766+
#[cfg(feature = "ffmpeg_6_0")]
767+
AV_PIX_FMT_VUYA => Pixel::VUYA,
768+
#[cfg(feature = "ffmpeg_6_0")]
769+
AV_PIX_FMT_RGBAF16BE => Pixel::RGBAF16BE,
770+
#[cfg(feature = "ffmpeg_6_0")]
771+
AV_PIX_FMT_RGBAF16LE => Pixel::RGBAF16LE,
772+
#[cfg(feature = "ffmpeg_6_0")]
773+
AV_PIX_FMT_VUYX => Pixel::VUYX,
774+
#[cfg(feature = "ffmpeg_6_0")]
775+
AV_PIX_FMT_P012LE => Pixel::P012LE,
776+
#[cfg(feature = "ffmpeg_6_0")]
777+
AV_PIX_FMT_P012BE => Pixel::P012BE,
778+
#[cfg(feature = "ffmpeg_6_0")]
779+
AV_PIX_FMT_Y212BE => Pixel::Y212BE,
780+
#[cfg(feature = "ffmpeg_6_0")]
781+
AV_PIX_FMT_Y212LE => Pixel::Y212LE,
782+
#[cfg(feature = "ffmpeg_6_0")]
783+
AV_PIX_FMT_XV30BE => Pixel::XV30BE,
784+
#[cfg(feature = "ffmpeg_6_0")]
785+
AV_PIX_FMT_XV30LE => Pixel::XV30LE,
786+
#[cfg(feature = "ffmpeg_6_0")]
787+
AV_PIX_FMT_XV36BE => Pixel::XV36BE,
788+
#[cfg(feature = "ffmpeg_6_0")]
789+
AV_PIX_FMT_XV36LE => Pixel::XV36LE,
790+
#[cfg(feature = "ffmpeg_6_0")]
791+
AV_PIX_FMT_RGBF32BE => Pixel::RGBF32BE,
792+
#[cfg(feature = "ffmpeg_6_0")]
793+
AV_PIX_FMT_RGBF32LE => Pixel::RGBF32LE,
794+
#[cfg(feature = "ffmpeg_6_0")]
795+
AV_PIX_FMT_RGBAF32BE => Pixel::RGBAF32BE,
796+
#[cfg(feature = "ffmpeg_6_0")]
797+
AV_PIX_FMT_RGBAF32LE => Pixel::RGBAF32LE,
798+
733799
#[cfg(feature = "rpi")]
734800
AV_PIX_FMT_RPI => Pixel::RPI,
735801
#[cfg(feature = "rpi")]
@@ -1110,6 +1176,39 @@ impl From<Pixel> for AVPixelFormat {
11101176
#[cfg(feature = "ffmpeg_5_0")]
11111177
Pixel::P416LE => AV_PIX_FMT_P416LE,
11121178

1179+
#[cfg(feature = "ffmpeg_6_0")]
1180+
Pixel::VUYA => AV_PIX_FMT_VUYA,
1181+
#[cfg(feature = "ffmpeg_6_0")]
1182+
Pixel::RGBAF16BE => AV_PIX_FMT_RGBAF16BE,
1183+
#[cfg(feature = "ffmpeg_6_0")]
1184+
Pixel::RGBAF16LE => AV_PIX_FMT_RGBAF16LE,
1185+
#[cfg(feature = "ffmpeg_6_0")]
1186+
Pixel::VUYX => AV_PIX_FMT_VUYX,
1187+
#[cfg(feature = "ffmpeg_6_0")]
1188+
Pixel::P012LE => AV_PIX_FMT_P012LE,
1189+
#[cfg(feature = "ffmpeg_6_0")]
1190+
Pixel::P012BE => AV_PIX_FMT_P012BE,
1191+
#[cfg(feature = "ffmpeg_6_0")]
1192+
Pixel::Y212BE => AV_PIX_FMT_Y212BE,
1193+
#[cfg(feature = "ffmpeg_6_0")]
1194+
Pixel::Y212LE => AV_PIX_FMT_Y212LE,
1195+
#[cfg(feature = "ffmpeg_6_0")]
1196+
Pixel::XV30BE => AV_PIX_FMT_XV30BE,
1197+
#[cfg(feature = "ffmpeg_6_0")]
1198+
Pixel::XV30LE => AV_PIX_FMT_XV30LE,
1199+
#[cfg(feature = "ffmpeg_6_0")]
1200+
Pixel::XV36BE => AV_PIX_FMT_XV36BE,
1201+
#[cfg(feature = "ffmpeg_6_0")]
1202+
Pixel::XV36LE => AV_PIX_FMT_XV36LE,
1203+
#[cfg(feature = "ffmpeg_6_0")]
1204+
Pixel::RGBF32BE => AV_PIX_FMT_RGBF32BE,
1205+
#[cfg(feature = "ffmpeg_6_0")]
1206+
Pixel::RGBF32LE => AV_PIX_FMT_RGBF32LE,
1207+
#[cfg(feature = "ffmpeg_6_0")]
1208+
Pixel::RGBAF32BE => AV_PIX_FMT_RGBAF32BE,
1209+
#[cfg(feature = "ffmpeg_6_0")]
1210+
Pixel::RGBAF32LE => AV_PIX_FMT_RGBAF32LE,
1211+
11131212
#[cfg(feature = "rpi")]
11141213
Pixel::RPI => AV_PIX_FMT_RPI,
11151214
#[cfg(feature = "rpi")]

0 commit comments

Comments
 (0)