Avoid class templates for the POPCNT64/CTZ64 macros
[openal-soft.git] / alc / buffer_storage.h
blob4a5b8b5c7875fd5d938a9985b50f07452bdde19b
1 #ifndef ALC_BUFFER_FORMATS_H
2 #define ALC_BUFFER_FORMATS_H
4 #include "AL/al.h"
5 #include "AL/alext.h"
7 #include "albyte.h"
8 #include "inprogext.h"
9 #include "vector.h"
12 /* Storable formats */
13 enum FmtType : unsigned char {
14 FmtUByte,
15 FmtShort,
16 FmtFloat,
17 FmtDouble,
18 FmtMulaw,
19 FmtAlaw,
21 enum FmtChannels : unsigned char {
22 FmtMono,
23 FmtStereo,
24 FmtRear,
25 FmtQuad,
26 FmtX51, /* (WFX order) */
27 FmtX61, /* (WFX order) */
28 FmtX71, /* (WFX order) */
29 FmtBFormat2D,
30 FmtBFormat3D,
33 enum class AmbiLayout : unsigned char {
34 FuMa = AL_FUMA_SOFT,
35 ACN = AL_ACN_SOFT,
37 enum class AmbiScaling : unsigned char {
38 FuMa = AL_FUMA_SOFT,
39 SN3D = AL_SN3D_SOFT,
40 N3D = AL_N3D_SOFT,
43 ALuint BytesFromFmt(FmtType type) noexcept;
44 ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept;
45 inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type, ALuint ambiorder) noexcept
46 { return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); }
49 struct BufferStorage {
50 al::vector<al::byte,16> mData;
52 LPALBUFFERCALLBACKTYPESOFT mCallback{nullptr};
53 void *mUserData{nullptr};
55 ALuint mSampleRate{0u};
56 FmtChannels mChannels{};
57 FmtType mType{};
58 ALuint mSampleLen{0u};
60 AmbiLayout mAmbiLayout{AmbiLayout::FuMa};
61 AmbiScaling mAmbiScaling{AmbiScaling::FuMa};
62 ALuint mAmbiOrder{0u};
64 inline ALuint bytesFromFmt() const noexcept { return BytesFromFmt(mType); }
65 inline ALuint channelsFromFmt() const noexcept
66 { return ChannelsFromFmt(mChannels, mAmbiOrder); }
67 inline ALuint frameSizeFromFmt() const noexcept { return channelsFromFmt() * bytesFromFmt(); }
69 inline bool isBFormat() const noexcept
70 { return mChannels == FmtBFormat2D || mChannels == FmtBFormat3D; }
73 #endif /* ALC_BUFFER_FORMATS_H */