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 | Private Attributes | List of all members
leansdr::randomizer Struct Reference

#include <dvb.h>

+ Inheritance diagram for leansdr::randomizer:
+ Collaboration diagram for leansdr::randomizer:

Public Member Functions

 randomizer (scheduler *sch, pipebuf< tspacket > &_in, pipebuf< tspacket > &_out)
 
void precompute_pattern ()
 
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 ()
 

Private Attributes

u8 pattern [188 *8]
 
u8pattern_end
 
u8pos
 
pipereader< tspacketin
 
pipewriter< tspacketout
 

Additional Inherited Members

- Public Attributes inherited from leansdr::runnable_common
const char * name
 
- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

Definition at line 1311 of file dvb.h.

Constructor & Destructor Documentation

◆ randomizer()

leansdr::randomizer::randomizer ( scheduler sch,
pipebuf< tspacket > &  _in,
pipebuf< tspacket > &  _out 
)
inline

Definition at line 1313 of file dvb.h.

1315  : runnable(sch, "derandomizer"),
1316  in(_in),
1317  out(_out)
1318  {
1320  pos = pattern;
1321  pattern_end = pattern + sizeof(pattern) / sizeof(pattern[0]);
1322  }
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
pipereader< tspacket > in
Definition: dvb.h:1364
void precompute_pattern()
Definition: dvb.h:1324
u8 pattern[188 *8]
Definition: dvb.h:1363
scheduler * sch
Definition: framework.h:199
pipewriter< tspacket > out
Definition: dvb.h:1365
u8 * pattern_end
Definition: dvb.h:1363

Member Function Documentation

◆ precompute_pattern()

void leansdr::randomizer::precompute_pattern ( )
inline

Definition at line 1324 of file dvb.h.

References i, and leansdr::deconvol_sync< Tbyte, BYTE_ERASED >::sync_t::out.

1325  {
1326  // EN 300 421, section 4.4.1 Transport multiplex adaptation
1327  pattern[0] = 0xff; // Invert one in eight sync bytes
1328  unsigned short st = 000251; // 0b 000 000 010 101 001 (Fig 2 reversed)
1329 
1330  for (int i = 1; i < 188 * 8; ++i)
1331  {
1332  u8 out = 0;
1333 
1334  for (int n = 8; n--;)
1335  {
1336  int bit = ((st >> 13) ^ (st >> 14)) & 1; // Taps
1337  out = (out << 1) | bit; // MSB first
1338  st = (st << 1) | bit; // Feedback
1339  }
1340 
1341  pattern[i] = (i % 188) ? out : 0; // Inhibit on sync bytes
1342  }
1343  }
unsigned char u8
Definition: framework.h:453
u8 pattern[188 *8]
Definition: dvb.h:1363
int32_t i
Definition: decimators.h:244
pipewriter< tspacket > out
Definition: dvb.h:1365

◆ run()

void leansdr::randomizer::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 1345 of file dvb.h.

References leansdr::deconvol_sync< Tbyte, BYTE_ERASED >::sync_t::in, and leansdr::deconvol_sync< Tbyte, BYTE_ERASED >::sync_t::out.

1346  {
1347  while (in.readable() >= 1 && out.writable() >= 1)
1348  {
1349  u8 *pin = in.rd()->data, *pend = pin + SIZE_TSPACKET;
1350  u8 *pout = out.wr()->data;
1351  if (pin[0] != MPEG_SYNC)
1352  fprintf(stderr, "randomizer: bad MPEG sync %02x\n", pin[0]);
1353  for (; pin < pend; ++pin, ++pout, ++pos)
1354  *pout = *pin ^ *pos;
1355  if (pos == pattern_end)
1356  pos = pattern;
1357  in.read(1);
1358  out.written(1);
1359  }
1360  }
unsigned char u8
Definition: framework.h:453
pipereader< tspacket > in
Definition: dvb.h:1364
u8 pattern[188 *8]
Definition: dvb.h:1363
pipewriter< tspacket > out
Definition: dvb.h:1365
u8 * pattern_end
Definition: dvb.h:1363

Member Data Documentation

◆ in

pipereader<tspacket> leansdr::randomizer::in
private

Definition at line 1364 of file dvb.h.

◆ out

pipewriter<tspacket> leansdr::randomizer::out
private

Definition at line 1365 of file dvb.h.

◆ pattern

u8 leansdr::randomizer::pattern[188 *8]
private

Definition at line 1363 of file dvb.h.

◆ pattern_end

u8 * leansdr::randomizer::pattern_end
private

Definition at line 1363 of file dvb.h.

◆ pos

u8 * leansdr::randomizer::pos
private

Definition at line 1363 of file dvb.h.


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