aboutsummaryrefslogtreecommitdiffstats
path: root/alc/converter.h
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
committerSven Gothel <[email protected]>2019-12-12 19:21:00 +0100
commit4df06c6894b39af5bf4681c0acf0c1c080084c80 (patch)
tree2505eb6e3b5798db34033c4cac2d4613bf6bda44 /alc/converter.h
parent8915501ed02eac2b3bce9a7fc06cb1ab562901c3 (diff)
parentc0cf323e1d56ce605e90927324d2fdafcfbb564a (diff)
merge v1.20.0
Diffstat (limited to 'alc/converter.h')
-rw-r--r--alc/converter.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/alc/converter.h b/alc/converter.h
new file mode 100644
index 00000000..5842df07
--- /dev/null
+++ b/alc/converter.h
@@ -0,0 +1,61 @@
+#ifndef CONVERTER_H
+#define CONVERTER_H
+
+#include <cstddef>
+#include <memory>
+
+#include "AL/al.h"
+
+#include "alcmain.h"
+#include "almalloc.h"
+#include "alnumeric.h"
+#include "alu.h"
+#include "devformat.h"
+#include "voice.h"
+
+
+struct SampleConverter {
+ DevFmtType mSrcType{};
+ DevFmtType mDstType{};
+ ALuint mSrcTypeSize{};
+ ALuint mDstTypeSize{};
+
+ ALint mSrcPrepCount{};
+
+ ALuint mFracOffset{};
+ ALuint mIncrement{};
+ InterpState mState{};
+ ResamplerFunc mResample{};
+
+ alignas(16) ALfloat mSrcSamples[BUFFERSIZE]{};
+ alignas(16) ALfloat mDstSamples[BUFFERSIZE]{};
+
+ struct ChanSamples {
+ alignas(16) ALfloat PrevSamples[MAX_RESAMPLER_PADDING];
+ };
+ al::FlexArray<ChanSamples> mChan;
+
+ SampleConverter(size_t numchans) : mChan{numchans} { }
+
+ ALuint convert(const ALvoid **src, ALuint *srcframes, ALvoid *dst, ALuint dstframes);
+ ALuint availableOut(ALuint srcframes) const;
+
+ DEF_FAM_NEWDEL(SampleConverter, mChan)
+};
+using SampleConverterPtr = std::unique_ptr<SampleConverter>;
+
+SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
+ ALuint srcRate, ALuint dstRate, Resampler resampler);
+
+
+struct ChannelConverter {
+ DevFmtType mSrcType;
+ DevFmtChannels mSrcChans;
+ DevFmtChannels mDstChans;
+
+ bool is_active() const noexcept { return mSrcChans != mDstChans; }
+
+ void convert(const ALvoid *src, ALfloat *dst, ALuint frames) const;
+};
+
+#endif /* CONVERTER_H */