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