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 | Static Private Member Functions | Private Attributes | List of all members
leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE > Struct Template Reference

#include <dvbs2.h>

+ Inheritance diagram for leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >:
+ Collaboration diagram for leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >:

Public Member Functions

 s2_deinterleaver (scheduler *sch, pipebuf< plslot< SOFTSYMB >> &_in, pipebuf< fecframe< SOFTBYTE >> &_out)
 
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 ()
 

Static Private Member Functions

static void deserialize_qpsk (plslot< SOFTSYMB > *pin, int nslots, SOFTBYTE *pout)
 
static void deinterleave (int bps, int rows, const plslot< SOFTSYMB > *pin, int nslots, bool msb_first, SOFTBYTE *pout)
 
template<int MSB_FIRST, int BPS>
static void deinterleave (int rows, const plslot< SOFTSYMB > *pin, int nslots, SOFTBYTE *pout)
 
static void deinterleave4050 (const plslot< SOFTSYMB > *pin, int nslots, SOFTBYTE *pout)
 
static void split_symbol (const llr_ss &ps, int bps, hard_sb accs[], int nacc, bool msb_first)
 
template<int MSB_FIRST, int BPS>
static void split_symbol (const llr_ss &ps, hard_sb accs[], int nacc)
 
static void split_symbol (const llr_ss &ps, int bps, llr_sb accs[], int nacc, bool msb_first)
 
template<int MSB_FIRST, int BPS>
static void split_symbol (const llr_ss &ps, llr_sb accs[], int nacc)
 
static void pack_qpsk_symbol (const llr_ss &ps, hard_sb *acc, int nacc)
 
static void pack_qpsk_symbol (const llr_ss &ps, llr_sb *acc, int nacc)
 

Private Attributes

pipereader< plslot< SOFTSYMB > > in
 
pipewriter< fecframe< SOFTBYTE > > out
 

Additional Inherited Members

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

Detailed Description

template<typename SOFTSYMB, typename SOFTBYTE>
struct leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >

Definition at line 1559 of file dvbs2.h.

Constructor & Destructor Documentation

◆ s2_deinterleaver()

template<typename SOFTSYMB, typename SOFTBYTE>
leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::s2_deinterleaver ( scheduler sch,
pipebuf< plslot< SOFTSYMB >> &  _in,
pipebuf< fecframe< SOFTBYTE >> &  _out 
)
inline

Definition at line 1561 of file dvbs2.h.

1564  : runnable(sch, "S2 deinterleaver"),
1565  in(_in), out(_out)
1566  {
1567  }
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
pipewriter< fecframe< SOFTBYTE > > out
Definition: dvbs2.h:1864
pipereader< plslot< SOFTSYMB > > in
Definition: dvbs2.h:1863
scheduler * sch
Definition: framework.h:199

Member Function Documentation

◆ deinterleave() [1/2]

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::deinterleave ( int  bps,
int  rows,
const plslot< SOFTSYMB > *  pin,
int  nslots,
bool  msb_first,
SOFTBYTE *  pout 
)
inlinestaticprivate

Definition at line 1652 of file dvbs2.h.

References leansdr::fail().

1655  {
1656  void (*func)(int rows, const plslot<SOFTSYMB> *pin, int nslots,
1657  SOFTBYTE *pout) = 0;
1658  if (msb_first)
1659  switch (bps)
1660  {
1661  case 2:
1662  func = deinterleave<1, 2>;
1663  break;
1664  case 3:
1665  func = deinterleave<1, 3>;
1666  break;
1667  case 4:
1668  func = deinterleave<1, 4>;
1669  break;
1670  case 5:
1671  func = deinterleave<1, 5>;
1672  break;
1673  default:
1674  fail("Bad bps");
1675  }
1676  else
1677  switch (bps)
1678  {
1679  case 2:
1680  func = deinterleave<0, 2>;
1681  break;
1682  case 3:
1683  func = deinterleave<0, 3>;
1684  break;
1685  case 4:
1686  func = deinterleave<0, 4>;
1687  break;
1688  case 5:
1689  func = deinterleave<0, 5>;
1690  break;
1691  default:
1692  fail("Bad bps");
1693  }
1694  (*func)(rows, pin, nslots, pout);
1695  }
void fail(const char *s)
Definition: framework.cpp:11
+ Here is the call graph for this function:

◆ deinterleave() [2/2]

template<typename SOFTSYMB, typename SOFTBYTE>
template<int MSB_FIRST, int BPS>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::deinterleave ( int  rows,
const plslot< SOFTSYMB > *  pin,
int  nslots,
SOFTBYTE *  pout 
)
inlinestaticprivate

Definition at line 1698 of file dvbs2.h.

References leansdr::fail(), leansdr::fatal(), leansdr::plslot< SOFTSYMB >::LENGTH, leansdr::softword_clear(), and leansdr::plslot< SOFTSYMB >::symbols.

1700  {
1701  if (BPS == 4 && rows == 4050 && MSB_FIRST)
1702  return deinterleave4050(pin, nslots, pout);
1703  if (rows % 8)
1704  fatal("modcod/framesize combination not supported\n");
1705  int stride = rows / 8; // Offset to next column, in bytes
1706  SOFTBYTE accs[BPS];
1707  for (int b = 0; b < BPS; ++b)
1708  softword_clear(&accs[b]); // gcc warning
1709  int nacc = 0;
1710  for (; nslots; --nslots, ++pin)
1711  {
1712  const SOFTSYMB *ps = pin->symbols;
1713  for (int ns = pin->LENGTH; ns--; ++ps)
1714  {
1715  split_symbol(*ps, BPS, accs, nacc, MSB_FIRST);
1716  ++nacc;
1717  if (nacc == 8)
1718  { // TBD Unroll, same as interleave()
1719  SOFTBYTE *po = pout;
1720  // TBD Pass stride as template parameter.
1721  for (int b = 0; b < BPS; ++b, po += stride)
1722  *po = accs[b];
1723  ++pout;
1724  nacc = 0;
1725  }
1726  }
1727  }
1728  if (nacc)
1729  fail("Bug: s2_deinterleaver");
1730  }
static void deinterleave4050(const plslot< SOFTSYMB > *pin, int nslots, SOFTBYTE *pout)
Definition: dvbs2.h:1736
static void split_symbol(const llr_ss &ps, int bps, hard_sb accs[], int nacc, bool msb_first)
Definition: dvbs2.h:1781
void fail(const char *s)
Definition: framework.cpp:11
void fatal(const char *s)
Definition: framework.cpp:6
void softword_clear(hard_sb *p)
Definition: softword.h:32
+ Here is the call graph for this function:

◆ deinterleave4050()

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::deinterleave4050 ( const plslot< SOFTSYMB > *  pin,
int  nslots,
SOFTBYTE *  pout 
)
inlinestaticprivate

Definition at line 1736 of file dvbs2.h.

References leansdr::fatal(), leansdr::plslot< SOFTSYMB >::LENGTH, leansdr::softword_clear(), leansdr::softword_get(), leansdr::softwords_set(), and leansdr::plslot< SOFTSYMB >::symbols.

1738  {
1739  const int rows = 4050;
1740  SOFTBYTE accs[4];
1741  for (int b = 0; b < 4; ++b)
1742  softword_clear(&accs[b]); // gcc warning
1743  int nacc = 0;
1744  for (; nslots; --nslots, ++pin)
1745  {
1746  const SOFTSYMB *ps = pin->symbols;
1747  for (int ns = pin->LENGTH; ns--; ++ps)
1748  {
1749  split_symbol(*ps, 4, accs, nacc, true);
1750  ++nacc;
1751  if (nacc == 8)
1752  {
1753  for (int b = 0; b < 8; ++b)
1754  {
1755  softwords_set(pout, rows * 0 + b, softword_get(accs[0], b));
1756  softwords_set(pout, rows * 1 + b, softword_get(accs[1], b));
1757  softwords_set(pout, rows * 2 + b, softword_get(accs[2], b));
1758  softwords_set(pout, rows * 3 + b, softword_get(accs[3], b));
1759  }
1760  ++pout;
1761  nacc = 0;
1762  }
1763  }
1764  }
1765  if (nacc != 2)
1766  fatal("Bug: Expected 2 leftover rows\n");
1767  // Pad with random symbol so that we can use accs[].
1768  for (int b = nacc; b < 8; ++b)
1769  split_symbol(pin->symbols[0], 4, accs, b, true);
1770  for (int b = 0; b < nacc; ++b)
1771  {
1772  softwords_set(pout, rows * 0 + b, softword_get(accs[0], b));
1773  softwords_set(pout, rows * 1 + b, softword_get(accs[1], b));
1774  softwords_set(pout, rows * 2 + b, softword_get(accs[2], b));
1775  softwords_set(pout, rows * 3 + b, softword_get(accs[3], b));
1776  }
1777  }
static void split_symbol(const llr_ss &ps, int bps, hard_sb accs[], int nacc, bool msb_first)
Definition: dvbs2.h:1781
void fatal(const char *s)
Definition: framework.cpp:6
void softwords_set(hard_sb p[], int b)
Definition: softword.h:50
bool softword_get(const hard_sb &p, int b)
Definition: softword.h:23
void softword_clear(hard_sb *p)
Definition: softword.h:32
+ Here is the call graph for this function:

◆ deserialize_qpsk()

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::deserialize_qpsk ( plslot< SOFTSYMB > *  pin,
int  nslots,
SOFTBYTE *  pout 
)
inlinestaticprivate

Definition at line 1601 of file dvbs2.h.

References leansdr::fail(), leansdr::fatal(), leansdr::plslot< SOFTSYMB >::LENGTH, leansdr::softword_clear(), and leansdr::plslot< SOFTSYMB >::symbols.

1603  {
1604  SOFTBYTE acc;
1605  softword_clear(&acc); // gcc warning
1606  int nacc = 0;
1607  for (; nslots; --nslots, ++pin)
1608  {
1609  SOFTSYMB *ps = pin->symbols;
1610  for (int ns = pin->LENGTH; ns--; ++ps)
1611  {
1612  pack_qpsk_symbol(*ps, &acc, nacc);
1613  nacc += 2;
1614  if (nacc == 8)
1615  { // TBD unroll
1616  *pout++ = acc;
1617  nacc = 0;
1618  }
1619  }
1620  }
1621  }
static void pack_qpsk_symbol(const llr_ss &ps, hard_sb *acc, int nacc)
Definition: dvbs2.h:1847
void softword_clear(hard_sb *p)
Definition: softword.h:32
+ Here is the call graph for this function:

◆ pack_qpsk_symbol() [1/2]

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::pack_qpsk_symbol ( const llr_ss ps,
hard_sb acc,
int  nacc 
)
inlinestaticprivate

Definition at line 1847 of file dvbs2.h.

References leansdr::llr_ss::bits, and leansdr::llr_harden().

1849  {
1850  // TBD Must match LLR law, see softsymb_harden.
1851  uint8_t s = llr_harden(ps.bits[0]) | (llr_harden(ps.bits[1]) << 1);
1852  *acc = (*acc << 2) | s;
1853  }
bool llr_harden(llr_t v)
Definition: sdr.h:446
unsigned char uint8_t
Definition: rtptypes_win.h:42
+ Here is the call graph for this function:

◆ pack_qpsk_symbol() [2/2]

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::pack_qpsk_symbol ( const llr_ss ps,
llr_sb acc,
int  nacc 
)
inlinestaticprivate

Definition at line 1856 of file dvbs2.h.

References leansdr::llr_sb::bits, and leansdr::llr_ss::bits.

1858  {
1859  acc->bits[nacc] = ps.bits[1];
1860  acc->bits[nacc + 1] = ps.bits[0];
1861  }

◆ run()

template<typename SOFTSYMB, typename SOFTBYTE>
void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 1568 of file dvbs2.h.

References leansdr::fecframe< SOFTBYTE >::bytes, leansdr::check_modcod(), leansdr::fail(), leansdr::FEC35, leansdr::s2_pls::framebits(), leansdr::plslot< SOFTSYMB >::is_pls, leansdr::s2_pls::modcod, leansdr::modcod_info::nslots_nf, leansdr::modcod_info::nsymbols, leansdr::plslot< SOFTSYMB >::pls, leansdr::fecframe< SOFTBYTE >::pls, leansdr::modcod_info::rate, leansdr::pipereader< T >::rd(), leansdr::pipereader< T >::read(), leansdr::pipereader< T >::readable(), leansdr::s2_pls::sf, leansdr::pipewriter< T >::wr(), leansdr::pipewriter< T >::writable(), and leansdr::pipewriter< T >::written().

1569  {
1570  while (in.readable() >= 1 && out.writable() >= 1)
1571  {
1572  plslot<SOFTSYMB> *pin = in.rd();
1573  if (!pin->is_pls)
1574  fail("s2_deinterleaver: bad input sequence");
1575  s2_pls *pls = &pin->pls;
1576  const modcod_info *mcinfo = check_modcod(pls->modcod);
1577  int nslots = pls->sf ? mcinfo->nslots_nf / 4 : mcinfo->nslots_nf;
1578  if (in.readable() < 1 + nslots)
1579  return;
1580  fecframe<SOFTBYTE> *pout = out.wr();
1581  pout->pls = *pls;
1582  SOFTBYTE *pbytes = pout->bytes;
1583  if (mcinfo->nsymbols == 4)
1584  deserialize_qpsk(pin + 1, nslots, pbytes);
1585  else
1586  {
1587  int bps = log2(mcinfo->nsymbols);
1588  int rows = pls->framebits() / bps;
1589  if (mcinfo->nsymbols == 8 && mcinfo->rate == FEC35)
1590  deinterleave(bps, rows, pin + 1, nslots, false, pbytes);
1591  else
1592  deinterleave(bps, rows, pin + 1, nslots, true, pbytes);
1593  }
1594  in.read(1 + nslots);
1595  out.written(1);
1596  }
1597  }
static void deinterleave(int bps, int rows, const plslot< SOFTSYMB > *pin, int nslots, bool msb_first, SOFTBYTE *pout)
Definition: dvbs2.h:1652
pipewriter< fecframe< SOFTBYTE > > out
Definition: dvbs2.h:1864
void fail(const char *s)
Definition: framework.cpp:11
pipereader< plslot< SOFTSYMB > > in
Definition: dvbs2.h:1863
static void deserialize_qpsk(plslot< SOFTSYMB > *pin, int nslots, SOFTBYTE *pout)
Definition: dvbs2.h:1601
const modcod_info * check_modcod(int m)
Definition: dvbs2.h:285
+ Here is the call graph for this function:

◆ split_symbol() [1/4]

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::split_symbol ( const llr_ss ps,
int  bps,
hard_sb  accs[],
int  nacc,
bool  msb_first 
)
inlinestaticprivate

Definition at line 1781 of file dvbs2.h.

References leansdr::llr_ss::bits, and leansdr::llr_harden().

1784  {
1785  if (msb_first)
1786  {
1787  for (int b = 0; b < bps; ++b)
1788  accs[b] = (accs[b] << 1) | llr_harden(ps.bits[bps - 1 - b]);
1789  }
1790  else
1791  {
1792  for (int b = 0; b < bps; ++b)
1793  accs[b] = (accs[b] << 1) | llr_harden(ps.bits[b]);
1794  }
1795  }
bool llr_harden(llr_t v)
Definition: sdr.h:446
+ Here is the call graph for this function:

◆ split_symbol() [2/4]

template<typename SOFTSYMB, typename SOFTBYTE>
template<int MSB_FIRST, int BPS>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::split_symbol ( const llr_ss ps,
hard_sb  accs[],
int  nacc 
)
inlinestaticprivate

Definition at line 1798 of file dvbs2.h.

References leansdr::llr_ss::bits, and leansdr::llr_harden().

1800  {
1801  if (MSB_FIRST)
1802  {
1803  for (int b = 0; b < BPS; ++b)
1804  accs[b] = (accs[b] << 1) | llr_harden(ps.bits[BPS - 1 - b]);
1805  }
1806  else
1807  {
1808  for (int b = 0; b < BPS; ++b)
1809  accs[b] = (accs[b] << 1) | llr_harden(ps.bits[b]);
1810  }
1811  }
bool llr_harden(llr_t v)
Definition: sdr.h:446
+ Here is the call graph for this function:

◆ split_symbol() [3/4]

template<typename SOFTSYMB, typename SOFTBYTE>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::split_symbol ( const llr_ss ps,
int  bps,
llr_sb  accs[],
int  nacc,
bool  msb_first 
)
inlinestaticprivate

Definition at line 1814 of file dvbs2.h.

References leansdr::llr_ss::bits.

1817  {
1818  if (msb_first)
1819  {
1820  for (int b = 0; b < bps; ++b)
1821  accs[b].bits[nacc] = ps.bits[bps - 1 - b];
1822  }
1823  else
1824  {
1825  for (int b = 0; b < bps; ++b)
1826  accs[b].bits[nacc] = ps.bits[b];
1827  }
1828  }

◆ split_symbol() [4/4]

template<typename SOFTSYMB, typename SOFTBYTE>
template<int MSB_FIRST, int BPS>
static void leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::split_symbol ( const llr_ss ps,
llr_sb  accs[],
int  nacc 
)
inlinestaticprivate

Definition at line 1831 of file dvbs2.h.

References leansdr::llr_ss::bits.

1833  {
1834  if (MSB_FIRST)
1835  {
1836  for (int b = 0; b < BPS; ++b)
1837  accs[b].bits[nacc] = ps.bits[BPS - 1 - b];
1838  }
1839  else
1840  {
1841  for (int b = 0; b < BPS; ++b)
1842  accs[b].bits[nacc] = ps.bits[b];
1843  }
1844  }

Member Data Documentation

◆ in

template<typename SOFTSYMB, typename SOFTBYTE>
pipereader<plslot<SOFTSYMB> > leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::in
private

Definition at line 1863 of file dvbs2.h.

◆ out

template<typename SOFTSYMB, typename SOFTBYTE>
pipewriter<fecframe<SOFTBYTE> > leansdr::s2_deinterleaver< SOFTSYMB, SOFTBYTE >::out
private

Definition at line 1864 of file dvbs2.h.


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