diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2019-08-07 21:45:12 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2019-08-09 23:04:28 +0200 |
commit | f7bbf2c1d8d780294f3e016aff239ca35eb6516e (patch) | |
tree | e09ab6112e02b2215b2d59ac24d3d6ea2edac745 /gr-fec/lib/puncture_ff_impl.cc | |
parent | 78431dc6941e3acc67c858277dfe4a0ed583643c (diff) |
Tree: clang-format without the include sorting
Diffstat (limited to 'gr-fec/lib/puncture_ff_impl.cc')
-rw-r--r-- | gr-fec/lib/puncture_ff_impl.cc | 206 |
1 files changed, 99 insertions, 107 deletions
diff --git a/gr-fec/lib/puncture_ff_impl.cc b/gr-fec/lib/puncture_ff_impl.cc index abc3da541a..d4c1c05723 100644 --- a/gr-fec/lib/puncture_ff_impl.cc +++ b/gr-fec/lib/puncture_ff_impl.cc @@ -33,122 +33,114 @@ #include <stdio.h> namespace gr { - namespace fec { - - puncture_ff::sptr - puncture_ff::make(int puncsize, int puncpat, int delay) - { - return gnuradio::get_initial_sptr - (new puncture_ff_impl(puncsize, puncpat, delay)); - } - - 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_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++) +namespace fec { + +puncture_ff::sptr puncture_ff::make(int puncsize, int puncpat, int delay) +{ + return gnuradio::get_initial_sptr(new puncture_ff_impl(puncsize, puncpat, delay)); +} + +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_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 & 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((uint64_t)(d_puncsize - d_puncholes), - (uint64_t)d_puncsize); - set_output_multiple(d_puncsize - d_puncholes); - //set_msg_handler(boost::bind(&puncture_ff_impl::catch_msg, this, _1)); + // 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 & 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((uint64_t)(d_puncsize - d_puncholes), (uint64_t)d_puncsize); + set_output_multiple(d_puncsize - d_puncholes); + // set_msg_handler(boost::bind(&puncture_ff_impl::catch_msg, this, _1)); +} + +puncture_ff_impl::~puncture_ff_impl() {} + +int puncture_ff_impl::fixed_rate_ninput_to_noutput(int ninput) +{ + return (int)((((d_puncsize - d_puncholes) / (double)(d_puncsize)) * ninput) + .5); +} + +int puncture_ff_impl::fixed_rate_noutput_to_ninput(int noutput) +{ + return (int)(((d_puncsize / (double)(d_puncsize - d_puncholes)) * noutput) + .5); +} + +void puncture_ff_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) +{ + ninput_items_required[0] = + (int)(((d_puncsize / (double)(d_puncsize - d_puncholes)) * noutput_items) + .5); +} - puncture_ff_impl::~puncture_ff_impl() - { - } - - int - puncture_ff_impl::fixed_rate_ninput_to_noutput(int ninput) - { - return (int)((((d_puncsize - d_puncholes)/(double)(d_puncsize)) * ninput) + .5); - } - - int - puncture_ff_impl::fixed_rate_noutput_to_ninput(int noutput) - { - return (int)(((d_puncsize/(double)(d_puncsize-d_puncholes)) * noutput) + .5); - } - - void - puncture_ff_impl::forecast(int noutput_items, - gr_vector_int& ninput_items_required) - { - ninput_items_required[0] = (int)(((d_puncsize/(double)(d_puncsize-d_puncholes)) * noutput_items) + .5); +/* +void +puncture_ff_impl::catch_msg(pmt::pmt_t msg) +{ + long mlong = pmt::pmt_to_long(msg); + for(int i = 0; i < mlong; ++i) { + d_puncholes = (d_puncholes >> 1) | ((d_puncholes & 1) << (d_puncsize - 1)); + } +} +*/ + +int puncture_ff_impl::general_work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) +{ + const float* in = (const float*)input_items[0]; + float* out = (float*)output_items[0]; + + for (int i = 0, k = 0; i < noutput_items / output_multiple(); ++i) { + for (int j = 0; j < d_puncsize; ++j) { + if ((d_puncpat >> (d_puncsize - 1 - j)) & 1) { + out[k++] = in[i * d_puncsize + j]; + } + } } /* - void - puncture_ff_impl::catch_msg(pmt::pmt_t msg) - { - long mlong = pmt::pmt_to_long(msg); - for(int i = 0; i < mlong; ++i) { - d_puncholes = (d_puncholes >> 1) | ((d_puncholes & 1) << (d_puncsize - 1)); + 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) { + GR_LOG_DEBUG(d_debug_logger, boost::format("%1%...%2%") \ + % out[k++] % in[i]); } - } - */ - - int - puncture_ff_impl::general_work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - const float *in = (const float *)input_items[0]; - float *out = (float *)output_items[0]; - - for(int i=0, k=0; i < noutput_items/output_multiple(); ++i) { - for(int j = 0; j < d_puncsize; ++j) { - if((d_puncpat >> (d_puncsize - 1 - j)) & 1) { - out[k++] = in[i*d_puncsize + j]; - } - } - } - - /* - 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) { - GR_LOG_DEBUG(d_debug_logger, boost::format("%1%...%2%") \ - % out[k++] % in[i]); - } - else { - GR_LOG_DEBUG(d_debug_logger, boost::format("snit %1%") % in[i]); - } + else { + GR_LOG_DEBUG(d_debug_logger, boost::format("snit %1%") % in[i]); } + } - GR_LOG_DEBUG(d_debug_logger, boost::format("comp: %1%, %2%\n") \ - % noutput_items % ninput_items[0]); - GR_LOG_DEBUG(d_debug_logger, boost::format("consuming %1%") \ - % ((int)(((1.0/relative_rate()) * noutput_items) + .5))); - */ + GR_LOG_DEBUG(d_debug_logger, boost::format("comp: %1%, %2%\n") \ + % 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; - } + consume_each((int)(((1.0 / relative_rate()) * noutput_items) + .5)); + return noutput_items; +} - } /* namespace fec */ -}/* namespace gr */ +} /* namespace fec */ +} /* namespace gr */ |