diff options
author | Chris Robinson <[email protected]> | 2020-08-24 17:59:07 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-24 17:59:07 -0700 |
commit | 9d61484e4bc0b2691b714d758391b3c3ecfd7890 (patch) | |
tree | e122607532bbbd692dccf01fa6da55e928da54bf | |
parent | 73ab9d46c88f034a32a6fb174e98fd23dec1ff98 (diff) |
Move storable buffer format info to a separate source
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | al/buffer.cpp | 31 | ||||
-rw-r--r-- | al/buffer.h | 59 | ||||
-rw-r--r-- | alc/buffer_formats.cpp | 37 | ||||
-rw-r--r-- | alc/buffer_formats.h | 33 |
5 files changed, 89 insertions, 73 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ab81e4f..803f34de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -617,6 +617,8 @@ set(ALC_OBJS alc/bsinc_tables.cpp alc/bsinc_tables.h alc/bufferline.h + alc/buffer_formats.cpp + alc/buffer_formats.h alc/compat.h alc/converter.cpp alc/converter.h diff --git a/al/buffer.cpp b/al/buffer.cpp index af1ad638..b795964a 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -1577,37 +1577,6 @@ START_API_FUNC END_API_FUNC -ALuint BytesFromFmt(FmtType type) noexcept -{ - switch(type) - { - case FmtUByte: return sizeof(uint8_t); - case FmtShort: return sizeof(int16_t); - case FmtFloat: return sizeof(float); - case FmtDouble: return sizeof(double); - case FmtMulaw: return sizeof(uint8_t); - case FmtAlaw: return sizeof(uint8_t); - } - return 0; -} -ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept -{ - switch(chans) - { - case FmtMono: return 1; - case FmtStereo: return 2; - case FmtRear: return 2; - case FmtQuad: return 4; - case FmtX51: return 6; - case FmtX61: return 7; - case FmtX71: return 8; - case FmtBFormat2D: return (ambiorder*2) + 1; - case FmtBFormat3D: return (ambiorder+1) * (ambiorder+1); - } - return 0; -} - - BufferSubList::~BufferSubList() { uint64_t usemask{~FreeMask}; diff --git a/al/buffer.h b/al/buffer.h index 2e98e927..ab4fa333 100644 --- a/al/buffer.h +++ b/al/buffer.h @@ -8,60 +8,35 @@ #include "albyte.h" #include "almalloc.h" #include "atomic.h" +#include "buffer_formats.h" #include "inprogext.h" #include "vector.h" /* User formats */ enum UserFmtType : unsigned char { - UserFmtUByte, - UserFmtShort, - UserFmtFloat, - UserFmtDouble, - UserFmtMulaw, - UserFmtAlaw, + UserFmtUByte = FmtUByte, + UserFmtShort = FmtShort, + UserFmtFloat = FmtFloat, + UserFmtMulaw = FmtMulaw, + UserFmtAlaw = FmtAlaw, + + UserFmtDouble = 128, UserFmtIMA4, UserFmtMSADPCM, }; enum UserFmtChannels : unsigned char { - UserFmtMono, - UserFmtStereo, - UserFmtRear, - UserFmtQuad, - UserFmtX51, /* (WFX order) */ - UserFmtX61, /* (WFX order) */ - UserFmtX71, /* (WFX order) */ - UserFmtBFormat2D, - UserFmtBFormat3D, -}; - - -/* Storable formats */ -enum FmtType : unsigned char { - FmtUByte = UserFmtUByte, - FmtShort = UserFmtShort, - FmtFloat = UserFmtFloat, - FmtDouble = UserFmtDouble, - FmtMulaw = UserFmtMulaw, - FmtAlaw = UserFmtAlaw, -}; -enum FmtChannels : unsigned char { - FmtMono = UserFmtMono, - FmtStereo = UserFmtStereo, - FmtRear = UserFmtRear, - FmtQuad = UserFmtQuad, - FmtX51 = UserFmtX51, - FmtX61 = UserFmtX61, - FmtX71 = UserFmtX71, - FmtBFormat2D = UserFmtBFormat2D, - FmtBFormat3D = UserFmtBFormat3D, + UserFmtMono = FmtMono, + UserFmtStereo = FmtStereo, + UserFmtRear = FmtRear, + UserFmtQuad = FmtQuad, + UserFmtX51 = FmtX51, + UserFmtX61 = FmtX61, + UserFmtX71 = FmtX71, + UserFmtBFormat2D = FmtBFormat2D, + UserFmtBFormat3D = FmtBFormat3D, }; -ALuint BytesFromFmt(FmtType type) noexcept; -ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept; -inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type, ALuint ambiorder) noexcept -{ return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); } - struct ALbuffer { al::vector<al::byte,16> mData; diff --git a/alc/buffer_formats.cpp b/alc/buffer_formats.cpp new file mode 100644 index 00000000..7ee4bfc8 --- /dev/null +++ b/alc/buffer_formats.cpp @@ -0,0 +1,37 @@ + +#include "config.h" + +#include "buffer_formats.h" + +#include <cstdint> + + +ALuint BytesFromFmt(FmtType type) noexcept +{ + switch(type) + { + case FmtUByte: return sizeof(uint8_t); + case FmtShort: return sizeof(int16_t); + case FmtFloat: return sizeof(float); + case FmtDouble: return sizeof(double); + case FmtMulaw: return sizeof(uint8_t); + case FmtAlaw: return sizeof(uint8_t); + } + return 0; +} +ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept +{ + switch(chans) + { + case FmtMono: return 1; + case FmtStereo: return 2; + case FmtRear: return 2; + case FmtQuad: return 4; + case FmtX51: return 6; + case FmtX61: return 7; + case FmtX71: return 8; + case FmtBFormat2D: return (ambiorder*2) + 1; + case FmtBFormat3D: return (ambiorder+1) * (ambiorder+1); + } + return 0; +} diff --git a/alc/buffer_formats.h b/alc/buffer_formats.h new file mode 100644 index 00000000..b10cea4c --- /dev/null +++ b/alc/buffer_formats.h @@ -0,0 +1,33 @@ +#ifndef ALC_BUFFER_FORMATS_H +#define ALC_BUFFER_FORMATS_H + +#include "AL/al.h" + + +/* Storable formats */ +enum FmtType : unsigned char { + FmtUByte, + FmtShort, + FmtFloat, + FmtDouble, + FmtMulaw, + FmtAlaw, +}; +enum FmtChannels : unsigned char { + FmtMono, + FmtStereo, + FmtRear, + FmtQuad, + FmtX51, /* (WFX order) */ + FmtX61, /* (WFX order) */ + FmtX71, /* (WFX order) */ + FmtBFormat2D, + FmtBFormat3D, +}; + +ALuint BytesFromFmt(FmtType type) noexcept; +ALuint ChannelsFromFmt(FmtChannels chans, ALuint ambiorder) noexcept; +inline ALuint FrameSizeFromFmt(FmtChannels chans, FmtType type, ALuint ambiorder) noexcept +{ return ChannelsFromFmt(chans, ambiorder) * BytesFromFmt(type); } + +#endif /* ALC_BUFFER_FORMATS_H */ |