diff options
author | Tom Tsou <tom.tsou@ettus.com> | 2015-08-21 19:32:58 -0700 |
---|---|---|
committer | Tom Tsou <tom.tsou@ettus.com> | 2016-07-01 03:03:11 -0700 |
commit | 28670fb5dad8e48ff74051a5bbe0c8309b04c817 (patch) | |
tree | f93d11d8a26701cdecceebdf40b9fac006c8af03 /Transceiver52M/Resampler.cpp | |
parent | 05c6feb71dd2f66b74c9e1671d91570485479836 (diff) |
iface: Add inner ring-buffer implementation
Two buffers, inner and outer, are used in the transceiver
implementation. The outer buffer interfaces with the device receive
interface to guarantee timestamp aligned and contiguously allocated
sample buffers. The inner buffer absorbs vector size differences between
GSM bursts (156 or 157 samples) and the resampler interface (typically
fixed multiples of 65).
Reimplement the inner buffer with a ring buffer that allows fixed size
segments on the outer (resampler) portion and variable lengths (GSM
side) on the inner side. Compared to the previous stack-like version,
this implementation removes unnecessary copying of buffer contents.
Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
Diffstat (limited to 'Transceiver52M/Resampler.cpp')
-rw-r--r-- | Transceiver52M/Resampler.cpp | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/Transceiver52M/Resampler.cpp b/Transceiver52M/Resampler.cpp index e4b66a7..070adda 100644 --- a/Transceiver52M/Resampler.cpp +++ b/Transceiver52M/Resampler.cpp @@ -167,22 +167,13 @@ void Resampler::computePath() } } -int Resampler::rotate(float *in, size_t in_len, float *out, size_t out_len) +int Resampler::rotate(const float *in, size_t in_len, float *out, size_t out_len) { int n, path; - int hist_len = filt_len - 1; if (!check_vec_len(in_len, out_len, p, q)) return -1; - if (history_on) { - memcpy(&in[-2 * hist_len], - history, hist_len * 2 * sizeof(float)); - } else { - memset(&in[-2 * hist_len], 0, - hist_len * 2 * sizeof(float)); - } - /* Generate output from precomputed input/output paths */ for (size_t i = 0; i < out_len; i++) { n = in_index[i]; @@ -194,27 +185,15 @@ int Resampler::rotate(float *in, size_t in_len, float *out, size_t out_len) n, 1, 1, 0); } - /* Save history */ - if (history_on) { - memcpy(history, &in[2 * (in_len - hist_len)], - hist_len * 2 * sizeof(float)); - } - return out_len; } bool Resampler::init(float bw) { - size_t hist_len = filt_len - 1; - /* Filterbank filter internals */ if (initFilters(bw) < 0) return false; - /* History buffer */ - history = new float[2 * hist_len]; - memset(history, 0, 2 * hist_len * sizeof(float)); - /* Precompute filterbank paths */ in_index = new size_t[MAX_OUTPUT_LEN]; out_path = new size_t[MAX_OUTPUT_LEN]; @@ -228,14 +207,8 @@ size_t Resampler::len() return filt_len; } -void Resampler::enableHistory(bool on) -{ - history_on = on; -} - Resampler::Resampler(size_t p, size_t q, size_t filt_len) - : in_index(NULL), out_path(NULL), partitions(NULL), - history(NULL), history_on(true) + : in_index(NULL), out_path(NULL), partitions(NULL) { this->p = p; this->q = q; @@ -246,7 +219,6 @@ Resampler::~Resampler() { releaseFilters(); - delete history; delete in_index; delete out_path; } |