aboutsummaryrefslogtreecommitdiffstats
path: root/lib/resample_s16func.cpp
blob: 07c086ea8a11228791b47da219733f88deb83e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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;
}