diff options
-rw-r--r-- | gr-blocks/lib/nlog10_ff_impl.cc | 29 | ||||
-rw-r--r-- | gr-blocks/lib/nlog10_ff_impl.h | 4 |
2 files changed, 26 insertions, 7 deletions
diff --git a/gr-blocks/lib/nlog10_ff_impl.cc b/gr-blocks/lib/nlog10_ff_impl.cc index bed2da4d0d..67dafae45a 100644 --- a/gr-blocks/lib/nlog10_ff_impl.cc +++ b/gr-blocks/lib/nlog10_ff_impl.cc @@ -26,6 +26,7 @@ #include "nlog10_ff_impl.h" #include <gnuradio/io_signature.h> +#include <volk/volk.h> namespace gr { namespace blocks { @@ -39,8 +40,23 @@ namespace gr { : sync_block("nlog10_ff", io_signature::make (1, 1, sizeof(float)*vlen), io_signature::make (1, 1, sizeof(float)*vlen)), - d_n(n), d_vlen(vlen), d_k(k) + d_vlen(vlen) { + setk(k); + setn(n); + //TODO message handlers + } + + void + nlog10_ff_impl::setk(float k) + { + d_k = k; + } + + void + nlog10_ff_impl::setn(float n) + { + d_prefactor = n / log2f(10.0f); } int @@ -48,15 +64,16 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + #define novolk 0 const float *in = (const float *) input_items[0]; float *out = (float *) output_items[0]; int noi = noutput_items * d_vlen; - float n = d_n; - float k = d_k; - - for (int i = 0; i < noi; i++) - out[i] = n * log10(std::max(in[i], (float) 1e-18)) + k; + volk_32f_log2_32f(out, in, noi); + volk_32f_s32f_multiply_32f(out, out, d_prefactor, noi); + for(int i = 0; i < noi; ++i) { + out[i] += d_k; + } return noutput_items; } diff --git a/gr-blocks/lib/nlog10_ff_impl.h b/gr-blocks/lib/nlog10_ff_impl.h index dd260bea1f..21c64d42f5 100644 --- a/gr-blocks/lib/nlog10_ff_impl.h +++ b/gr-blocks/lib/nlog10_ff_impl.h @@ -30,12 +30,14 @@ namespace gr { class BLOCKS_API nlog10_ff_impl : public nlog10_ff { - float d_n; + float d_prefactor; size_t d_vlen; float d_k; public: nlog10_ff_impl(float n, size_t vlen, float k); + void setn(float n); + void setk(float k); int work(int noutput_items, gr_vector_const_void_star &input_items, |