Remove a couple unnecessary casts
[openal-soft.git] / core / devformat.h
blobf2a372c1c4e55c907001fade2185dbdac8358da0
1 #ifndef CORE_DEVFORMAT_H
2 #define CORE_DEVFORMAT_H
4 #include <cstdint>
7 using uint = unsigned int;
9 enum Channel : unsigned char {
10 FrontLeft = 0,
11 FrontRight,
12 FrontCenter,
13 LFE,
14 BackLeft,
15 BackRight,
16 BackCenter,
17 SideLeft,
18 SideRight,
20 TopCenter,
21 TopFrontLeft,
22 TopFrontCenter,
23 TopFrontRight,
24 TopBackLeft,
25 TopBackCenter,
26 TopBackRight,
28 Aux0,
29 Aux1,
30 Aux2,
31 Aux3,
32 Aux4,
33 Aux5,
34 Aux6,
35 Aux7,
36 Aux8,
37 Aux9,
38 Aux10,
39 Aux11,
40 Aux12,
41 Aux13,
42 Aux14,
43 Aux15,
45 MaxChannels
49 /* Device formats */
50 enum DevFmtType : unsigned char {
51 DevFmtByte,
52 DevFmtUByte,
53 DevFmtShort,
54 DevFmtUShort,
55 DevFmtInt,
56 DevFmtUInt,
57 DevFmtFloat,
59 DevFmtTypeDefault = DevFmtFloat
61 enum DevFmtChannels : unsigned char {
62 DevFmtMono,
63 DevFmtStereo,
64 DevFmtQuad,
65 DevFmtX51,
66 DevFmtX61,
67 DevFmtX71,
68 DevFmtX3D71,
69 DevFmtAmbi3D,
71 DevFmtChannelsDefault = DevFmtStereo
73 #define MAX_OUTPUT_CHANNELS 16
75 /* DevFmtType traits, providing the type, etc given a DevFmtType. */
76 template<DevFmtType T>
77 struct DevFmtTypeTraits { };
79 template<>
80 struct DevFmtTypeTraits<DevFmtByte> { using Type = int8_t; };
81 template<>
82 struct DevFmtTypeTraits<DevFmtUByte> { using Type = uint8_t; };
83 template<>
84 struct DevFmtTypeTraits<DevFmtShort> { using Type = int16_t; };
85 template<>
86 struct DevFmtTypeTraits<DevFmtUShort> { using Type = uint16_t; };
87 template<>
88 struct DevFmtTypeTraits<DevFmtInt> { using Type = int32_t; };
89 template<>
90 struct DevFmtTypeTraits<DevFmtUInt> { using Type = uint32_t; };
91 template<>
92 struct DevFmtTypeTraits<DevFmtFloat> { using Type = float; };
94 template<DevFmtType T>
95 using DevFmtType_t = typename DevFmtTypeTraits<T>::Type;
98 uint BytesFromDevFmt(DevFmtType type) noexcept;
99 uint ChannelsFromDevFmt(DevFmtChannels chans, uint ambiorder) noexcept;
100 inline uint FrameSizeFromDevFmt(DevFmtChannels chans, DevFmtType type, uint ambiorder) noexcept
101 { return ChannelsFromDevFmt(chans, ambiorder) * BytesFromDevFmt(type); }
103 const char *DevFmtTypeString(DevFmtType type) noexcept;
104 const char *DevFmtChannelsString(DevFmtChannels chans) noexcept;
106 enum class DevAmbiLayout : bool {
107 FuMa,
108 ACN,
110 Default = ACN
113 enum class DevAmbiScaling : unsigned char {
114 FuMa,
115 SN3D,
116 N3D,
118 Default = SN3D
121 #endif /* CORE_DEVFORMAT_H */