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.
sdr.cpp
Go to the documentation of this file.
1 #include "sdr.h"
2 
3 namespace leansdr
4 {
5 
6 const char *cstln_base::names[] =
7  {
8  "BPSK",
9  "QPSK",
10  "8PSK",
11  "16APSK",
12  "32APSK",
13  "64APSKe",
14  "16QAM",
15  "64QAM",
16  "256QAM"
17  };
18 
19 
21 {
22  for (int b = 0; b < 8; ++b)
23  ss->bits[b] = (ss->bits[b] < 0) ? -127 : 127;
24 }
25 
27 {
28  (void)ss; // NOP
29 }
30 
32 {
33  for (int s = 0; s < ss->MAX_SYMBOLS; ++s)
34  ss->dists2[s] = (s == ss->nearest) ? 0 : 1;
35 }
36 
37 
38 uint8_t softsymb_to_dump(const llr_ss &ss, int bit)
39 {
40  return 128 - ss.bits[bit];
41 }
42 
43 uint8_t softsymb_to_dump(const hard_ss &ss, int bit)
44 {
45  return ((ss >> bit) & 1) ? 255 : 0;
46 }
47 
48 uint8_t softsymb_to_dump(const eucl_ss &ss, int bit)
49 {
50  (void)bit;
51  return ss.dists2[ss.nearest] >> 8;
52 }
53 
54 
55 void to_softsymb(const full_ss *fss, hard_ss *ss)
56 {
57  *ss = fss->nearest;
58 }
59 
60 void to_softsymb(const full_ss *fss, eucl_ss *ss)
61 {
62  for (int s = 0; s < ss->MAX_SYMBOLS; ++s)
63  ss->dists2[s] = fss->dists2[s];
64 
65  uint16_t best = 65535, best2 = 65535;
66 
67  for (int s = 0; s < ss->MAX_SYMBOLS; ++s)
68  {
69  if (fss->dists2[s] < best)
70  {
71  best2 = best;
72  best = fss->dists2[s];
73  }
74  else if (fss->dists2[s] < best2)
75  {
76  best2 = fss->dists2[s];
77  }
78  }
79 
80  ss->discr2 = best2 - best;
81  ss->nearest = fss->nearest;
82 }
83 
84 void to_softsymb(const full_ss *fss, llr_ss *ss)
85 {
86  for (int b = 0; b < 8; ++b)
87  {
88  float v = (1.0f - fss->p[b]) / (fss->p[b] + 1e-6);
89  int r = logf(v) * 5; // TBD Optimal scaling vs saturation ?
90  if (r < -127)
91  r = -127;
92  if (r > 127)
93  r = 127;
94  ss->bits[b] = r;
95  }
96 }
97 
98 } // leansdr
static const char * names[]
Definition: sdr.h:476
static const int MAX_SYMBOLS
Definition: sdr.h:433
void to_softsymb(const full_ss *fss, hard_ss *ss)
Definition: sdr.cpp:55
uint8_t nearest
Definition: sdr.h:409
uint16_t discr2
Definition: sdr.h:435
unsigned char uint8_t
Definition: rtptypes_win.h:42
void softsymb_harden(llr_ss *ss)
Definition: sdr.cpp:20
llr_t bits[8]
Definition: sdr.h:453
uint8_t softsymb_to_dump(const llr_ss &ss, int bit)
Definition: sdr.cpp:38
unsigned short uint16_t
Definition: rtptypes_win.h:44
uint16_t dists2[256]
Definition: sdr.h:410
uint8_t hard_ss
Definition: sdr.h:423
float p[8]
Definition: sdr.h:411
uint16_t dists2[MAX_SYMBOLS]
Definition: sdr.h:434
uint8_t nearest
Definition: sdr.h:436