aboutsummaryrefslogtreecommitdiffstats
path: root/lib/resample_s16func.cpp
diff options
context:
space:
mode:
authorMarkus Mittendrein <maxmitti@maxmitti.tk>2022-11-28 20:16:46 +0100
committerMarkus Mittendrein <maxmitti@maxmitti.tk>2022-11-28 20:16:46 +0100
commit4cb83acddbe154312b74d2d63985ac1100bad7c5 (patch)
treed49dc904acc9af57acca8864fb6a40e340accacc /lib/resample_s16func.cpp
downloadfresample-master.tar.gz
fresample-master.zip
InitialHEADmaster
Diffstat (limited to 'lib/resample_s16func.cpp')
-rw-r--r--lib/resample_s16func.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/resample_s16func.cpp b/lib/resample_s16func.cpp
new file mode 100644
index 0000000..07c086e
--- /dev/null
+++ b/lib/resample_s16func.cpp
@@ -0,0 +1,51 @@
+/* Copyright 2012 Dietrich Epp <depp@zdome.net> */
+#include "defs.h"
+#include "filter.h"
+#include "resample.h"
+#include "resample_func.h"
+
+namespace {
+ template<auto func>
+ void helper(lfr_fixed_t* pos, lfr_fixed_t inv_ratio, unsigned* dither, void* out, int outlen, const void* in, int inlen, const lfr_filter* filter)
+ {
+ return func(*pos, inv_ratio, *dither, out, outlen, in, inlen, *filter);
+ }
+}
+
+lfr_resample_func_t
+lfr_resample_s16func(int nchan, const struct lfr_filter *filter)
+{
+ const auto ftype = filter->type;
+ switch (nchan) {
+ case 1:
+ switch (ftype) {
+ case LFR_FTYPE_S16:
+ return helper<lfr_resample<short, short, short, int, 1, 14>>;
+
+ case LFR_FTYPE_F32:
+ return helper<lfr_resample<short, short, short, int, 1, 14>>;
+
+ default:
+ break;
+ }
+ break;
+
+ case 2:
+ switch (ftype) {
+ case LFR_FTYPE_S16:
+ return helper<lfr_resample<short, short, short, int, 2, 14>>;
+
+ case LFR_FTYPE_F32:
+ return helper<lfr_resample<short, short, float, float, 2, 14>>;
+
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return NULL;
+}