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