Skip to main content

ChannelLayoutFault

Enum ChannelLayoutFault 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§channels: i32

nb_channels, as the layout declared it.

§

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.

Fields

§channels: i32

nb_channels, as the layout declared 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

§order: i32

order, as the raw c_int it is on the wire.

§channels: i32

nb_channels, as the layout declared it.

§

Alloc

The description could not be allocated.

Trait Implementations§

Source§

impl Clone for ChannelLayoutFault

Source§

fn clone(&self) -> ChannelLayoutFault

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ChannelLayoutFault

Source§

impl Debug for ChannelLayoutFault

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ChannelLayoutFault

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ChannelLayoutFault

Source§

impl Error for ChannelLayoutFault

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ChannelLayoutFault

Source§

fn eq(&self, other: &ChannelLayoutFault) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ChannelLayoutFault

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more