JS8Call-Improved master
Loading...
Searching...
No Matches
decoder_aided_redemod.h
Go to the documentation of this file.
1
31
32#pragma once
33
34#include <algorithm>
35#include <array>
36#include <cmath>
37#include <complex>
38#include <cstdint>
39#include <cstdlib>
40#include <functional>
41#include <limits>
42#include <numbers>
43#include <vector>
44
45namespace js8 {
46namespace aided {
47
49inline constexpr int kCodeBits = 174;
51inline constexpr int kDataSymbols = 58;
53inline constexpr int kTotalSymbols = 79;
55inline constexpr int kTones = 8;
56
58inline constexpr int kMaxSyndrome = 4;
59
61inline constexpr int kTimingDeltaMin = -2;
62inline constexpr int kTimingDeltaMax = 2;
63
65inline constexpr double kFreqStartHz = -0.5;
66inline constexpr double kFreqStepHz = 0.1;
67inline constexpr int kFreqSteps = 11;
68
70inline constexpr double kDriftValues[] = {-0.02, 0.0, 0.02};
71inline constexpr int kDriftSteps =
72 static_cast<int>(sizeof(kDriftValues) / sizeof(kDriftValues[0]));
73
78inline constexpr double kMinMetricGain = 1.005;
79
81inline constexpr double kConfidenceFloor = 0.5;
83inline constexpr double kConfidenceScale = 3.0;
84
86using CostasTones = std::array<std::array<int, 7>, 3>;
87
95inline bool redemodEnabled() {
96 return std::getenv("JS8_DISABLE_REDEMOD") == nullptr;
97}
98
105constexpr bool isCostasSymbol(int k) {
106 return (k >= 0 && k < 7) || (k >= 36 && k < 43) || (k >= 72 && k < 79);
107}
108
110constexpr int dataSymbolIndex(int j) {
111 return j < 29 ? j + 7 : j + 14;
112}
113
121inline void codewordToTones(std::array<int8_t, kCodeBits> const &cw,
122 CostasTones const &costas,
123 std::array<int, kTotalSymbols> &tones) {
124 for (int block = 0; block < 3; ++block)
125 for (int column = 0; column < 7; ++column)
126 tones[static_cast<std::size_t>(block * 36 + column)] =
127 costas[static_cast<std::size_t>(block)]
128 [static_cast<std::size_t>(column)];
129 for (int j = 0; j < kDataSymbols; ++j) {
130 int const b0 = cw[static_cast<std::size_t>(3 * j)] != 0 ? 1 : 0;
131 int const b1 = cw[static_cast<std::size_t>(3 * j + 1)] != 0 ? 1 : 0;
132 int const b2 = cw[static_cast<std::size_t>(3 * j + 2)] != 0 ? 1 : 0;
133 tones[static_cast<std::size_t>(dataSymbolIndex(j))] =
134 (b0 << 2) | (b1 << 1) | b2;
135 }
136}
137
140 std::array<float, kDataSymbols> weights{};
141 int used = 0;
142 double mean = 0.0;
143 double minAbsMin = 0.0;
144};
145
155tentativeConfidences(std::array<float, kCodeBits> const &llr) {
156 ConfidenceSummary out{};
157 double sum = 0.0;
158 bool haveMin = false;
159 for (int j = 0; j < kDataSymbols; ++j) {
160 float const v0 = llr[static_cast<std::size_t>(3 * j)];
161 float const v1 = llr[static_cast<std::size_t>(3 * j + 1)];
162 float const v2 = llr[static_cast<std::size_t>(3 * j + 2)];
163 double weight = 0.0;
164 if (std::isfinite(v0) && std::isfinite(v1) && std::isfinite(v2)) {
165 double const minAbs = std::min(
166 {std::abs(static_cast<double>(v0)),
167 std::abs(static_cast<double>(v1)),
168 std::abs(static_cast<double>(v2))});
169 if (!haveMin || minAbs < out.minAbsMin) {
170 out.minAbsMin = minAbs;
171 haveMin = true;
172 }
173 if (minAbs >= kConfidenceFloor) {
174 weight = (minAbs - kConfidenceFloor) /
176 weight = std::clamp(weight, 0.0, 1.0);
177 }
178 }
179 out.weights[static_cast<std::size_t>(j)] =
180 static_cast<float>(weight);
181 if (weight > 0.0) {
182 ++out.used;
183 sum += weight;
184 }
185 }
186 out.mean = out.used > 0 ? sum / out.used : 0.0;
187 return out;
188}
189
195inline void
197 std::array<float, kTotalSymbols> &weights) {
198 for (int k = 0; k < kTotalSymbols; ++k) {
199 if (isCostasSymbol(k)) {
200 weights[static_cast<std::size_t>(k)] = 1.0f;
201 continue;
202 }
203 // Data globals 7..35 -> j=k-7; globals 43..71 -> j=k-14.
204 int const j = k < 36 ? k - 7 : k - 14;
205 weights[static_cast<std::size_t>(k)] =
206 (j >= 0 && j < kDataSymbols)
207 ? conf.weights[static_cast<std::size_t>(j)]
208 : 0.0f;
209 }
210}
211
219inline void
220buildCostasWeights(std::array<float, kTotalSymbols> &weights) {
221 for (int k = 0; k < kTotalSymbols; ++k)
222 weights[static_cast<std::size_t>(k)] =
223 isCostasSymbol(k) ? 1.0f : 0.0f;
224}
225
236inline float aidedFrameXdt(float xdt2, int aidedDt,
237 float dtSecondsPerSample) {
238 if (!std::isfinite(xdt2) || !std::isfinite(dtSecondsPerSample))
239 return std::numeric_limits<float>::quiet_NaN();
240 return xdt2 + static_cast<float>(aidedDt) * dtSecondsPerSample;
241}
242
245 double residualHz = std::numeric_limits<double>::quiet_NaN();
246 double midpointSeconds = std::numeric_limits<double>::quiet_NaN();
247 double trackerHzAtMid = std::numeric_limits<double>::quiet_NaN();
248 bool valid = false;
249};
250
262 int startSamples = 0;
263 float trackerHz = 0.0f;
264};
265
289 double aidedDf, double aidedDd,
290 std::array<SymbolBaseline, kTotalSymbols> const &baselines, int window,
291 double sampleRateHz, std::array<float, kTotalSymbols> const &weights) {
292 MidpointResidual out{};
293 if (!std::isfinite(aidedDf) || !std::isfinite(aidedDd) || window <= 0 ||
294 !std::isfinite(sampleRateHz) || !(sampleRateHz > 0.0))
295 return out;
296 double tMin = std::numeric_limits<double>::infinity();
297 double tMax = -std::numeric_limits<double>::infinity();
298 double sw = 0.0, swt = 0.0, swtt = 0.0, swr = 0.0, swtr = 0.0;
299 for (int k = 0; k < kTotalSymbols; ++k) {
300 float const w = weights[static_cast<std::size_t>(k)];
301 if (!(w > 0.0f) || !std::isfinite(w))
302 continue;
303 double const tracker =
304 static_cast<double>(baselines[static_cast<std::size_t>(k)]
305 .trackerHz);
306 double const start =
307 static_cast<double>(baselines[static_cast<std::size_t>(k)]
308 .startSamples);
309 if (!std::isfinite(tracker) || !std::isfinite(start))
310 return out;
311 double const t = (start + window * 0.5) / sampleRateHz;
312 double const r = aidedDf + aidedDd * t - tracker;
313 if (!std::isfinite(t) || !std::isfinite(r))
314 return out;
315 tMin = std::min(tMin, t);
316 tMax = std::max(tMax, t);
317 double const dw = static_cast<double>(w);
318 sw += dw;
319 swt += dw * t;
320 swtt += dw * t * t;
321 swr += dw * r;
322 swtr += dw * t * r;
323 }
324 if (!(sw > 0.0) || !std::isfinite(sw) || !(tMax >= tMin) ||
325 !std::isfinite(tMin) || !std::isfinite(tMax))
326 return out;
327 double const tMid = 0.5 * (tMin + tMax);
328 double residual = std::numeric_limits<double>::quiet_NaN();
329 double const det = sw * swtt - swt * swt;
330 if (std::isfinite(det) && det > 0.0) {
331 double const a = (swr * swtt - swt * swtr) / det;
332 double const b = (sw * swtr - swt * swr) / det;
333 residual = a + b * tMid;
334 } else {
335 residual = swr / sw; // Degenerate (e.g. single point): plain mean.
336 }
337 if (!std::isfinite(residual))
338 return out;
339 out.residualHz = residual;
340 out.midpointSeconds = tMid;
341 out.trackerHzAtMid = aidedDf + aidedDd * tMid - residual;
342 out.valid = true;
343 return out;
344}
345
353inline bool
354symbolBoundsValid(std::array<SymbolBaseline, kTotalSymbols> const &baselines,
355 int window, int numSamples, int maxAbsDelta) {
356 if (window <= 0 || numSamples <= 0 || maxAbsDelta < 0)
357 return false;
358 for (auto const &base : baselines) {
359 long const first = static_cast<long>(base.startSamples) - maxAbsDelta;
360 long const last =
361 static_cast<long>(base.startSamples) + maxAbsDelta;
362 if (first < 0 || last < 0)
363 return false;
364 if (last + window > static_cast<long>(numSamples))
365 return false;
366 }
367 return true;
368}
369
383inline bool replayTrackerCorrection(std::complex<float> *window, int count,
384 double trackerHz, double sampleRateHz) {
385 if (window == nullptr || count <= 0 || !std::isfinite(trackerHz) ||
386 !std::isfinite(sampleRateHz) || !(sampleRateHz > 0.0))
387 return false;
388 double const dphi = 2.0 * std::numbers::pi * (trackerHz / sampleRateHz);
389 auto const wstep = std::polar(1.0f, static_cast<float>(dphi));
390 auto w = std::complex<float>{1.0f, 0.0f};
391 for (int i = 0; i < count; ++i) {
392 if (!std::isfinite(window[i].real()) ||
393 !std::isfinite(window[i].imag()))
394 return false;
395 w *= wstep;
396 window[i] *= w;
397 }
398 return true;
399}
400
410inline double contrastEight(double expectedPower,
411 double const *otherPowers) {
412 if (otherPowers == nullptr || !std::isfinite(expectedPower) ||
413 expectedPower < 0.0)
414 return std::numeric_limits<double>::quiet_NaN();
415 double sum = 0.0;
416 for (int t = 0; t < kTones - 1; ++t) {
417 if (!std::isfinite(otherPowers[t]) || otherPowers[t] < 0.0)
418 return std::numeric_limits<double>::quiet_NaN();
419 sum += otherPowers[t];
420 }
421 return expectedPower - sum / (kTones - 1);
422}
423
426 int deltaSamples = 0;
427 double deltaHz = 0.0;
428 double driftHzPerSec = 0.0;
429 double metric = std::numeric_limits<double>::quiet_NaN();
430};
431
435 double baselineMetric = std::numeric_limits<double>::quiet_NaN();
436 bool baselineFinite = false;
437 bool searched = false;
438 bool cancelled = false;
439 bool atBoundary = false;
440};
441
463inline Refinement refineSync(std::complex<float> const *samples,
464 int numSamples,
465 std::array<SymbolBaseline, kTotalSymbols> const
466 &baselines,
467 int window, double sampleRateHz,
468 std::array<int, kTotalSymbols> const &tones,
469 std::array<float, kTotalSymbols> const &weights,
470 std::function<bool()> const &shouldCancel = {}) {
471 Refinement out{};
472 auto const stop = [&] {
473 if (!shouldCancel || !shouldCancel())
474 return false;
475 out.cancelled = true;
476 out.searched = false;
477 return true;
478 };
479 if (stop())
480 return out;
481 if (samples == nullptr || numSamples <= 0 || window <= 0 || window > 32 ||
482 !std::isfinite(sampleRateHz) || !(sampleRateHz > 0.0))
483 return out;
484 if (!symbolBoundsValid(baselines, window, numSamples, kTimingDeltaMax))
485 return out;
486 for (int k = 0; k < kTotalSymbols; ++k) {
487 if (tones[static_cast<std::size_t>(k)] < 0 ||
488 tones[static_cast<std::size_t>(k)] >= kTones)
489 return out;
490 float const w = weights[static_cast<std::size_t>(k)];
491 if (!std::isfinite(w) || w < 0.0f)
492 return out;
493 // Used symbols need usable baseline metadata; unused ones are never
494 // touched, so their metadata may be anything.
495 if (w > 0.0f &&
496 !std::isfinite(
497 static_cast<double>(baselines[static_cast<std::size_t>(k)]
498 .trackerHz)))
499 return out;
500 }
501
502 // Forward-DFT twiddles for the 8 valid tones, computed once per call so
503 // the inner loop performs no per-tone trigonometry.
504 constexpr double twoPi = 2.0 * std::numbers::pi;
505 double twRe[kTones][32];
506 double twIm[kTones][32];
507 for (int tone = 0; tone < kTones; ++tone) {
508 for (int n = 0; n < window; ++n) {
509 double const angle =
510 -twoPi * static_cast<double>(tone * n) / window;
511 twRe[tone][n] = std::cos(angle);
512 twIm[tone][n] = std::sin(angle);
513 }
514 }
515
516#ifndef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
517 constexpr int timingChoices = kTimingDeltaMax - kTimingDeltaMin + 1;
518 struct CachedWindow {
519 std::array<std::complex<float>, 32> samples{};
520 bool usable = false;
521 };
522 // Keep the ~100 KiB cache off the decoder thread's stack. Only used
523 // symbols are populated; failed tracker replays remain skipped exactly
524 // as in the uncached scorer.
525 std::vector<CachedWindow> correctedWindows(
526 timingChoices * kTotalSymbols);
527 auto const cached = [&](int dt, int k) -> CachedWindow & {
528 return correctedWindows[static_cast<std::size_t>(
529 (dt - kTimingDeltaMin) * kTotalSymbols + k)];
530 };
531 auto const cacheTiming = [&](int dt) {
532 for (int k = 0; k < kTotalSymbols; ++k) {
533 if (!(weights[static_cast<std::size_t>(k)] > 0.0f))
534 continue;
535 int const start =
536 baselines[static_cast<std::size_t>(k)].startSamples + dt;
537 auto &entry = cached(dt, k);
538 for (int n = 0; n < window; ++n)
539 entry.samples[static_cast<std::size_t>(n)] = samples[start + n];
540 entry.usable = replayTrackerCorrection(
541 entry.samples.data(), window,
542 baselines[static_cast<std::size_t>(k)].trackerHz,
543 sampleRateHz);
544 }
545 };
546#endif
547
548 // Score one (timing, freq, drift) hypothesis with the weighted 8-tone
549 // contrast. The recorded tracker rotation is replayed first (baseline),
550 // then the candidate refinement derotation (absolute-time, matching the
551 // decoder's coarse correction sign convention).
552 auto const scoreHypothesis = [&](int dt, double df, double dd) {
553 double metric = 0.0;
554#ifdef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
555 std::complex<float> replayed[32];
556#endif
557 for (int k = 0; k < kTotalSymbols; ++k) {
558 float const w = weights[static_cast<std::size_t>(k)];
559 if (!(w > 0.0f))
560 continue;
561 int const start =
562 baselines[static_cast<std::size_t>(k)].startSamples + dt;
563#ifdef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
564 for (int n = 0; n < window; ++n)
565 replayed[n] = samples[start + n];
567 replayed, window,
568 baselines[static_cast<std::size_t>(k)].trackerHz,
569 sampleRateHz))
570#else
571 auto const &entry = cached(dt, k);
572 if (!entry.usable)
573#endif
574 continue;
575 double binRe[kTones] = {};
576 double binIm[kTones] = {};
577 for (int n = 0; n < window; ++n) {
578 double const t =
579 static_cast<double>(start + n) / sampleRateHz;
580 double const angle =
581 twoPi * df * t + std::numbers::pi * dd * t * t;
582 double const c = std::cos(angle);
583 double const s = std::sin(angle);
584#ifdef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
585 double const yr = static_cast<double>(replayed[n].real()) * c +
586 static_cast<double>(replayed[n].imag()) * s;
587 double const yi = static_cast<double>(replayed[n].imag()) * c -
588 static_cast<double>(replayed[n].real()) * s;
589#else
590 double const yr =
591 static_cast<double>(entry.samples[n].real()) * c +
592 static_cast<double>(entry.samples[n].imag()) * s;
593 double const yi =
594 static_cast<double>(entry.samples[n].imag()) * c -
595 static_cast<double>(entry.samples[n].real()) * s;
596#endif
597 for (int tone = 0; tone < kTones; ++tone) {
598 binRe[tone] += yr * twRe[tone][n] - yi * twIm[tone][n];
599 binIm[tone] += yi * twRe[tone][n] + yr * twIm[tone][n];
600 }
601 }
602 int const expected = tones[static_cast<std::size_t>(k)];
603 double const expPower =
604 binRe[expected] * binRe[expected] +
605 binIm[expected] * binIm[expected];
606 double others[kTones - 1];
607 int oi = 0;
608 for (int tone = 0; tone < kTones; ++tone) {
609 if (tone == expected)
610 continue;
611 others[oi++] =
612 binRe[tone] * binRe[tone] + binIm[tone] * binIm[tone];
613 }
614 double const cont = contrastEight(expPower, others);
615 if (!std::isfinite(cont))
616 continue;
617 metric += static_cast<double>(w) * cont;
618 }
619 return metric;
620 };
621
622#ifndef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
623 cacheTiming(0);
624#endif
625 out.baselineMetric = scoreHypothesis(0, 0.0, 0.0);
626 out.baselineFinite = std::isfinite(out.baselineMetric);
627 if (!out.baselineFinite)
628 return out;
629 out.searched = true;
630 out.best.metric = out.baselineMetric;
631 if (stop())
632 return out;
633
634#ifndef JS8_BENCHMARK_UNOPTIMIZED_HOTSPOTS
635 for (int d = kTimingDeltaMin; d <= kTimingDeltaMax; ++d)
636 if (d != 0)
637 cacheTiming(d);
638#endif
639
640 for (int dd = 0; dd < kDriftSteps; ++dd) {
641 for (int f = 0; f < kFreqSteps; ++f) {
642 double const df = kFreqStartHz + f * kFreqStepHz;
643 for (int d = kTimingDeltaMin; d <= kTimingDeltaMax; ++d) {
644 if (stop())
645 return out;
646 if (d == 0 && df == 0.0 && kDriftValues[dd] == 0.0)
647 continue; // Baseline already scored.
648 double const metric =
649 scoreHypothesis(d, df, kDriftValues[dd]);
650 if (std::isfinite(metric) && metric > out.best.metric) {
651 out.best.deltaSamples = d;
652 out.best.deltaHz = df;
653 out.best.driftHzPerSec = kDriftValues[dd];
654 out.best.metric = metric;
655 }
656 }
657 }
658 }
659
660 // Boundary check by grid index (exact; avoids float comparison). Only the
661 // timing and frequency dimensions participate: the drift grid is nearly
662 // unobservable in a per-symbol power metric (its within-symbol curvature
663 // is <= 6e-3 rad), so a drift edge pick usually just fine-tunes frequency
664 // between grid steps and must not veto an otherwise interior optimum. A
665 // wrong drift derotation is harmless downstream (negligible
666 // within-symbol smear; the Costas-only coherent fit absorbs the residual
667 // linear/quadratic trend), while timing/frequency edge picks indicate a
668 // runaway optimum outside the trusted box.
669 {
670 int const d = out.best.deltaSamples - kTimingDeltaMin;
671 int f = -1;
672 for (int i = 0; i < kFreqSteps; ++i)
673 if (kFreqStartHz + i * kFreqStepHz == out.best.deltaHz)
674 f = i;
675 out.atBoundary =
676 (d == 0 || d == (kTimingDeltaMax - kTimingDeltaMin) || f == 0 ||
677 f == kFreqSteps - 1);
678 }
679 return out;
680}
681
687inline bool refinementAccepted(Refinement const &r) {
688 if (!r.searched || r.cancelled || !std::isfinite(r.best.metric) ||
689 !r.baselineFinite)
690 return false;
691 if (r.atBoundary)
692 return false;
693 if (!(r.best.metric > r.baselineMetric))
694 return false;
695 if (r.baselineMetric > 0.0)
696 return r.best.metric >= r.baselineMetric * kMinMetricGain;
697 return r.best.metric > 0.0;
698}
699
701inline double metricGainDb(double refined, double baseline) {
702 if (!(refined > 0.0) || !(baseline > 0.0) ||
703 !std::isfinite(refined) || !std::isfinite(baseline))
704 return 0.0;
705 return 10.0 * std::log10(refined / baseline);
706}
707
709template <std::size_t NBlades>
710inline double llrNorm(std::array<float, NBlades> const &llr) {
711 double sum = 0.0;
712 for (float v : llr) {
713 if (std::isfinite(v))
714 sum += static_cast<double>(v) * v;
715 }
716 return std::sqrt(sum);
717}
718
719} // namespace aided
720} // namespace js8
constexpr double kMinMetricGain
Definition decoder_aided_redemod.h:78
constexpr double kFreqStartHz
Definition decoder_aided_redemod.h:65
constexpr int kDataSymbols
Definition decoder_aided_redemod.h:51
constexpr double kConfidenceFloor
Definition decoder_aided_redemod.h:81
constexpr int kCodeBits
Definition decoder_aided_redemod.h:49
Refinement refineSync(std::complex< float > const *samples, int numSamples, std::array< SymbolBaseline, kTotalSymbols > const &baselines, int window, double sampleRateHz, std::array< int, kTotalSymbols > const &tones, std::array< float, kTotalSymbols > const &weights, std::function< bool()> const &shouldCancel={})
Bounded local sync refinement around the first-pass solution.
Definition decoder_aided_redemod.h:463
void buildSymbolWeights(ConfidenceSummary const &conf, std::array< float, kTotalSymbols > &weights)
Expand 58 data confidences to 79 per-symbol weights.
Definition decoder_aided_redemod.h:196
void buildCostasWeights(std::array< float, kTotalSymbols > &weights)
Expand confidences to Costas-only weights (1.0 on pilots, else 0).
Definition decoder_aided_redemod.h:220
double llrNorm(std::array< float, NBlades > const &llr)
Definition decoder_aided_redemod.h:710
constexpr double kDriftValues[]
Definition decoder_aided_redemod.h:70
bool redemodEnabled()
Kill switch for decoder-aided re-demodulation.
Definition decoder_aided_redemod.h:95
MidpointResidual aidedPhysicalResidualAtMidpoint(double aidedDf, double aidedDd, std::array< SymbolBaseline, kTotalSymbols > const &baselines, int window, double sampleRateHz, std::array< float, kTotalSymbols > const &weights)
Physical carrier residual at the frame midpoint.
Definition decoder_aided_redemod.h:288
float aidedFrameXdt(float xdt2, int aidedDt, float dtSecondsPerSample)
Scalar frame timing seed from an aided timing delta.
Definition decoder_aided_redemod.h:236
ConfidenceSummary tentativeConfidences(std::array< float, kCodeBits > const &llr)
Confidence weight per tentative data symbol from its 3 bit LLRs.
Definition decoder_aided_redemod.h:155
bool symbolBoundsValid(std::array< SymbolBaseline, kTotalSymbols > const &baselines, int window, int numSamples, int maxAbsDelta)
Validate candidate sample bounds for the aided search/extraction.
Definition decoder_aided_redemod.h:354
bool refinementAccepted(Refinement const &r)
Safety gate: accept the refined sync only when it is finite, off the search boundary,...
Definition decoder_aided_redemod.h:687
constexpr int kTotalSymbols
Definition decoder_aided_redemod.h:53
double contrastEight(double expectedPower, double const *otherPowers)
Tone-CONTRAST metric from the actual 8 JS8 FSK bins.
Definition decoder_aided_redemod.h:410
constexpr int kTimingDeltaMin
Definition decoder_aided_redemod.h:61
constexpr double kConfidenceScale
Definition decoder_aided_redemod.h:83
std::array< std::array< int, 7 >, 3 > CostasTones
Definition decoder_aided_redemod.h:86
constexpr int kMaxSyndrome
Definition decoder_aided_redemod.h:58
bool replayTrackerCorrection(std::complex< float > *window, int count, double trackerHz, double sampleRateHz)
Replay one symbol's recorded FrequencyTracker correction.
Definition decoder_aided_redemod.h:383
constexpr int kTones
Definition decoder_aided_redemod.h:55
void codewordToTones(std::array< int8_t, kCodeBits > const &cw, CostasTones const &costas, std::array< int, kTotalSymbols > &tones)
Convert a tentative 174-bit codeword into 79 expected tones.
Definition decoder_aided_redemod.h:121
constexpr int dataSymbolIndex(int j)
Definition decoder_aided_redemod.h:110
constexpr bool isCostasSymbol(int k)
Whether global symbol k is a known Costas pilot.
Definition decoder_aided_redemod.h:105
double metricGainDb(double refined, double baseline)
Definition decoder_aided_redemod.h:701
JS8 namespace for Kalman filter-based trackers.
Definition bp_math.h:12
Definition decoder_aided_redemod.h:139
int used
Symbols with weight > 0.
Definition decoder_aided_redemod.h:141
std::array< float, kDataSymbols > weights
Per-symbol weight in [0,1].
Definition decoder_aided_redemod.h:140
double mean
Mean weight over USED symbols (0 if none).
Definition decoder_aided_redemod.h:142
double minAbsMin
Smallest min|LLR| observed (diagnostic).
Definition decoder_aided_redemod.h:143
Definition decoder_aided_redemod.h:425
double driftHzPerSec
Linear drift correction (Hz/s).
Definition decoder_aided_redemod.h:428
double deltaHz
Residual frequency correction (Hz).
Definition decoder_aided_redemod.h:427
int deltaSamples
Timing offset (downsampled samples).
Definition decoder_aided_redemod.h:426
Definition decoder_aided_redemod.h:244
Definition decoder_aided_redemod.h:433
bool cancelled
Incomplete searches can never be accepted.
Definition decoder_aided_redemod.h:438
Hypothesis best
Best hypothesis (baseline unless beaten strictly).
Definition decoder_aided_redemod.h:434
bool atBoundary
Best sits on the search box boundary.
Definition decoder_aided_redemod.h:439
bool searched
False when inputs were rejected up front.
Definition decoder_aided_redemod.h:437
First-pass per-symbol extraction metadata for the refinement baseline.
Definition decoder_aided_redemod.h:261
float trackerHz
Recorded tracker estimate for the symbol.
Definition decoder_aided_redemod.h:263
int startSamples
First-pass window start (base + shift).
Definition decoder_aided_redemod.h:262