1 #ifndef CORE_DEVFORMAT_H
2 #define CORE_DEVFORMAT_H
3 
4 #include <cstdint>
5 
6 
7 using uint = unsigned int;
8 
9 enum Channel : unsigned char {
10     FrontLeft = 0,
11     FrontRight,
12     FrontCenter,
13     LFE,
14     BackLeft,
15     BackRight,
16     BackCenter,
17     SideLeft,
18     SideRight,
19 
20     TopFrontLeft,
21     TopFrontCenter,
22     TopFrontRight,
23     TopCenter,
24     TopBackLeft,
25     TopBackCenter,
26     TopBackRight,
27 
28     MaxChannels
29 };
30 
31 
32 /* Device formats */
33 enum DevFmtType : unsigned char {
34     DevFmtByte,
35     DevFmtUByte,
36     DevFmtShort,
37     DevFmtUShort,
38     DevFmtInt,
39     DevFmtUInt,
40     DevFmtFloat,
41 
42     DevFmtTypeDefault = DevFmtFloat
43 };
44 enum DevFmtChannels : unsigned char {
45     DevFmtMono,
46     DevFmtStereo,
47     DevFmtQuad,
48     DevFmtX51,
49     DevFmtX61,
50     DevFmtX71,
51     DevFmtAmbi3D,
52 
53     /* Similar to 5.1, except using rear channels instead of sides */
54     DevFmtX51Rear,
55 
56     DevFmtChannelsDefault = DevFmtStereo
57 };
58 #define MAX_OUTPUT_CHANNELS  16
59 
60 /* DevFmtType traits, providing the type, etc given a DevFmtType. */
61 template<DevFmtType T>
62 struct DevFmtTypeTraits { };
63 
64 template<>
65 struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
66 template<>
67 struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
68 template<>
69 struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
70 template<>
71 struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
72 template<>
73 struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
74 template<>
75 struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
76 template<>
77 struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
78 
79 template<DevFmtType T>
80 using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
81 
82 
83 uint BytesFromDevFmt(DevFmtType type) noexcept;
84 uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
85 inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
86 { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
87 
88 const char *DevFmtTypeString(DevFmtType type) noexcept;
89 const char *DevFmtChannelsString(DevFmtChannels chans) noexcept;
90 
91 enum class DevAmbiLayout : bool {
92     FuMa,
93     ACN,
94 
95     Default = ACN
96 };
97 
98 enum class DevAmbiScaling : unsigned char {
99     FuMa,
100     SN3D,
101     N3D,
102 
103     Default = SN3D
104 };
105 
106 #endif /* CORE_DEVFORMAT_H */
107