aboutsummaryrefslogtreecommitdiffstats
path: root/src/mdct/mdct.h
blob: ced049c479dc08bf8b4e5a85c17c55f0f06a6e7e (plain) (blame)
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
#pragma once

#include "vorbis_impl/mdct.h"
#include <vector>

namespace NMDCT {

class TMDCTBase {
protected:
    MDCTContext Ctx;
    TMDCTBase(int n, double scale) {
        mdct_ctx_init(&Ctx, n, scale);
    };
    virtual ~TMDCTBase() {
        mdct_ctx_close(&Ctx);
    };
};


template<int N>
class TMDCT : public TMDCTBase {
    std::vector<double> Buf;
public:
    TMDCT(float scale = 1.0)
        : TMDCTBase(N, scale)
        , Buf(N/2)
    {}
    const std::vector<double>& operator()(double* in) {
        mdct(&Ctx, &Buf[0], in);
        return Buf;
    }
};

template<int N>
class TMIDCT : public TMDCTBase {
    std::vector<double> Buf;
public:
    TMIDCT(float scale = 1.0)
        : TMDCTBase(N, scale)
        , Buf(N)
    {}
    const std::vector<double>& operator()(double* in) {
        midct(&Ctx, &Buf[0], in);
        return Buf;
    }
};
} //namespace NMDCT