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