scuffle_ffmpeg/enums/av_channel_order.rs
1use nutype_enum::nutype_enum;
2
3use crate::ffi::*;
4
5const _: () = {
6 assert!(std::mem::size_of::<AVChannelOrder>() == std::mem::size_of_val(&AV_CHANNEL_ORDER_UNSPEC));
7};
8
9nutype_enum! {
10 /// Audio channel ordering schemes used in FFmpeg's `AVChannelOrder`.
11 ///
12 /// This enum defines how channels are arranged in an audio stream, determining
13 /// their order and mapping.
14 ///
15 /// See the official FFmpeg documentation:
16 /// <https://ffmpeg.org/doxygen/trunk/channel__layout_8h.html>
17 pub enum AVChannelOrder(u32) {
18 /// Only the **channel count** is specified, without any further information
19 /// about the **channel order**.
20 /// - **Used for**: Unspecified channel layouts.
21 /// - **Equivalent to**: `AV_CHANNEL_ORDER_UNSPEC`
22 Unspecified = AV_CHANNEL_ORDER_UNSPEC as _,
23
24 /// Channels are in the **native order** defined in `AVChannel` (up to 63 channels).
25 /// - **Used for**: Standard layouts where channels are ordered as per the `AVChannel` enum.
26 /// - **Equivalent to**: `AV_CHANNEL_ORDER_NATIVE`
27 Native = AV_CHANNEL_ORDER_NATIVE as _,
28
29 /// The channel order does not correspond to any predefined order and is stored
30 /// as an **explicit map**.
31 /// - **Used for**:
32 /// - Layouts with **64 or more channels**.
33 /// - Layouts with **empty/skipped** (`AV_CHAN_UNUSED`) channels at arbitrary positions.
34 /// - **Example**: Custom surround sound layouts.
35 /// - **Equivalent to**: `AV_CHANNEL_ORDER_CUSTOM`
36 Custom = AV_CHANNEL_ORDER_CUSTOM as _,
37
38 /// **Ambisonic channel order**, where each channel represents a **spherical harmonic**
39 /// expansion component.
40 ///
41 /// **Channel arrangement (ACN - Ambisonic Channel Number)**:
42 /// - Channel index **n** is mapped to spherical harmonic degree **l** and order **m**:
43 /// - `l = floor(sqrt(n))`
44 /// - `m = n - l * (l + 1)`
45 /// - Conversely, given degree **l** and order **m**, the channel index is:
46 /// - `n = l * (l + 1) + m`
47 ///
48 /// **Normalization**: SN3D (Schmidt Semi-Normalization) as defined in **AmbiX format ยง2.1**.
49 ///
50 /// - **Used for**: **Ambisonic (3D spatial audio)** representations.
51 /// - **Equivalent to**: `AV_CHANNEL_ORDER_AMBISONIC`
52 Ambisonic = AV_CHANNEL_ORDER_AMBISONIC as _,
53
54 /// **Number of channel orders** (internal use only).
55 /// - **DO NOT USE** in applications.
56 /// - **Equivalent to**: `FF_CHANNEL_ORDER_NB`
57 Nb = FF_CHANNEL_ORDER_NB as _,
58 }
59}
60
61impl PartialEq<u32> for AVChannelOrder {
62 fn eq(&self, other: &u32) -> bool {
63 self.0 == *other
64 }
65}
66
67impl From<AVChannelOrder> for i32 {
68 fn from(value: AVChannelOrder) -> Self {
69 value.0 as i32
70 }
71}
72
73impl From<i32> for AVChannelOrder {
74 fn from(value: i32) -> Self {
75 AVChannelOrder(value as u32)
76 }
77}