GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
polar_encoder.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 
24 #ifndef INCLUDED_FEC_POLAR_ENCODER_H
25 #define INCLUDED_FEC_POLAR_ENCODER_H
26 
27 #include <gnuradio/fec/api.h>
30 
31 namespace gr {
32  namespace fec {
33  namespace code {
34 
35  /*!
36  * \brief POLAR encoder
37  * for basic details see 'polar_common' class.
38  * \ingroup error_coding_blk
39  *
40  * \details
41  * expects values with MSB first. It needs a full information word and encodes it in one pass.
42  * Output is a codeword of block_size.
43  */
45  {
46  public:
47  /*!
48  * Factory for a polar code encoder object.
49  *
50  * \param block_size defines the codeword size. It MUST be a
51  * power of 2.
52  * \param num_info_bits represents the number of information
53  * bits in a block. Also called frame_size.
54  * \param frozen_bit_positions is an integer vector which
55  * defines the position of all frozen bits in a block.
56  * Its size MUST be equal to block_size - num_info_bits.
57  * Also it must be sorted and every position must only
58  * occur once.
59  * \param frozen_bit_values holds an unpacked byte for every
60  * frozen bit position. It defines if a frozen bit is
61  * fixed to '0' or '1'. Defaults to all ZERO.
62  * \param is_packed choose 1 active bit/byte or 8 active
63  * bit/byte. if false, VOLK polar encoder is used.
64  */
65  static generic_encoder::sptr make(int block_size, int num_info_bits,
66  std::vector<int> frozen_bit_positions,
67  std::vector<char> frozen_bit_values,
68  bool is_packed = false);
69  ~polar_encoder();
70 
71  // FECAPI
72  void generic_work(void *in_buffer, void *out_buffer);
73  double rate(){return (1.0 * get_input_size() / get_output_size());};
74  int get_input_size(){return num_info_bits() / (d_is_packed ? 8 : 1);};
75  int get_output_size(){return block_size() / (d_is_packed ? 8 : 1);};
76  bool set_frame_size(unsigned int frame_size){return false;};
77  const char* get_input_conversion(){return d_is_packed ? "pack" : "none";};
78  const char* get_output_conversion(){return d_is_packed ? "packed_bits" : "none";};
79 
80  private:
81  polar_encoder(int block_size, int num_info_bits,
82  std::vector<int>& frozen_bit_positions,
83  std::vector<char>& frozen_bit_values, bool is_packed);
84  bool d_is_packed;
85 
86  // c'tor method for packed algorithm setup.
87  void setup_frozen_bit_inserter();
88 
89  // methods insert input bits and frozen bits into packed array for encoding
90  unsigned char* d_frozen_bit_prototype; // packed frozen bits are written onto it and later copies are used.
91  void insert_packed_frozen_bits_and_reverse(unsigned char* target,
92  const unsigned char* input) const;
93  void insert_unpacked_bit_into_packed_array_at_position(unsigned char* target,
94  const unsigned char bit,
95  const int pos) const;
96  void insert_packet_bit_into_packed_array_at_position(unsigned char* target,
97  const unsigned char bit,
98  const int target_pos,
99  const int bit_pos) const;
100 
101  // packed encoding methods
102  void encode_vector_packed(unsigned char* target) const;
103  void encode_vector_packed_subbyte(unsigned char* target) const;
104  void encode_packed_byte(unsigned char* target) const;
105  void encode_vector_packed_interbyte(unsigned char* target) const;
106  };
107 
108  } // namespace code
109  } // namespace fec
110 } // namespace gr
111 
112 #endif /* INCLUDED_FEC_POLAR_ENCODER_H */
double rate()
Definition: polar_encoder.h:73
const char * get_input_conversion()
Definition: polar_encoder.h:77
int get_input_size()
Definition: polar_encoder.h:74
Include this header to use the message passing features.
Definition: logger.h:131
bool set_frame_size(unsigned int frame_size)
Definition: polar_encoder.h:76
Definition: generic_encoder.h:34
boost::shared_ptr< generic_encoder > sptr
Definition: generic_encoder.h:49
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
POLAR encoder for basic details see 'polar_common' class.
Definition: polar_encoder.h:44
const char * get_output_conversion()
Definition: polar_encoder.h:78
POLAR code common operations and attributes.
Definition: polar_common.h:55
int get_output_size()
Definition: polar_encoder.h:75