GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
cc_decoder.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 * GNU Radio 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, or (at your option)
10 * any later version.
11 *
12 * GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef INCLUDED_FEC_CC_DECODER_H
24#define INCLUDED_FEC_CC_DECODER_H
25
26#include <gnuradio/fec/api.h>
29#include <map>
30#include <string>
31
32namespace gr {
33namespace fec {
34namespace code {
35
36typedef void (*conv_kernel)(unsigned char* Y,
37 unsigned char* X,
38 unsigned char* syms,
39 unsigned char* dec,
40 unsigned int framebits,
41 unsigned int excess,
42 unsigned char* Branchtab);
43
44/*!
45 * \brief Convolutional Code Decoding class.
46 * \ingroup error_coding_blk
47 *
48 * \details
49 * This class performs convolutional decoding via the Viterbi
50 * algorithm. While it is set up to take variable values for K,
51 * rate, and the polynomials, currently, the block is only
52 * capable of handling the following settings:
53 *
54 * \li K = 7
55 * \li rate = 1/2 (given as 2 to the constructor)
56 * \li polynomials = [109, 79]
57 *
58 * This is the well-known convolutional part of the Voyager code
59 * implemented in the CCSDS encoder.
60 *
61 * The intent of having this FECAPI code classes fully
62 * parameterizable is to eventually allow it to take on generic
63 * settings, much like the cc_encoder class where the CCSDS
64 * settings would be a highly-optimized version of this.
65 *
66 * The decoder is set up with a number of bits per frame in the
67 * constructor. When not being used in a tagged stream mode,
68 * this encoder will only process frames of the length provided
69 * here. If used in a tagged stream block, this setting becomes
70 * the maximum allowable frame size that the block may process.
71 *
72 * The \p mode is a cc_mode_t that specifies how the convolutional
73 * encoder will behave and under what conditions.
74 *
75 * \li 'CC_STREAMING': mode expects an uninterrupted flow of
76 * samples into the encoder, and the output stream is
77 * continually encoded. This mode is the only mode for this
78 * decoder that has a history requirement because it requires
79 * rate*(K-1) bits more to finish the decoding properly. This
80 * mode does not work with any deployments that do not allow
81 * history.
82 *
83 * \li 'CC_TERMINATED': is a mode designed for packet-based
84 * systems. This mode adds rate*(k-1) bits to the output as a
85 * way to help flush the decoder.
86 *
87 * \li 'CC_TAILBITING': is another packet-based method. Instead of
88 * adding bits onto the end of the packet, this mode will
89 * continue the code between the payloads of packets by
90 * pre-initializing the state of the new packet based on the
91 * state of the last packet for (k-1) bits.
92 *
93 * \li 'CC_TRUNCATED': a truncated code always resets the registers
94 * to the \p start_state between frames.
95 *
96 * A common convolutional encoder uses K=7, Rate=1/2,
97 * Polynomials=[109, 79]. This is the Voyager code from NASA:
98 * \li 109: b(1101101) --> 1 + x + x^3 + x^4 + x^6
99 * \li 79: b(1001111) --> 1 + x^3 + x^4 + x^5 + x^6
100 */
101class FEC_API cc_decoder : virtual public generic_decoder
102{
103public:
104 /*!
105 * Build a convolutional code decoding FEC API object.
106 *
107 * \param frame_size Number of bits per frame. If using in the
108 * tagged stream style, this is the maximum allowable
109 * number of bits per frame.
110 * \param k Constraint length (K) of the encoder.
111 * \param rate Inverse of the coder's rate
112 * (rate=2 means 2 output bits per 1 input).
113 * \param polys Vector of polynomials as integers.
114 * \param start_state Initialization state of the shift register.
115 * \param end_state Ending state of the shift register.
116 * \param mode cc_mode_t mode of the encoding.
117 * \param padded true if the encoded frame is padded
118 * to the nearest byte.
119 */
120 static generic_decoder::sptr make(int frame_size,
121 int k,
122 int rate,
123 std::vector<int> polys,
124 int start_state = 0,
125 int end_state = -1,
126 cc_mode_t mode = CC_STREAMING,
127 bool padded = false);
128
129 /*!
130 * Sets the uncoded frame size to \p frame_size. If \p
131 * frame_size is greater than the value given to the
132 * constructor, the frame size will be capped by that initial
133 * value and this function will return false. Otherwise, it
134 * returns true.
135 */
136 virtual bool set_frame_size(unsigned int frame_size) = 0;
137
138 /*!
139 * Returns the coding rate of this encoder.
140 */
141 virtual double rate() = 0;
142};
143
144} /* namespace code */
145} /* namespace fec */
146} /* namespace gr */
147
148#endif /* INCLUDED_FEC_CC_DECODER_H */
enum _cc_mode_t cc_mode_t
@ CC_STREAMING
Definition: cc_common.h:27
Convolutional Code Decoding class.
Definition: cc_decoder.h:102
static generic_decoder::sptr make(int frame_size, int k, int rate, std::vector< int > polys, int start_state=0, int end_state=-1, cc_mode_t mode=CC_STREAMING, bool padded=false)
virtual bool set_frame_size(unsigned int frame_size)=0
virtual double rate()=0
Parent class for FECAPI objects.
Definition: generic_decoder.h:61
boost::shared_ptr< generic_decoder > sptr
Definition: generic_decoder.h:75
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
void(* conv_kernel)(unsigned char *Y, unsigned char *X, unsigned char *syms, unsigned char *dec, unsigned int framebits, unsigned int excess, unsigned char *Branchtab)
Definition: cc_decoder.h:36
Include this header to use the message passing features.
Definition: basic_block.h:45