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