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::rs_decoder< Tbyte, BYTE_ERASED > Struct Template Reference

#include <dvb.h>

+ Inheritance diagram for leansdr::rs_decoder< Tbyte, BYTE_ERASED >:
+ Collaboration diagram for leansdr::rs_decoder< Tbyte, BYTE_ERASED >:

Public Member Functions

 rs_decoder (scheduler *sch, pipebuf< rspacket< Tbyte >> &_in, pipebuf< tspacket > &_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

rs_engine rs
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

pipereader< rspacket< Tbyte > > in
 
pipewriter< tspacketout
 
pipewriter< int > * bitcount
 
pipewriter< int > * errcount
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

template<typename Tbyte, int BYTE_ERASED>
struct leansdr::rs_decoder< Tbyte, BYTE_ERASED >

Definition at line 1215 of file dvb.h.

Constructor & Destructor Documentation

◆ rs_decoder()

template<typename Tbyte, int BYTE_ERASED>
leansdr::rs_decoder< Tbyte, BYTE_ERASED >::rs_decoder ( scheduler sch,
pipebuf< rspacket< Tbyte >> &  _in,
pipebuf< tspacket > &  _out,
pipebuf< int > *  _bitcount = NULL,
pipebuf< int > *  _errcount = NULL 
)
inline

Definition at line 1219 of file dvb.h.

1223  : runnable(sch, "RS decoder"),
1224  in(_in),
1225  out(_out)
1226  {
1227  bitcount = _bitcount ? new pipewriter<int>(*_bitcount) : NULL;
1228  errcount = _errcount ? new pipewriter<int>(*_errcount) : NULL;
1229  }
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
pipewriter< int > * errcount
Definition: dvb.h:1305
pipereader< rspacket< Tbyte > > in
Definition: dvb.h:1303
scheduler * sch
Definition: framework.h:199
pipewriter< int > * bitcount
Definition: dvb.h:1305
pipewriter< tspacket > out
Definition: dvb.h:1304

Member Function Documentation

◆ run()

template<typename Tbyte, int BYTE_ERASED>
void leansdr::rs_decoder< Tbyte, BYTE_ERASED >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 1231 of file dvb.h.

1232  {
1233  if (bitcount && bitcount->writable() < 1)
1234  return;
1235  if (errcount && errcount->writable() < 1)
1236  return;
1237 
1238  int nbits = 0, nerrs = 0;
1239 
1240  while (in.readable() >= 1 && out.writable() >= 1)
1241  {
1242  Tbyte *pin = in.rd()->data;
1243  u8 *pout = out.wr()->data;
1244 
1245  nbits += SIZE_RSPACKET * 8;
1246 
1247  // The message is the first 188 bytes.
1248  if (sizeof(Tbyte) == 1)
1249  memcpy(pout, pin, SIZE_TSPACKET);
1250  else
1251  fail("Erasures not implemented");
1252 
1253  u8 synd[16];
1254  bool corrupted = rs.syndromes(pin, synd);
1255 
1256 #if 0
1257  if ( ! corrupted ) {
1258  // Test BM
1259  fprintf(stderr, "Simulating errors\n");
1260  pin[203] ^= 42;
1261  pin[202] ^= 99;
1262  corrupted = rs.syndromes(pin, synd);
1263  }
1264 #endif
1265  if (!corrupted)
1266  {
1267  if (sch->debug)
1268  fprintf(stderr, "_"); // Packet received without errors.
1269  }
1270  else
1271  {
1272  corrupted = rs.correct(synd, pout, pin, &nerrs);
1273 
1274  if (sch->debug)
1275  {
1276  if (!corrupted)
1277  fprintf(stderr, "."); // Errors were corrected.
1278  else
1279  fprintf(stderr, "!"); // Packet still corrupted.
1280  }
1281  }
1282 
1283  in.read(1);
1284 
1285  // Output corrupted packets (with a special mark)
1286  // otherwise the derandomizer will lose synchronization.
1287  if (corrupted)
1288  pout[0] ^= MPEG_SYNC_CORRUPTED;
1289 
1290  out.written(1);
1291  }
1292 
1293  if (nbits)
1294  {
1295  if (bitcount)
1296  bitcount->write(nbits);
1297  if (errcount)
1298  errcount->write(nerrs);
1299  }
1300  }
rs_engine rs
Definition: dvb.h:1217
unsigned char u8
Definition: framework.h:453
pipewriter< int > * errcount
Definition: dvb.h:1305
bool correct(u8 synd[16], u8 pout[188], u8 pin[204]=NULL, int *bits_corrected=NULL)
Definition: rs.h:201
pipereader< rspacket< Tbyte > > in
Definition: dvb.h:1303
void fail(const char *s)
Definition: framework.cpp:11
bool syndromes(const u8 *poly, u8 *synd)
Definition: rs.h:132
scheduler * sch
Definition: framework.h:199
void write(const T &e)
Definition: framework.h:319
pipewriter< int > * bitcount
Definition: dvb.h:1305
pipewriter< tspacket > out
Definition: dvb.h:1304

Member Data Documentation

◆ bitcount

template<typename Tbyte, int BYTE_ERASED>
pipewriter<int>* leansdr::rs_decoder< Tbyte, BYTE_ERASED >::bitcount
private

Definition at line 1305 of file dvb.h.

◆ errcount

template<typename Tbyte, int BYTE_ERASED>
pipewriter<int> * leansdr::rs_decoder< Tbyte, BYTE_ERASED >::errcount
private

Definition at line 1305 of file dvb.h.

◆ in

template<typename Tbyte, int BYTE_ERASED>
pipereader<rspacket<Tbyte> > leansdr::rs_decoder< Tbyte, BYTE_ERASED >::in
private

Definition at line 1303 of file dvb.h.

◆ out

template<typename Tbyte, int BYTE_ERASED>
pipewriter<tspacket> leansdr::rs_decoder< Tbyte, BYTE_ERASED >::out
private

Definition at line 1304 of file dvb.h.

◆ rs

template<typename Tbyte, int BYTE_ERASED>
rs_engine leansdr::rs_decoder< Tbyte, BYTE_ERASED >::rs

Definition at line 1217 of file dvb.h.


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