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