diff options
Diffstat (limited to 'gr-fec/lib/puncture_ff_impl.cc')
-rw-r--r-- | gr-fec/lib/puncture_ff_impl.cc | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/gr-fec/lib/puncture_ff_impl.cc b/gr-fec/lib/puncture_ff_impl.cc index a534bef79f..9a7c8f6dc2 100644 --- a/gr-fec/lib/puncture_ff_impl.cc +++ b/gr-fec/lib/puncture_ff_impl.cc @@ -26,6 +26,7 @@ #include "puncture_ff_impl.h" #include <gnuradio/io_signature.h> +#include <volk/volk.h> #include <boost/bind.hpp> #include <pmt/pmt.h> #include <string> @@ -35,25 +36,39 @@ namespace gr { namespace fec { puncture_ff::sptr - puncture_ff::make(int delay, int puncpat, - int puncholes, int puncsize) + puncture_ff::make(int puncsize, int puncpat, int delay) { return gnuradio::get_initial_sptr - (new puncture_ff_impl(delay, puncpat, - puncholes, puncsize)); + (new puncture_ff_impl(puncsize, puncpat, delay)); } - puncture_ff_impl::puncture_ff_impl(int delay, int puncpat, - int puncholes, int puncsize) + puncture_ff_impl::puncture_ff_impl(int puncsize, int puncpat, int delay) : block("puncture_ff", io_signature::make(1, 1, sizeof(float)), io_signature::make(1, 1, sizeof(float))), - d_delay(delay), d_puncholes(puncholes), d_puncsize(puncsize) + d_puncsize(puncsize), d_delay(delay) { + // Create a mask of all 1's of puncsize length + int mask = 0; + for(int i = 0; i < d_puncsize; i++) + mask |= 1 << i; + + // Rotate the pattern for the delay value; then mask it if there + // are any excess 1's in the pattern. for(int i = 0; i < d_delay; ++i) { puncpat = ((puncpat & 1) << (d_puncsize - 1)) + (puncpat >> 1); } - d_puncpat = puncpat; + d_puncpat = puncpat & mask; + + // Calculate the number of holes in the pattern. The mask is all + // 1's given puncsize and puncpat is a pattern with >= puncsize + // 0's (masked to ensure this). The difference between the + // number of 1's in the mask and the puncpat is the number of + // holes. + uint32_t count_mask=0, count_pat=0; + volk_32u_popcnt(&count_mask, static_cast<uint32_t>(mask)); + volk_32u_popcnt(&count_pat, static_cast<uint32_t>(d_puncpat)); + d_puncholes = count_mask - count_pat; set_fixed_rate(true); set_relative_rate((double)(d_puncsize - d_puncholes)/d_puncsize); @@ -112,6 +127,7 @@ namespace gr { } } + /* GR_LOG_DEBUG(d_debug_logger, ">>>>>> start"); for(int i = 0, k=0; i < noutput_items; ++i) { if((d_puncpat >> (d_puncsize - 1 - (i % d_puncsize))) & 1) { @@ -127,6 +143,7 @@ namespace gr { % noutput_items % ninput_items[0]); GR_LOG_DEBUG(d_debug_logger, boost::format("consuming %1%") \ % ((int)(((1.0/relative_rate()) * noutput_items) + .5))); + */ consume_each((int)(((1.0/relative_rate()) * noutput_items) + .5)); return noutput_items; @@ -134,4 +151,3 @@ namespace gr { } /* namespace fec */ }/* namespace gr */ - |