SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | Private Attributes | List of all members
leansdr::s2_fecdec< SOFTBIT, SOFTBYTE > Struct Template Reference

#include <dvbs2.h>

+ Inheritance diagram for leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >:
+ Collaboration diagram for leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >:

Public Member Functions

 s2_fecdec (scheduler *sch, pipebuf< fecframe< SOFTBYTE >> &_in, pipebuf< bbframe > &_out, pipebuf< int > *_bitcount=NULL, pipebuf< int > *_errcount=NULL)
 
void run ()
 
- Public Member Functions inherited from leansdr::runnable
 runnable (scheduler *_sch, const char *name)
 
- Public Member Functions inherited from leansdr::runnable_common
 runnable_common (const char *_name)
 
virtual ~runnable_common ()
 
virtual void shutdown ()
 

Public Attributes

int bitflips
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

s2_ldpc_engines< SOFTBIT, SOFTBYTE > s2ldpc
 
uint8_t bch_buf [64800/8]
 
s2_bch_engines s2bch
 
s2_bbscrambling bbscrambling
 
pipereader< fecframe< SOFTBYTE > > in
 
pipewriter< bbframeout
 
pipewriter< int > * bitcount
 
pipewriter< int > * errcount
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

template<typename SOFTBIT, typename SOFTBYTE>
struct leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >

Definition at line 2090 of file dvbs2.h.

Constructor & Destructor Documentation

◆ s2_fecdec()

template<typename SOFTBIT, typename SOFTBYTE>
leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::s2_fecdec ( scheduler sch,
pipebuf< fecframe< SOFTBYTE >> &  _in,
pipebuf< bbframe > &  _out,
pipebuf< int > *  _bitcount = NULL,
pipebuf< int > *  _errcount = NULL 
)
inline

Definition at line 2093 of file dvbs2.h.

References leansdr::scheduler::debug.

2097  : runnable(sch, "S2 fecdec"),
2098  bitflips(0),
2099  in(_in), out(_out),
2100  bitcount(opt_writer(_bitcount, 1)),
2101  errcount(opt_writer(_errcount, 1))
2102  {
2103  if (sch->debug)
2104  s2ldpc.print_node_stats();
2105  }
pipewriter< int > * bitcount
Definition: dvbs2.h:2174
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
s2_ldpc_engines< SOFTBIT, SOFTBYTE > s2ldpc
Definition: dvbs2.h:2168
pipewriter< bbframe > out
Definition: dvbs2.h:2173
pipewriter< T > * opt_writer(pipebuf< T > *buf, unsigned long min_write=1)
Definition: framework.h:329
pipewriter< int > * errcount
Definition: dvbs2.h:2174
scheduler * sch
Definition: framework.h:199
pipereader< fecframe< SOFTBYTE > > in
Definition: dvbs2.h:2172

Member Function Documentation

◆ run()

template<typename SOFTBIT, typename SOFTBYTE>
void leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 2106 of file dvbs2.h.

References leansdr::fecframe< SOFTBYTE >::bytes, leansdr::bbframe::bytes, leansdr::check_modcod(), leansdr::bch_interface::decode(), leansdr::ldpc_engine< SOFTBIT, SOFTWORD, SWSIZE, Taddr >::decode_bitflip(), leansdr::opt_writable(), leansdr::opt_write(), leansdr::fecframe< SOFTBYTE >::pls, leansdr::bbframe::pls, leansdr::modcod_info::rate, leansdr::pipereader< T >::rd(), leansdr::pipereader< T >::read(), leansdr::pipereader< T >::readable(), leansdr::softbytes_harden(), leansdr::pipewriter< T >::wr(), leansdr::pipewriter< T >::writable(), and leansdr::pipewriter< T >::written().

2107  {
2108  while (in.readable() >= 1 && out.writable() >= 1 &&
2110  {
2111  fecframe<SOFTBYTE> *pin = in.rd();
2112  const modcod_info *mcinfo = check_modcod(pin->pls.modcod);
2113  const fec_info *fi = &fec_infos[pin->pls.sf][mcinfo->rate];
2114  bool corrupted = false;
2115  bool residual_errors;
2116  if (true)
2117  {
2118  // LDPC decode
2119  size_t cwbits = pin->pls.framebits();
2120  size_t msgbits = fi->kldpc;
2121  size_t chkbits = cwbits - msgbits;
2122  s2_ldpc_engine *ldpc = s2ldpc.ldpcs[pin->pls.sf][mcinfo->rate];
2123  int ncorr = ldpc->decode_bitflip(fi->ldpc, pin->bytes, msgbits, cwbits, bitflips);
2124  if (sch->debug2)
2125  fprintf(stderr, "LDPCCORR = %d\n", ncorr);
2126  }
2127  uint8_t *hardbytes = softbytes_harden(pin->bytes, fi->kldpc / 8, bch_buf);
2128  if (true)
2129  {
2130  // BCH decode
2131  size_t cwbytes = fi->kldpc / 8;
2132  size_t msgbytes = fi->Kbch / 8;
2133  size_t chkbytes = cwbytes - msgbytes;
2134  // Decode with suitable BCH decoder for this MODCOD
2135  bch_interface *bch = s2bch.bchs[pin->pls.sf][mcinfo->rate];
2136  int ncorr = bch->decode(hardbytes, cwbytes);
2137  if (sch->debug2)
2138  fprintf(stderr, "BCHCORR = %d\n", ncorr);
2139  corrupted = (ncorr < 0);
2140  residual_errors = (ncorr != 0);
2141  // Report VER
2142  opt_write(bitcount, fi->Kbch);
2143  opt_write(errcount, (ncorr >= 0) ? ncorr : fi->Kbch);
2144  }
2145  int bbsize = fi->Kbch / 8;
2146  // TBD Some decoders want the bad packets.
2147 #if 0
2148  if ( corrupted ) {
2149  fprintf(stderr, "Passing bad frame\n");
2150  corrupted = false;
2151  }
2152 #endif
2153  if (!corrupted)
2154  {
2155  // Descramble and output
2156  bbframe *pout = out.wr();
2157  pout->pls = pin->pls;
2158  bbscrambling.transform(hardbytes, bbsize, pout->bytes);
2159  out.written(1);
2160  }
2161  if (sch->debug)
2162  fprintf(stderr, "%c", corrupted ? ':' : residual_errors ? '.' : '_');
2163  in.read(1);
2164  }
2165  }
virtual int decode(uint8_t *cw, size_t cwbytes)=0
uint8_t * softbytes_harden(hard_sb p[], int nbytes, uint8_t storage[])
Definition: softword.h:67
pipewriter< int > * bitcount
Definition: dvbs2.h:2174
bch_interface * bchs[2][FEC_COUNT]
Definition: dvbs2.h:1966
s2_ldpc_engines< SOFTBIT, SOFTBYTE > s2ldpc
Definition: dvbs2.h:2168
unsigned char uint8_t
Definition: rtptypes_win.h:42
pipewriter< bbframe > out
Definition: dvbs2.h:2173
void opt_write(pipewriter< T > *p, T val)
Definition: framework.h:341
bool opt_writable(pipewriter< T > *p, int n=1)
Definition: framework.h:335
pipewriter< int > * errcount
Definition: dvbs2.h:2174
void transform(const uint8_t *in, int bbsize, uint8_t *out)
Definition: dvbs2.h:186
s2_bch_engines s2bch
Definition: dvbs2.h:2170
s2_bbscrambling bbscrambling
Definition: dvbs2.h:2171
ldpc_engine< bool, hard_sb, 8, uint16_t > s2_ldpc_engine
Definition: dvbs2.h:1868
scheduler * sch
Definition: framework.h:199
uint8_t bch_buf[64800/8]
Definition: dvbs2.h:2169
const modcod_info * check_modcod(int m)
Definition: dvbs2.h:285
pipereader< fecframe< SOFTBYTE > > in
Definition: dvbs2.h:2172
+ Here is the call graph for this function:

Member Data Documentation

◆ bbscrambling

template<typename SOFTBIT, typename SOFTBYTE>
s2_bbscrambling leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::bbscrambling
private

Definition at line 2171 of file dvbs2.h.

◆ bch_buf

template<typename SOFTBIT, typename SOFTBYTE>
uint8_t leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::bch_buf[64800/8]
private

Definition at line 2169 of file dvbs2.h.

◆ bitcount

template<typename SOFTBIT, typename SOFTBYTE>
pipewriter<int>* leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::bitcount
private

Definition at line 2174 of file dvbs2.h.

◆ bitflips

template<typename SOFTBIT, typename SOFTBYTE>
int leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::bitflips

Definition at line 2092 of file dvbs2.h.

◆ errcount

template<typename SOFTBIT, typename SOFTBYTE>
pipewriter<int> * leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::errcount
private

Definition at line 2174 of file dvbs2.h.

◆ in

template<typename SOFTBIT, typename SOFTBYTE>
pipereader<fecframe<SOFTBYTE> > leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::in
private

Definition at line 2172 of file dvbs2.h.

◆ out

template<typename SOFTBIT, typename SOFTBYTE>
pipewriter<bbframe> leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::out
private

Definition at line 2173 of file dvbs2.h.

◆ s2bch

template<typename SOFTBIT, typename SOFTBYTE>
s2_bch_engines leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::s2bch
private

Definition at line 2170 of file dvbs2.h.

◆ s2ldpc

template<typename SOFTBIT, typename SOFTBYTE>
s2_ldpc_engines<SOFTBIT, SOFTBYTE> leansdr::s2_fecdec< SOFTBIT, SOFTBYTE >::s2ldpc
private

Definition at line 2168 of file dvbs2.h.


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