#[non_exhaustive]pub enum ChannelLayoutFault {
UnverifiableCustomMap {
channels: i32,
},
MalformedCustomMap {
channels: i32,
},
MalformedLayout {
order: i32,
channels: i32,
},
Alloc,
}Expand description
Why a channel layout could not be described.
Three answers, and the first two are memory-safety ones rather
than resource ones. av_channel_layout_describe walks u.map[i]
for each of nb_channels when the order is CUSTOM, and FFmpeg’s
struct puts nothing between a caller and that walk: the map is a
bare pointer and the count is a bare int. Refusing is not
politeness, it is the precondition.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnverifiableCustomMap
A CUSTOM order reached a safe conversion, which cannot
establish that the map it points at is as long as the count it
declares.
ffmpeg_next::ChannelLayout is a public newtype over a public
AVChannelLayout, so safe Rust can write nb_channels = 2 beside
a u.map that points at one entry — or at a dangling address, or
at something misaligned. Checking for null and for a terminator
inside each name does not help: neither provenance nor extent is
observable from the pointer, and the loop that would check the
names is itself the out-of-bounds read. There is no validation a
safe function can perform here, so it performs none and refuses.
The extent has to come from the caller instead, which is what
channel_layout_description_from_raw_ptr’s unsafe contract
asks for. Inside this crate the demux and convert roads satisfy it
from FFmpeg’s own AVCodecParameters and AVFrame, where
av_channel_layout_copy allocated the map and sized it — and they
argue exactly that at each call.
MalformedCustomMap
A CUSTOM order whose u.map is null, or whose channel count is
not positive, or one of whose sixteen-byte names carries no NUL.
FFmpeg would dereference the map, or read past a name, while
describing it.
MalformedLayout
A layout whose declared shape is not one FFmpeg’s own helpers
can be given, for an order other than CUSTOM.
av_channel_layout_describe and av_channel_layout_compare both
assume the invariants av_channel_layout_check states, and
nothing between a caller and those helpers enforces them: a
NATIVE layout whose nb_channels disagrees with its mask’s
population, an AMBISONIC layout whose channels do not form an
ambisonic order, and any layout declaring a count outside the
range every downstream calculation assumes. FFmpeg computes
nb_channels - popcount(mask) and takes an integer square root of
it in signed C arithmetic; a count a safe caller can simply write
into the public struct is enough to take that somewhere it was
never meant to go.
Fields
Alloc
The description could not be allocated.
Trait Implementations§
Source§impl Clone for ChannelLayoutFault
impl Clone for ChannelLayoutFault
Source§fn clone(&self) -> ChannelLayoutFault
fn clone(&self) -> ChannelLayoutFault
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ChannelLayoutFault
Source§impl Debug for ChannelLayoutFault
impl Debug for ChannelLayoutFault
Source§impl Display for ChannelLayoutFault
impl Display for ChannelLayoutFault
impl Eq for ChannelLayoutFault
Source§impl Error for ChannelLayoutFault
impl Error for ChannelLayoutFault
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()