-
Notifications
You must be signed in to change notification settings - Fork 3
/
rftimeblockencoder.h
84 lines (65 loc) · 2.86 KB
/
rftimeblockencoder.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef DYSCO_RFTIME_BLOCK_ENCODER_H
#define DYSCO_RFTIME_BLOCK_ENCODER_H
#include "stochasticencoder.h"
#include "timeblockbuffer.h"
#include "uvector.h"
#include <complex>
#include <random>
#include <vector>
#include "timeblockencoder.h"
class RFTimeBlockEncoder : public TimeBlockEncoder {
public:
RFTimeBlockEncoder(size_t nPol, size_t nChannels);
virtual ~RFTimeBlockEncoder() override;
virtual void EncodeWithDithering(
const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount,
std::mt19937 &rnd) final override {
encode<true>(gausEncoder, buffer, metaBuffer, symbolBuffer, antennaCount,
&rnd);
}
virtual void EncodeWithoutDithering(
const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
float *metaBuffer, symbol_t *symbolBuffer,
size_t antennaCount) final override {
encode<false>(gausEncoder, buffer, metaBuffer, symbolBuffer, antennaCount,
0);
}
virtual void InitializeDecode(const float *metaBuffer, size_t nRow,
size_t nAntennae) final override;
virtual void Decode(const dyscostman::StochasticEncoder<float> &gausEncoder,
FBuffer &buffer, const symbol_t *symbolBuffer,
size_t blockRow, size_t antenna1,
size_t antenna2) final override;
virtual size_t SymbolCount(size_t nRow, size_t nPol,
size_t nChannels) const final override {
return nRow * nChannels * nPol * 2 /*complex*/;
}
virtual size_t SymbolCount(size_t nRow) const final override {
return nRow * _nChannels * _nPol * 2 /*complex*/;
}
virtual size_t SymbolsPerRow() const final override {
return _nChannels * _nPol * 2 /*complex*/;
}
virtual size_t MetaDataCount(size_t nRow, size_t nPol, size_t nChannels,
size_t /*nAntennae*/) const final override {
return nPol * (nChannels + nRow);
}
void Normalize(const dyscostman::StochasticEncoder<float> &gausEncoder,
TimeBlockBuffer<std::complex<float>> &buffer,
size_t antennaCount);
private:
void maximizeRows(std::vector<DBufferRow> &data, float *metaBuffer,
const dyscostman::StochasticEncoder<float> &gausEncoder);
void maximizeChannels(
std::vector<DBufferRow> &data, float *metaBuffer,
const dyscostman::StochasticEncoder<float> &gausEncoder);
template <bool UseDithering>
void encode(const dyscostman::StochasticEncoder<float> &gausEncoder,
const FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer,
size_t antennaCount, std::mt19937 *rnd);
size_t _nPol, _nChannels;
ao::uvector<double> _channelFactors, _rowFactors;
std::uniform_int_distribution<unsigned> _ditherDist;
};
#endif