From f7ab563da007de2a4ca61a1b5befe3f618abf937 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 29 Mar 2021 15:52:02 +0200 Subject: [PATCH] zita-convolver: prepare for non-power-of-two processing --- libs/zita-convolver/zita-convolver.cc | 53 +++++++++++++++++++ .../zita-convolver/zita-convolver.h | 2 + 2 files changed, 55 insertions(+) diff --git a/libs/zita-convolver/zita-convolver.cc b/libs/zita-convolver/zita-convolver.cc index 4563220ada..96a00c05d5 100644 --- a/libs/zita-convolver/zita-convolver.cc +++ b/libs/zita-convolver/zita-convolver.cc @@ -307,6 +307,29 @@ Convproc::process () return f; } +int +Convproc::tailonly (uint32_t n_samples) +{ + uint32_t k; + int f = 0; + + if (_state != ST_PROC) { + return 0; + } + + uint32_t outoffs = _outoffs; + outoffs += _quantum; + if (outoffs == _minpart) { + for (k = 0; k < _nout; k++) { + memset (_outbuff[k], 0, n_samples * sizeof (float)); + } + for (k = 0; k < _nlevels; k++) { + f |= _convlev[k]->readtail (n_samples); + } + } + return f; +} + int Convproc::stop_process (void) { @@ -810,6 +833,36 @@ Convlevel::readout () return (_wait > 1) ? _bits : 0; } +int +Convlevel::readtail (uint32_t n_samples) +{ + Outnode const* Y; + + uint32_t opind = _opind; + uint32_t outoffs = _outoffs + _outsize; + if (outoffs == _parsize) { + + while (_wait) { + _done.wait (); + _wait--; + } + + outoffs = 0; + if (++opind == 3) { + opind = 0; + } + } + + for (Y = _out_list; Y; Y = Y->_next) { + float const* const p = Y->_buff[opind] + outoffs; + float* const q = _outbuff[Y->_out]; + for (uint32_t i = 0; i < n_samples; i++) { + q[i] += p[i]; + } + } + return 0; +} + void Convlevel::print (FILE* F) { diff --git a/libs/zita-convolver/zita-convolver/zita-convolver.h b/libs/zita-convolver/zita-convolver/zita-convolver.h index 128e426e85..81fa0c8321 100644 --- a/libs/zita-convolver/zita-convolver/zita-convolver.h +++ b/libs/zita-convolver/zita-convolver/zita-convolver.h @@ -272,6 +272,7 @@ private: void process (); int readout (); + int readtail (uint32_t n_samples); void stop (void); @@ -392,6 +393,7 @@ public: int start_process (int abspri, int policy); int process (); + int tailonly (uint32_t n_samples); int stop_process (void);