<p>pespin <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-trx/+/14672">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sigProcLib: detectAnyBurst() family: Use struct to gather all out params<br><br>Currently we have 2 out parameters, but in forthcoming commits will add<br>a third one. All those functions already have too many parameters, so<br>let's put together all the output params in a struct to pass them easily<br>and make it easier to understand they are the estimated output values.<br><br>Related: OS#4006<br>Change-Id: I05cfa0ceaa2e633a5e6e404e2eae497ff4442dea<br>---<br>M Transceiver52M/Transceiver.cpp<br>M Transceiver52M/sigProcLib.cpp<br>M Transceiver52M/sigProcLib.h<br>3 files changed, 45 insertions(+), 45 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/Transceiver52M/Transceiver.cpp b/Transceiver52M/Transceiver.cpp</span><br><span>index 4462cdd..5c5707b 100644</span><br><span>--- a/Transceiver52M/Transceiver.cpp</span><br><span>+++ b/Transceiver52M/Transceiver.cpp</span><br><span>@@ -575,8 +575,8 @@</span><br><span> bool Transceiver::pullRadioVector(size_t chan, struct trx_ul_burst_ind *bi)</span><br><span> {</span><br><span>   int rc;</span><br><span style="color: hsl(0, 100%, 40%);">-  complex amp;</span><br><span style="color: hsl(0, 100%, 40%);">-  float toa, max = -1.0, avg = 0.0;</span><br><span style="color: hsl(120, 100%, 40%);">+  struct estim_burst_params ebp;</span><br><span style="color: hsl(120, 100%, 40%);">+  float max = -1.0, avg = 0.0;</span><br><span>   unsigned max_toa;</span><br><span>   int max_i = -1;</span><br><span>   signalVector *burst;</span><br><span>@@ -654,7 +654,7 @@</span><br><span>             mMaxExpectedDelayAB : mMaxExpectedDelayNB;</span><br><span> </span><br><span>   /* Detect normal or RACH bursts */</span><br><span style="color: hsl(0, 100%, 40%);">-  rc = detectAnyBurst(*burst, mTSC, BURST_THRESH, mSPSRx, type, amp, toa, max_toa);</span><br><span style="color: hsl(120, 100%, 40%);">+  rc = detectAnyBurst(*burst, mTSC, BURST_THRESH, mSPSRx, type, max_toa, &ebp);</span><br><span>   if (rc <= 0) {</span><br><span>     if (rc == -SIGERR_CLIP)</span><br><span>       LOG(WARNING) << "Clipping detected on received RACH or Normal Burst";</span><br><span>@@ -664,8 +664,8 @@</span><br><span>   }</span><br><span> </span><br><span>   type = (CorrType) rc;</span><br><span style="color: hsl(0, 100%, 40%);">-  bi->toa = toa;</span><br><span style="color: hsl(0, 100%, 40%);">-  rxBurst = demodAnyBurst(*burst, mSPSRx, amp, toa, type);</span><br><span style="color: hsl(120, 100%, 40%);">+  bi->toa = ebp.toa;</span><br><span style="color: hsl(120, 100%, 40%);">+  rxBurst = demodAnyBurst(*burst, mSPSRx, ebp.amp, ebp.toa, type);</span><br><span> </span><br><span>   /* EDGE demodulator returns 444 (gSlotLen * 3) bits */</span><br><span>   if (rxBurst->size() == EDGE_BURST_NBITS)</span><br><span>diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp</span><br><span>index cff7825..52a6701 100644</span><br><span>--- a/Transceiver52M/sigProcLib.cpp</span><br><span>+++ b/Transceiver52M/sigProcLib.cpp</span><br><span>@@ -1463,8 +1463,8 @@</span><br><span>  */</span><br><span> static int detectBurst(const signalVector &burst,</span><br><span>                        signalVector &corr, CorrelationSequence *sync,</span><br><span style="color: hsl(0, 100%, 40%);">-                       float thresh, int sps, complex *amp, float *toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                       int start, int len)</span><br><span style="color: hsl(120, 100%, 40%);">+                       float thresh, int sps, int start, int len,</span><br><span style="color: hsl(120, 100%, 40%);">+                       struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   const signalVector *corr_in;</span><br><span>   signalVector *dec = NULL;</span><br><span>@@ -1490,23 +1490,23 @@</span><br><span>   sps = 1;</span><br><span> </span><br><span>   /* Peak detection - place restrictions at correlation edges */</span><br><span style="color: hsl(0, 100%, 40%);">-  *amp = fastPeakDetect(corr, toa);</span><br><span style="color: hsl(120, 100%, 40%);">+  ebp->amp = fastPeakDetect(corr, &ebp->toa);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  if ((*toa < 3 * sps) || (*toa > len - 3 * sps))</span><br><span style="color: hsl(120, 100%, 40%);">+  if ((ebp->toa < 3 * sps) || (ebp->toa > len - 3 * sps))</span><br><span>     return 0;</span><br><span> </span><br><span>   /* Peak -to-average ratio */</span><br><span style="color: hsl(0, 100%, 40%);">-  if (computePeakRatio(&corr, sps, *toa, *amp) < thresh)</span><br><span style="color: hsl(120, 100%, 40%);">+  if (computePeakRatio(&corr, sps, ebp->toa, ebp->amp) < thresh)</span><br><span>     return 0;</span><br><span> </span><br><span>   /* Compute peak-to-average ratio. Reject if we don't have enough values */</span><br><span style="color: hsl(0, 100%, 40%);">-  *amp = peakDetect(corr, toa, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+  ebp->amp = peakDetect(corr, &ebp->toa, NULL);</span><br><span> </span><br><span>   /* Normalize our channel gain */</span><br><span style="color: hsl(0, 100%, 40%);">-  *amp = *amp / sync->gain;</span><br><span style="color: hsl(120, 100%, 40%);">+  ebp->amp = ebp->amp / sync->gain;</span><br><span> </span><br><span>   /* Compensate for residuate time lag */</span><br><span style="color: hsl(0, 100%, 40%);">-  *toa = *toa - sync->toa;</span><br><span style="color: hsl(120, 100%, 40%);">+  ebp->toa = ebp->toa - sync->toa;</span><br><span> </span><br><span>   return 1;</span><br><span> }</span><br><span>@@ -1532,13 +1532,10 @@</span><br><span>  *   head: Search symbols before target</span><br><span>  *   tail: Search symbols after target</span><br><span>  */</span><br><span style="color: hsl(0, 100%, 40%);">-static int detectGeneralBurst(const signalVector &rxBurst,</span><br><span style="color: hsl(0, 100%, 40%);">-                              float thresh,</span><br><span style="color: hsl(0, 100%, 40%);">-                              int sps,</span><br><span style="color: hsl(0, 100%, 40%);">-                              complex &amp,</span><br><span style="color: hsl(0, 100%, 40%);">-                              float &toa,</span><br><span style="color: hsl(120, 100%, 40%);">+static int detectGeneralBurst(const signalVector &rxBurst, float thresh, int sps,</span><br><span>                               int target, int head, int tail,</span><br><span style="color: hsl(0, 100%, 40%);">-                              CorrelationSequence *sync)</span><br><span style="color: hsl(120, 100%, 40%);">+                              CorrelationSequence *sync,</span><br><span style="color: hsl(120, 100%, 40%);">+                              struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   int rc, start, len;</span><br><span>   bool clipping = false;</span><br><span>@@ -1560,17 +1557,17 @@</span><br><span>   signalVector corr(len);</span><br><span> </span><br><span>   rc = detectBurst(rxBurst, corr, sync,</span><br><span style="color: hsl(0, 100%, 40%);">-                   thresh, sps, &amp, &toa, start, len);</span><br><span style="color: hsl(120, 100%, 40%);">+                   thresh, sps, start, len, ebp);</span><br><span>   if (rc < 0) {</span><br><span>     return -SIGERR_INTERNAL;</span><br><span>   } else if (!rc) {</span><br><span style="color: hsl(0, 100%, 40%);">-    amp = 0.0f;</span><br><span style="color: hsl(0, 100%, 40%);">-    toa = 0.0f;</span><br><span style="color: hsl(120, 100%, 40%);">+    ebp->amp = 0.0f;</span><br><span style="color: hsl(120, 100%, 40%);">+    ebp->toa = 0.0f;</span><br><span>     return clipping?-SIGERR_CLIP:SIGERR_NONE;</span><br><span>   }</span><br><span> </span><br><span>   /* Subtract forward search bits from delay */</span><br><span style="color: hsl(0, 100%, 40%);">-  toa -= head;</span><br><span style="color: hsl(120, 100%, 40%);">+  ebp->toa -= head;</span><br><span> </span><br><span>   return 1;</span><br><span> }</span><br><span>@@ -1585,7 +1582,7 @@</span><br><span>  *   tail: Search 8 symbols + maximum expected delay</span><br><span>  */</span><br><span> static int detectRACHBurst(const signalVector &burst, float threshold, int sps,</span><br><span style="color: hsl(0, 100%, 40%);">-                           complex &amplitude, float &toa, unsigned max_toa, bool ext)</span><br><span style="color: hsl(120, 100%, 40%);">+                           unsigned max_toa, bool ext, struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   int rc, target, head, tail;</span><br><span>   int i, num_seq;</span><br><span>@@ -1596,8 +1593,8 @@</span><br><span>   num_seq = ext ? 3 : 1;</span><br><span> </span><br><span>   for (i = 0; i < num_seq; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-    rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                            target, head, tail, gRACHSequences[i]);</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = detectGeneralBurst(burst, threshold, sps, target, head, tail,</span><br><span style="color: hsl(120, 100%, 40%);">+                            gRACHSequences[i], ebp);</span><br><span>     if (rc > 0)</span><br><span>       break;</span><br><span>   }</span><br><span>@@ -1614,7 +1611,7 @@</span><br><span>  *   tail: Search 6 symbols + maximum expected delay</span><br><span>  */</span><br><span> static int analyzeTrafficBurst(const signalVector &burst, unsigned tsc, float threshold,</span><br><span style="color: hsl(0, 100%, 40%);">-                               int sps, complex &amplitude, float &toa, unsigned max_toa)</span><br><span style="color: hsl(120, 100%, 40%);">+                               int sps, unsigned max_toa, struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   int rc, target, head, tail;</span><br><span>   CorrelationSequence *sync;</span><br><span>@@ -1627,13 +1624,12 @@</span><br><span>   tail = 6 + max_toa;</span><br><span>   sync = gMidambles[tsc];</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                          target, head, tail, sync);</span><br><span style="color: hsl(120, 100%, 40%);">+  rc = detectGeneralBurst(burst, threshold, sps, target, head, tail, sync, ebp);</span><br><span>   return rc;</span><br><span> }</span><br><span> </span><br><span> static int detectEdgeBurst(const signalVector &burst, unsigned tsc, float threshold,</span><br><span style="color: hsl(0, 100%, 40%);">-                           int sps, complex &amplitude, float &toa, unsigned max_toa)</span><br><span style="color: hsl(120, 100%, 40%);">+                           int sps, unsigned max_toa, struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   int rc, target, head, tail;</span><br><span>   CorrelationSequence *sync;</span><br><span>@@ -1646,33 +1642,30 @@</span><br><span>   tail = 6 + max_toa;</span><br><span>   sync = gEdgeMidambles[tsc];</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  rc = detectGeneralBurst(burst, threshold, sps, amplitude, toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                          target, head, tail, sync);</span><br><span style="color: hsl(120, 100%, 40%);">+  rc = detectGeneralBurst(burst, threshold, sps,</span><br><span style="color: hsl(120, 100%, 40%);">+                          target, head, tail, sync, ebp);</span><br><span>   return rc;</span><br><span> }</span><br><span> </span><br><span> int detectAnyBurst(const signalVector &burst, unsigned tsc, float threshold,</span><br><span style="color: hsl(0, 100%, 40%);">-                   int sps, CorrType type, complex &amp, float &toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                   unsigned max_toa)</span><br><span style="color: hsl(120, 100%, 40%);">+                   int sps, CorrType type, unsigned max_toa,</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct estim_burst_params *ebp)</span><br><span> {</span><br><span>   int rc = 0;</span><br><span> </span><br><span>   switch (type) {</span><br><span>   case EDGE:</span><br><span style="color: hsl(0, 100%, 40%);">-    rc = detectEdgeBurst(burst, tsc, threshold, sps,</span><br><span style="color: hsl(0, 100%, 40%);">-                         amp, toa, max_toa);</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = detectEdgeBurst(burst, tsc, threshold, sps, max_toa, ebp);</span><br><span>     if (rc > 0)</span><br><span>       break;</span><br><span>     else</span><br><span>       type = TSC;</span><br><span>   case TSC:</span><br><span style="color: hsl(0, 100%, 40%);">-    rc = analyzeTrafficBurst(burst, tsc, threshold, sps,</span><br><span style="color: hsl(0, 100%, 40%);">-                             amp, toa, max_toa);</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = analyzeTrafficBurst(burst, tsc, threshold, sps, max_toa, ebp);</span><br><span>     break;</span><br><span>   case EXT_RACH:</span><br><span>   case RACH:</span><br><span style="color: hsl(0, 100%, 40%);">-    rc = detectRACHBurst(burst, threshold, sps, amp, toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                         max_toa, type == EXT_RACH);</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = detectRACHBurst(burst, threshold, sps, max_toa, type == EXT_RACH, ebp);</span><br><span>     break;</span><br><span>   default:</span><br><span>     LOG(ERR) << "Invalid correlation type";</span><br><span>diff --git a/Transceiver52M/sigProcLib.h b/Transceiver52M/sigProcLib.h</span><br><span>index bae2127..8442cfc 100644</span><br><span>--- a/Transceiver52M/sigProcLib.h</span><br><span>+++ b/Transceiver52M/sigProcLib.h</span><br><span>@@ -101,15 +101,23 @@</span><br><span> */</span><br><span> float energyDetect(const signalVector &rxBurst,</span><br><span>                    unsigned windowLength);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/** Struct used to fill out parameters in detectAnyBurst(): estimated burst parameters</span><br><span style="color: hsl(120, 100%, 40%);">+@param amplitude The estimated amplitude of received TSC burst.</span><br><span style="color: hsl(120, 100%, 40%);">+@param toa The estimated time-of-arrival of received TSC burst (in symbols).</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+struct estim_burst_params {</span><br><span style="color: hsl(120, 100%, 40%);">+        complex amp;</span><br><span style="color: hsl(120, 100%, 40%);">+        float toa;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span> /**</span><br><span>         8-PSK/GMSK/RACH burst detector</span><br><span>         @param burst The received GSM burst of interest</span><br><span>         @param tsc Midamble type (0..7) also known as TSC</span><br><span>         @param threshold The threshold that the received burst's post-correlator SNR is compared against to determine validity.</span><br><span>         @param sps The number of samples per GSM symbol.</span><br><span style="color: hsl(0, 100%, 40%);">-        @param amplitude The estimated amplitude of received TSC burst.</span><br><span style="color: hsl(0, 100%, 40%);">-        @param toa The estimate time-of-arrival of received TSC burst (in symbols).</span><br><span>         @param max_toa The maximum expected time-of-arrival (in symbols).</span><br><span style="color: hsl(120, 100%, 40%);">+        @param ebp The estimated parameters of the detected burst.</span><br><span>         @return positive value (CorrType) if threshold value is reached,</span><br><span>                 negative value (-SignalError) on error,</span><br><span>                 zero (SIGERR_NONE) if no burst is detected</span><br><span>@@ -119,9 +127,8 @@</span><br><span>                    float threshold,</span><br><span>                    int sps,</span><br><span>                    CorrType type,</span><br><span style="color: hsl(0, 100%, 40%);">-                   complex &amp,</span><br><span style="color: hsl(0, 100%, 40%);">-                   float &toa,</span><br><span style="color: hsl(0, 100%, 40%);">-                   unsigned max_toa);</span><br><span style="color: hsl(120, 100%, 40%);">+                   unsigned max_toa,</span><br><span style="color: hsl(120, 100%, 40%);">+                   struct estim_burst_params *ebp);</span><br><span> </span><br><span> /** Demodulate burst basde on type and output soft bits */</span><br><span> SoftVector *demodAnyBurst(const signalVector &burst, int sps,</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-trx/+/14672">change 14672</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-trx/+/14672"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-trx </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I05cfa0ceaa2e633a5e6e404e2eae497ff4442dea </div>
<div style="display:none"> Gerrit-Change-Number: 14672 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>