Skip to content

Commit 28d2317

Browse files
Tweak channel_layout to reflect ffmpeg docs (#184)
* Use the av_channel_layout_compare function instead of manually comparing * Use the "empty" definition of the ffmpeg docs to preserve results wrt. previous versions
1 parent ea267ee commit 28d2317

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ffmpeg-next"
3-
version = "7.0.0"
3+
version = "7.0.1"
44
build = "build.rs"
55

66
authors = ["meh. <meh@schizofreni.co>", "Zhiming Wang <i@zhimingwang.org>"]

src/util/channel_layout.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ use ffi::*;
55
pub struct ChannelLayout(pub AVChannelLayout);
66

77
impl PartialEq for ChannelLayout {
8+
// TODO this can actually return an error if < 0
89
fn eq(&self, other: &Self) -> bool {
910
unsafe {
10-
self.0.order == other.0.order
11-
&& self.0.nb_channels == other.0.nb_channels
12-
&& self.0.u.mask == other.0.u.mask
13-
&& self.0.opaque == other.0.opaque
11+
av_channel_layout_compare(
12+
&self.0 as *const AVChannelLayout,
13+
&other.0 as *const AVChannelLayout,
14+
) == 0
1415
}
1516
}
1617
}
@@ -95,12 +96,10 @@ impl ChannelLayout {
9596
}
9697
}
9798

99+
// See https://ffmpeg.org/doxygen/trunk/group__lavu__audio__channels.html#gaa4a685b5c38835392552a7f96ee24a3e,
100+
// AV_CH_UNUSED
98101
pub fn is_empty(&self) -> bool {
99-
unsafe {
100-
self.0.order == AVChannelOrder::AV_CHANNEL_ORDER_UNSPEC
101-
&& self.0.nb_channels == 0
102-
&& self.0.u.mask == 0
103-
}
102+
self.0.order == AVChannelOrder::AV_CHANNEL_ORDER_UNSPEC
104103
}
105104
}
106105

0 commit comments

Comments
 (0)