blob: cbb842fb4cf8b686666ba149174a1c4b81c8f953 (
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)
: Buf(N/2)
, TMDCTBase(N, scale)
{}
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)
: Buf(N)
, TMDCTBase(N, scale)
{}
const std::vector<double>& operator()(double* in) {
midct(&Ctx, &Buf[0], in);
return Buf;
}
};
} //namespace NMDCT
|