GNU Radio's SATNOGS Package
egolay_decoder.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_DECODER_H
22#define EGOLAY_DECODER_H
23
24#include <gnuradio/fec/decoder.h>
27#include <itpp/comm/egolay.h>
28
29namespace gr {
30namespace satnogs {
31namespace code {
32
33class SATNOGS_API egolay_decoder : virtual public fec::generic_decoder
34{
35public:
36 static fec::generic_decoder::sptr make(bool packed = false);
37
38 egolay_decoder(bool packed = false);
39
40 void generic_work(fec_input_buffer_type inbuffer, void* outbuffer) override;
41
42 /*!
43 * Returns the rate of the code. For every r input bits, there
44 * is 1 output bit, so the rate is 1/r. Used for setting things
45 * like the encoder block's relative rate.
46 *
47 * This function MUST be reimplemented by the child class.
48 */
49 double rate() override;
50
51 /*!
52 * Returns the input size in items that the decoder object uses
53 * to decode a full frame. Often, this number is the number of
54 * bits per frame if the input format is unpacked. If the block
55 * expects packed bytes, then this value should be the number of
56 * bytes (number of bits / 8) per input frame.
57 *
58 * The child class MUST implement this function.
59 */
60 int get_input_size() override;
61
62 /*!
63 * Returns the output size in items that the decoder object
64 * produces after decoding a full frame. Often, this number is
65 * the number of bits in the outputted frame if the input format
66 * is unpacked. If the block produces packed bytes, then this
67 * value should be the number of bytes (number of bits / 8) per
68 * frame produced. This value is generally something like
69 * get_input_size()/R for a 1/R rate code.
70 *
71 * The child class MUST implement this function.
72 */
73 int get_output_size() override;
74
75 /*!
76 * Sets the size of an input item, as in the size of a char or
77 * float item.
78 *
79 * The child class SHOULD implement this function. If not
80 * reimplemented, it returns sizeof(float) as the decoders
81 * typically expect floating point input types.
82 */
83 int get_input_item_size() override;
84
85 /*!
86 * Sets the size of an output item, as in the size of a char or
87 * float item.
88 *
89 * The child class SHOULD implement this function. If not
90 * reimplemented, it returns sizeof(char) as the decoders
91 * typically expect to produce bits or bytes.
92 */
93 int get_output_item_size() override;
94
95 /*!
96 * Set up a conversion type required to setup the data properly
97 * for this decoder. The decoder itself will not implement the
98 * conversion and expects an external wrapper (e.g.,
99 * fec.extended_decoder) to read this value and "do the right
100 * thing" to format the data.
101 *
102 * The default behavior is 'none', which means no conversion is
103 * required. Whatever the get_input_item_size() value returns,
104 * the input is expected to conform directly to this.
105 *
106 * This may also return 'uchar', which indicates that the
107 * wrapper should convert the standard float samples to unsigned
108 * characters, either hard sliced or 8-bit soft symbols. See
109 * gr::fec::code::cc_decoder as an example decoder that uses
110 * this conversion format.
111 *
112 * If 'packed_bits', the block expects the inputs to be packed
113 * hard bits. Each input item is a unsigned char where each of
114 * the 8-bits is a hard bit value.
115 *
116 * The child class SHOULD implement this function. If not
117 * reimplemented, it returns "none".
118 */
119 const char* get_input_conversion() override;
120
121 /*!
122 * Set up a conversion type required to understand the output
123 * style of this decoder. Generally, follow-on processing
124 * expects unpacked bits, so we specify the conversion type here
125 * to indicate what the wrapper (e.g., fec.extended_decoder)
126 * should do to convert the output samples from the decoder into
127 * unpacked bits.
128 *
129 * The default behavior is 'none', which means no conversion is
130 * required. This should mean that the output data is produced
131 * from this decoder as unpacked bit.
132 *
133 * If 'unpack', the block produces packed bytes that should be
134 * unpacked by the wrapper. See gr::fec::code::ccsds_decoder as
135 * an example of a decoder that produces packed bytes.
136 *
137 * The child class SHOULD implement this function. If not
138 * reimplemented, it returns "none".
139 */
140 const char* get_output_conversion() override;
141
142 /*!
143 * Updates the size of a decoded frame.
144 *
145 * The child class MUST implement this function and interpret
146 * how the \p frame_size information affects the block's
147 * behavior. It should also provide bounds checks.
148 */
149 bool set_frame_size(unsigned int frame_size) override;
150
151private:
152 const bool m_packed;
153 size_t m_frame_len;
154
155
156 void to_bvec(itpp::bvec& out, const uint8_t* in);
157 void from_bvec(uint8_t* out, const itpp::bvec& in);
158};
159
160
161} // namespace code
162} // namespace satnogs
163} // namespace gr
164
165#endif // EGOLAY_DECODER_H
#define SATNOGS_API
Definition: api.h:19
Definition: egolay_decoder.h:34
static fec::generic_decoder::sptr make(bool packed=false)
bool set_frame_size(unsigned int frame_size) override
void generic_work(fec_input_buffer_type inbuffer, void *outbuffer) override
const char * get_output_conversion() override
egolay_decoder(bool packed=false)
const char * get_input_conversion() override
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