diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2015-12-07 16:15:31 -0800 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-12-07 16:15:31 -0800 |
commit | 422271f1e025bd1835e4a7ee68e2a60e23167b45 (patch) | |
tree | f49812df4a01de3d40af40e80ee9b6d62db6064c /gr-fec/lib/polar_encoder_systematic.cc | |
parent | a96c1dd97ecb6ca9a40522d297df27bbdeca5d7f (diff) | |
parent | 9ac7203fffb37fd456b82b737a71d4c7a1607b06 (diff) |
Merge remote-tracking branch 'jdemel/polar-systematic'
Diffstat (limited to 'gr-fec/lib/polar_encoder_systematic.cc')
-rw-r--r-- | gr-fec/lib/polar_encoder_systematic.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gr-fec/lib/polar_encoder_systematic.cc b/gr-fec/lib/polar_encoder_systematic.cc new file mode 100644 index 0000000000..80bfa1ca0c --- /dev/null +++ b/gr-fec/lib/polar_encoder_systematic.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2015 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gnuradio/io_signature.h> +#include <gnuradio/fec/polar_encoder_systematic.h> +#include <volk/volk.h> + +namespace gr { + namespace fec { + namespace code { + + generic_encoder::sptr + polar_encoder_systematic::make(int block_size, int num_info_bits, + std::vector<int> frozen_bit_positions) + { + return generic_encoder::sptr( + new polar_encoder_systematic(block_size, num_info_bits, frozen_bit_positions)); + } + + polar_encoder_systematic::polar_encoder_systematic(int block_size, int num_info_bits, + std::vector<int> frozen_bit_positions) : + polar_common(block_size, num_info_bits, frozen_bit_positions, std::vector<char>()) + { + d_volk_syst_intermediate = (unsigned char*) volk_malloc(sizeof(unsigned char) * block_size, volk_get_alignment()); + } + + polar_encoder_systematic::~polar_encoder_systematic() + { + volk_free(d_volk_syst_intermediate); + } + + void + polar_encoder_systematic::generic_work(void* in_buffer, void* out_buffer) + { + const unsigned char *in = (const unsigned char*) in_buffer; + unsigned char *out = (unsigned char*) out_buffer; + + volk_encode(out, in); + bit_reverse_and_reset_frozen_bits(d_volk_syst_intermediate, out); + volk_encode_block(out, d_volk_syst_intermediate); + } + + void + polar_encoder_systematic::bit_reverse_and_reset_frozen_bits(unsigned char* outbuf, + const unsigned char* inbuf) + { + memset(outbuf, 0, sizeof(unsigned char) * block_size()); + for(int i = 0; i < num_info_bits(); i++){ + outbuf[d_info_bit_positions[i]] = inbuf[d_info_bit_positions_reversed[i]]; + } + } + + } /* namespace code */ + } /* namespace fec */ +} /* namespace gr */ + |