GNU Radio's SATNOGS Package
ccsds_rs_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 CCSDS_RS_ENCODER_H
22#define CCSDS_RS_ENCODER_H
23
24#include <gnuradio/fec/encoder.h>
26#include <string>
27
28namespace gr {
29namespace satnogs {
30namespace code {
31
32class SATNOGS_API ccsds_rs_encoder : virtual public fec::generic_encoder
33{
34public:
35 /**
36 * @brief Error correction capabilities.
37 * @note the parity overhead can be calculated as \f$ \p ecc \times 2 \f$
38 *
39 */
40 enum class ecc : size_t { ecc8 = 8UL, ecc16 = 16UL };
41
42 /**
43 * @brief Interleaving depth
44 *
45 */
46 enum class interleaving_depth : size_t {
47 depth1 = 1,
48 depth2 = 2,
49 depth3 = 3,
50 depth4 = 4,
51 depth5 = 5,
52 depth8 = 8
53 };
54
55 static fec::generic_encoder::sptr make(ecc e, interleaving_depth depth);
56
58
59 double rate() override;
60
61 /*!
62 * Returns the input size in items that the encoder object uses
63 * to encode a full frame. Often, this number is the number of
64 * bits per frame if the input format is unpacked. If the block
65 * expects packed bytes, then this value should be the number of
66 * bytes (number of bits / 8) per input frame.
67 *
68 * The child class MUST implement this function.
69 */
70 int get_input_size() override;
71
72 /*!
73 * Returns the output size in items that the encoder object
74 * produces after encoding a full frame. Often, this number is
75 * the number of bits in the outputted frame if the input format
76 * is unpacked. If the block produces packed bytes, then this
77 * value should be the number of bytes (number of bits / 8) per
78 * frame produced. This value is generally something like
79 * R*get_input_size() for a 1/R rate code.
80 *
81 * The child class MUST implement this function.
82 */
83 int get_output_size() override;
84
85 /*!
86 * Set up a conversion type required to setup the data properly
87 * for this encoder. The encoder itself will not implement the
88 * conversion and expects an external wrapper (e.g.,
89 * fec.extended_encoder) to read this value and "do the right
90 * thing" to format the data.
91 *
92 * The default behavior is 'none', which means no conversion is
93 * required. Whatever the get_input_item_size() value returns,
94 * the input is expected to conform directly to this. Generally,
95 * this means unpacked bytes.
96 *
97 * If 'pack', the block expects the inputs to be packed
98 * bytes. The wrapper should implement a
99 * gr::blocks::pack_k_bits_bb(8) block for this.
100 *
101 * The child class MAY implement this function. If not
102 * reimplemented, it returns "none".
103 */
104 const char* get_input_conversion() override;
105
106 /*!
107 * Set up a conversion type required to understand the output
108 * style of this encoder. Generally an encoder will produce
109 * unpacked bytes with a bit set in the LSB.
110 *
111 * The default behavior is 'none', which means no conversion is
112 * required and the encoder produces unpacked bytes.
113 *
114 * If 'packed_bits', the block produces packed bits and the
115 * wrapper should unpack these (using, for instance,
116 * gr::block::unpack_k_bits_bb(8)).
117 *
118 * The child class MAY implement this function. If not
119 * reimplemented, it returns "none".
120 */
121 const char* get_output_conversion() override;
122
123 /*!
124 * Updates the size of the frame to encode.
125 *
126 * The child class MUST implement this function and interpret
127 * how the \p frame_size information affects the block's
128 * behavior. It should also provide bounds checks.
129 */
130 bool set_frame_size(unsigned int frame_size) override;
131
132 void generic_work(void* inbuffer, void* outbuffer) override;
133
134private:
135 const ecc m_ecc;
136 const interleaving_depth m_depth;
137 const size_t m_rs_parity;
138 const size_t m_max_in_frame_len;
139 const size_t m_max_out_frame_len;
140 size_t m_frame_len;
141};
142
143
144} // namespace code
145} // namespace satnogs
146} // namespace gr
147
148#endif // CCSDS_RS_ENCODER_H
#define SATNOGS_API
Definition: api.h:19
Definition: ccsds_rs_encoder.h:33
ecc
Error correction capabilities.
Definition: ccsds_rs_encoder.h:40
interleaving_depth
Interleaving depth.
Definition: ccsds_rs_encoder.h:46
ccsds_rs_encoder(ecc e, interleaving_depth depth)
const char * get_output_conversion() override
static fec::generic_encoder::sptr make(ecc e, interleaving_depth depth)
const char * get_input_conversion() override
bool set_frame_size(unsigned int frame_size) override
void generic_work(void *inbuffer, void *outbuffer) override
Definition: amsat_duv_decoder.h:29