GNU Radio's SATNOGS Package
egolay_encoder.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4 *
5 * Copyright (C) 2022, 2024 Libre Space Foundation <http://libre.space/>
6 *
7 * This program 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 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef EGOLAY_ENCODER_H
22#define EGOLAY_ENCODER_H
23
24#include <gnuradio/fec/encoder.h>
26#include <itpp/comm/egolay.h>
27
28namespace gr {
29namespace satnogs {
30namespace code {
31
32class SATNOGS_API egolay_encoder : virtual public fec::generic_encoder
33{
34public:
35 static fec::generic_encoder::sptr make(bool packed = false);
36
37 egolay_encoder(bool packed = false);
38
39 double rate() override;
40
41 /*!
42 * Returns the input size in items that the encoder object uses
43 * to encode a full frame. Often, this number is the number of
44 * bits per frame if the input format is unpacked. If the block
45 * expects packed bytes, then this value should be the number of
46 * bytes (number of bits / 8) per input frame.
47 *
48 * The child class MUST implement this function.
49 */
50 int get_input_size() override;
51
52 /*!
53 * Returns the output size in items that the encoder object
54 * produces after encoding a full frame. Often, this number is
55 * the number of bits in the outputted frame if the input format
56 * is unpacked. If the block produces packed bytes, then this
57 * value should be the number of bytes (number of bits / 8) per
58 * frame produced. This value is generally something like
59 * R*get_input_size() for a 1/R rate code.
60 *
61 * The child class MUST implement this function.
62 */
63 int get_output_size() override;
64
65 /*!
66 * Set up a conversion type required to setup the data properly
67 * for this encoder. The encoder itself will not implement the
68 * conversion and expects an external wrapper (e.g.,
69 * fec.extended_encoder) to read this value and "do the right
70 * thing" to format the data.
71 *
72 * The default behavior is 'none', which means no conversion is
73 * required. Whatever the get_input_item_size() value returns,
74 * the input is expected to conform directly to this. Generally,
75 * this means unpacked bytes.
76 *
77 * If 'pack', the block expects the inputs to be packed
78 * bytes. The wrapper should implement a
79 * gr::blocks::pack_k_bits_bb(8) block for this.
80 *
81 * The child class MAY implement this function. If not
82 * reimplemented, it returns "none".
83 */
84 const char* get_input_conversion() override;
85
86 /*!
87 * Set up a conversion type required to understand the output
88 * style of this encoder. Generally an encoder will produce
89 * unpacked bytes with a bit set in the LSB.
90 *
91 * The default behavior is 'none', which means no conversion is
92 * required and the encoder produces unpacked bytes.
93 *
94 * If 'packed_bits', the block produces packed bits and the
95 * wrapper should unpack these (using, for instance,
96 * gr::block::unpack_k_bits_bb(8)).
97 *
98 * The child class MAY implement this function. If not
99 * reimplemented, it returns "none".
100 */
101 const char* get_output_conversion() override;
102
103 /*!
104 * Updates the size of the frame to encode.
105 *
106 * The child class MUST implement this function and interpret
107 * how the \p frame_size information affects the block's
108 * behavior. It should also provide bounds checks.
109 */
110 bool set_frame_size(unsigned int frame_size) override;
111
112 void generic_work(void* inbuffer, void* outbuffer) override;
113
114private:
115 const bool m_packed;
116 size_t m_frame_len;
117
118 void to_bvec(itpp::bvec& out, const uint8_t* in);
119 void from_bvec(uint8_t* out, const itpp::bvec& in);
120};
121
122
123} // namespace code
124} // namespace satnogs
125} // namespace gr
126
127#endif // EGOLAY_ENCODER_H
#define SATNOGS_API
Definition: api.h:19
Definition: egolay_encoder.h:33
egolay_encoder(bool packed=false)
void generic_work(void *inbuffer, void *outbuffer) override
bool set_frame_size(unsigned int frame_size) override
const char * get_input_conversion() override
const char * get_output_conversion() override
static fec::generic_encoder::sptr make(bool packed=false)
Definition: amsat_duv_decoder.h:29