GNU Radio C++ API Reference: generic_encoder.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
generic_encoder.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013-2014 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_FEC_GENERIC_ENCODER_H
12#define INCLUDED_FEC_GENERIC_ENCODER_H
13
14#include <gnuradio/block.h>
15#include <gnuradio/fec/api.h>
16#include <gnuradio/logger.h>
17#include <memory>
18
19namespace gr {
20namespace fec {
21
22 class FEC_API generic_encoder
23{
24protected:
25 gr::logger_ptr d_logger;
26
27public:
28 friend class encoder;
29 virtual void generic_work(const void* in_buffer, void* out_buffer) = 0;
30 static int base_unique_id;
31 int my_id;
32 int unique_id();
33 std::string d_name;
34 std::string alias();
35
36public:
37 typedef std::shared_ptr<generic_encoder> sptr;
38
39 /*!
40 * Returns the rate of the code. For every 1 input bit, there
41 * are r output bits, so the rate is 1/r. Used for setting
42 * things like the encoder block's relative rate.
43 *
44 * This function MUST be reimplemented by the child class.
45 */
46 virtual double rate() = 0;
47
48 /*!
49 * Returns the input size in items that the encoder object uses
50 * to encode a full frame. Often, this number is the number of
51 * bits per frame if the input format is unpacked. If the block
52 * expects packed bytes, then this value should be the number of
53 * bytes (number of bits / 8) per input frame.
54 *
55 * The child class MUST implement this function.
56 */
57 virtual int get_input_size() = 0;
58
59 /*!
60 * Returns the output size in items that the encoder object
61 * produces after encoding a full frame. Often, this number is
62 * the number of bits in the outputted frame if the input format
63 * is unpacked. If the block produces packed bytes, then this
64 * value should be the number of bytes (number of bits / 8) per
65 * frame produced. This value is generally something like
66 * R*get_input_size() for a 1/R rate code.
67 *
68 * The child class MUST implement this function.
69 */
70 virtual int get_output_size() = 0;
71
72 /*!
73 * Set up a conversion type required to setup the data properly
74 * for this encoder. The encoder itself will not implement the
75 * conversion and expects an external wrapper (e.g.,
76 * fec.extended_encoder) to read this value and "do the right
77 * thing" to format the data.
78 *
79 * The default behavior is 'none', which means no conversion is
80 * required. Whatever the get_input_item_size() value returns,
81 * the input is expected to conform directly to this. Generally,
82 * this means unpacked bytes.
83 *
84 * If 'pack', the block expects the inputs to be packed
85 * bytes. The wrapper should implement a
86 * gr::blocks::pack_k_bits_bb(8) block for this.
87 *
88 * The child class MAY implement this function. If not
89 * reimplemented, it returns "none".
90 */
91 virtual const char* get_input_conversion();
92
93 /*!
94 * Set up a conversion type required to understand the output
95 * style of this encoder. Generally an encoder will produce
96 * unpacked bytes with a bit set in the LSB.
97 *
98 * The default behavior is 'none', which means no conversion is
99 * required and the encoder produces unpacked bytes.
100 *
101 * If 'packed_bits', the block produces packed bits and the
102 * wrapper should unpack these (using, for instance,
103 * gr::block::unpack_k_bits_bb(8)).
104 *
105 * The child class MAY implement this function. If not
106 * reimplemented, it returns "none".
107 */
108 virtual const char* get_output_conversion();
109
110 /*!
111 * Updates the size of the frame to encode.
112 *
113 * The child class MUST implement this function and interpret
114 * how the \p frame_size information affects the block's
115 * behavior. It should also provide bounds checks.
116 */
117 virtual bool set_frame_size(unsigned int frame_size) = 0;
118
119 generic_encoder(void){};
120 generic_encoder(std::string name);
121 virtual ~generic_encoder();
122};
123
124/*! see generic_encoder::get_output_size() */
125 FEC_API int get_encoder_output_size(generic_encoder::sptr my_encoder);
126
127/*! see generic_encoder::get_input_size() */
128 FEC_API int get_encoder_input_size(generic_encoder::sptr my_encoder);
129
130/*! see generic_encoder::get_input_conversion() */
131 FEC_API const char* get_encoder_input_conversion(generic_encoder::sptr my_encoder);
132
133/*! see generic_encoder::get_output_conversion() */
134 FEC_API const char* get_encoder_output_conversion(generic_encoder::sptr my_encoder);
135
136
137} /* namespace fec */
138} /* namespace gr */
139
140#endif /* INCLUDED_FEC_GENERIC_ENCODER_H */
gr::fec::generic_encoder::rate
virtual double rate()=0
gr::fec::generic_encoder::d_logger
gr::logger_ptr d_logger
Definition generic_encoder.h:25
gr::fec::generic_encoder::generic_work
virtual void generic_work(const void *in_buffer, void *out_buffer)=0
gr::fec::generic_encoder::alias
std::string alias()
gr::fec::generic_encoder::~generic_encoder
virtual ~generic_encoder()
gr::fec::generic_encoder::base_unique_id
static int base_unique_id
Definition generic_encoder.h:30
gr::fec::generic_encoder::sptr
std::shared_ptr< generic_encoder > sptr
Definition generic_encoder.h:37
gr::fec::generic_encoder::generic_encoder
generic_encoder(void)
Definition generic_encoder.h:119
gr::fec::generic_encoder::generic_encoder
generic_encoder(std::string name)
gr::fec::generic_encoder::encoder
friend class encoder
Definition generic_encoder.h:28
gr::fec::generic_encoder::get_input_size
virtual int get_input_size()=0
gr::fec::generic_encoder::get_output_size
virtual int get_output_size()=0
gr::fec::generic_encoder::d_name
std::string d_name
Definition generic_encoder.h:33
gr::fec::generic_encoder::set_frame_size
virtual bool set_frame_size(unsigned int frame_size)=0
gr::fec::generic_encoder::unique_id
int unique_id()
gr::fec::generic_encoder::get_input_conversion
virtual const char * get_input_conversion()
gr::fec::generic_encoder::my_id
int my_id
Definition generic_encoder.h:31
gr::fec::generic_encoder::get_output_conversion
virtual const char * get_output_conversion()
block.h
api.h
FEC_API
#define FEC_API
Definition gr-fec/include/gnuradio/fec/api.h:18
logger.h
gr::fec
Definition async_decoder.h:20
gr::fec::get_encoder_input_size
FEC_API int get_encoder_input_size(generic_encoder::sptr my_encoder)
gr::fec::get_encoder_output_conversion
FEC_API const char * get_encoder_output_conversion(generic_encoder::sptr my_encoder)
gr::fec::get_encoder_output_size
FEC_API int get_encoder_output_size(generic_encoder::sptr my_encoder)
gr::fec::get_encoder_input_conversion
FEC_API const char * get_encoder_input_conversion(generic_encoder::sptr my_encoder)
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
gr::logger_ptr
std::shared_ptr< logger > logger_ptr
Definition logger.h:250