GNU Radio's DVBS2RX Package
gr::dvbs2rx::bch_codec< T, P > Class Template Reference

BCH coder/decoder. More...

#include <bch.h>

Public Member Functions

 bch_codec (const galois_field< T > *const gf, uint8_t t, uint32_t n=0)
 Construct a new BCH coder/decoder object.
 
encode (const T &msg) const
 Encode an input message.
 
void encode (u8_cptr_t msg, u8_ptr_t codeword) const
 
std::vector< T > syndrome (const T &codeword) const
 Compute the syndrome of a received codeword.
 
std::vector< T > syndrome (u8_cptr_t codeword) const
 
gf2m_poly< T > err_loc_polynomial (const std::vector< T > &syndrome) const
 Compute the error-location polynomial.
 
std::vector< T > err_loc_numbers (const gf2m_poly< T > &sigma) const
 Compute the error-location numbers.
 
decode (T codeword) const
 Decode an input codeword.
 
int decode (u8_cptr_t codeword, u8_ptr_t decoded_msg) const
 
const gf2_poly< P > & get_gen_poly () const
 Get the generator polynomial object.
 
uint16_t get_n () const
 Get the codeword length n.
 
uint16_t get_k () const
 Get the message length k.
 

Detailed Description

template<typename T, typename P>
class gr::dvbs2rx::bch_codec< T, P >

BCH coder/decoder.

Template Parameters
TBase type for the Galois Field elements.
PBase type for the GF(2) generator polynomial.

Constructor & Destructor Documentation

◆ bch_codec()

template<typename T , typename P >
gr::dvbs2rx::bch_codec< T, P >::bch_codec ( const galois_field< T > *const gf,
uint8_t t,
uint32_t n = 0 )

Construct a new BCH coder/decoder object.

Parameters
gfReference Galois field.
tTarget error correction capability.
nTarget codeword length in bits.
Note
The default codeword length is n=(2^m - 1), where m is the dimension of the GF(2^m) Galois Field, so the codeword length is inferred from the gf parameter. Alternatively, a codeword length lower than (2^m - 1) and greater than the generator polynomial's degree can be specified through parameter n. In this case, the constructor attempts to construct a shortened (n - s, k - s) BCH code, with parameter s equal to (2^m - 1) - n.

Member Function Documentation

◆ decode() [1/2]

template<typename T , typename P >
T gr::dvbs2rx::bch_codec< T, P >::decode ( T codeword) const

Decode an input codeword.

Parameters
codewordn-bit input codeword.
Returns
T Decoded message.

◆ decode() [2/2]

template<typename T , typename P >
int gr::dvbs2rx::bch_codec< T, P >::decode ( u8_cptr_t codeword,
u8_ptr_t decoded_msg ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
codewordPointer to the received codeword with n/8 bytes.
decoded_msgPointer to the decoded message buffer with space for k/8 bytes.
Returns
int Number of bit errors corrected by the decoder. Set to 0 when the message is error-free and -1 when the decoding fails to correct all errors such that the decoded message has residual bit errors.
Note
The caller should make sure the pointers point to memory regions with enough data and space.
This bytes-based decoding is only supported when n and k are multiples of 8.

◆ encode() [1/2]

template<typename T , typename P >
T gr::dvbs2rx::bch_codec< T, P >::encode ( const T & msg) const

Encode an input message.

Parameters
msgk-bit input message.
Returns
T Resulting codeword.
Note
The parity digits are placed at the least significant (lower order) n - k bit positions, whereas the original (systematic) message is placed at the most significant k bit positions, from bit n-1 to bit n-k.
Only use this implementation if the message type T can hold n bits. Otherwise, use the implementation based on an array of bytes.

◆ encode() [2/2]

template<typename T , typename P >
void gr::dvbs2rx::bch_codec< T, P >::encode ( u8_cptr_t msg,
u8_ptr_t codeword ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
msgPointer to the input message with k/8 bytes.
codewordPointer to the codeword buffer with space for n/8 bytes.
Note
Since the code is systematic, the first k/8 bytes of the resulting codeword hold the original message, whereas the remaining bytes contain the parity digits. A serializer should read the codeword from the first byte to the last byte to preserve the order.
The caller should make sure the pointers point to memory regions with enough data and space.
This bytes-based encoding is only supported when n and k are multiples of 8.

◆ err_loc_numbers()

template<typename T , typename P >
std::vector< T > gr::dvbs2rx::bch_codec< T, P >::err_loc_numbers ( const gf2m_poly< T > & sigma) const

Compute the error-location numbers.

The error-location numbers are the numbers from GF(2^m) corresponding to the reciprocal of the roots of the error-location polynomial. An error-location number alpha^j indicates there is an error in the j-th bit of the received codeword.

Parameters
sigmaError location polynomial.
Returns
std::vector<T> Error location numbers, a vector of elements from GF(2^m).

◆ err_loc_polynomial()

template<typename T , typename P >
gf2m_poly< T > gr::dvbs2rx::bch_codec< T, P >::err_loc_polynomial ( const std::vector< T > & syndrome) const

Compute the error-location polynomial.

The error-location polynomial is a polynomial over GF(2^m) whose roots indicate the location of bit errors. The implementation for finding this polynomial is based on the simplified Berlekamp's iterative algorithm, which works for binary BCH codes.

Parameters
syndromeSyndrome vector with 2t elements.
Returns
gf2m_poly<T> Error-location polynomial, a polynomial over GF(2^m).

◆ get_gen_poly()

template<typename T , typename P >
const gf2_poly< P > & gr::dvbs2rx::bch_codec< T, P >::get_gen_poly ( ) const
inline

Get the generator polynomial object.

Returns
const gf2_poly

& Generator polynomial.

◆ get_k()

template<typename T , typename P >
uint16_t gr::dvbs2rx::bch_codec< T, P >::get_k ( ) const
inline

Get the message length k.

Returns
uint16_t Message length.

◆ get_n()

template<typename T , typename P >
uint16_t gr::dvbs2rx::bch_codec< T, P >::get_n ( ) const
inline

Get the codeword length n.

Returns
uint16_t Codeword length.

◆ syndrome() [1/2]

template<typename T , typename P >
std::vector< T > gr::dvbs2rx::bch_codec< T, P >::syndrome ( const T & codeword) const

Compute the syndrome of a received codeword.

Parameters
codewordReceived codeword.
Returns
std::vector<T> Syndrome as a vector with 2t GF(2^m) elements or an empty vector when the codeword is error-free.
Note
An empty vector is returned for an error-free codeword for CPU efficiency. The caller should check the size of the returned vector to determine whether the codeword is error-free or not.

◆ syndrome() [2/2]

template<typename T , typename P >
std::vector< T > gr::dvbs2rx::bch_codec< T, P >::syndrome ( u8_cptr_t codeword) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
codewordPointer to u8 array with the received codeword.

The documentation for this class was generated from the following file: