summaryrefslogtreecommitdiff
path: root/gr-dtv/lib/atsc
diff options
context:
space:
mode:
authorghostop14 <ghostop14@gmail.com>2020-02-01 13:02:34 -0500
committerdevnulling <devnulling@users.noreply.github.com>2020-02-04 09:08:55 -0800
commit90c8e30e87c935176224728d2a28709cb6a7adab (patch)
tree4a97b486b018e3de13962c08aba0e3f35a77fd15 /gr-dtv/lib/atsc
parent5b38e99298d47da94e4436d810db550d9e7e4520 (diff)
Fix ATSC Flowgraphs and Allow Realtime Viewing
The ATSC RX flowgraph has been fixed to allow for proper decoding. The original flowgraph had rate mismatches between the RX filter and the FPLL block that prevented proper decoding. This version also has a number of performance enhancements that ultimately allow the stream to be watched in real-time. These changes capitalize on new PRs for GR master branch. The ATSC RX filter was broken into its 2 respective parts (an RRC block and a resampler). The RRC block now uses the faster FFT RRC convenience wrapper, and the PFB arb resampler was crushing performance. So the sampling rate was adjusted to match the ATSC symbol rate*sps. This removed the need for a resampler altogether, significantly reducing CPU load. Processor core affinity based on a GRCon17 presentation was also applied to separate out blocks and prevent thread migration. Some cleanup was also done in the FPLL receiver block. Note that in using this in real-time, performance enhancements in PR 3076 that has not been merged into master yet are also important. The FPLL loop has some speedups due to the inlining of the NCO and sincos functions, and takes advantage of the already-merged cx_limited_range performance improvement in the FPLL loop too. An additional change to support fast CC multiply on systems that do not support the cx_limited_range compiler flag can be incorporated once 3076 is merged. This block also is better annotated for others to understand some of the design choices. Ultimately with the networking block in grnet, smplayer can be pointed at the flowgraph and TV watched in real-time. See the flowgraph for additional notes.
Diffstat (limited to 'gr-dtv/lib/atsc')
-rw-r--r--gr-dtv/lib/atsc/atsc_fpll_impl.cc33
1 files changed, 20 insertions, 13 deletions
diff --git a/gr-dtv/lib/atsc/atsc_fpll_impl.cc b/gr-dtv/lib/atsc/atsc_fpll_impl.cc
index 71f24713ac..b85a38207d 100644
--- a/gr-dtv/lib/atsc/atsc_fpll_impl.cc
+++ b/gr-dtv/lib/atsc/atsc_fpll_impl.cc
@@ -41,32 +41,39 @@ int atsc_fpll_impl::work(int noutput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items)
{
+ constexpr float alpha = 0.01;
+ constexpr float beta = alpha * alpha / 4.0;
+
const gr_complex* in = (const gr_complex*)input_items[0];
float* out = (float*)output_items[0];
+ float a_cos, a_sin;
+ float x;
+ gr_complex result, filtered;
for (int k = 0; k < noutput_items; k++) {
- float a_cos, a_sin;
-
d_nco.step(); // increment phase
d_nco.sincos(&a_sin, &a_cos); // compute cos and sin
// Mix out carrier and output I-only signal
- gr_complex result = in[k] * gr_complex(a_sin, a_cos);
+
+ // PR Merge Note: Once the Costas Optimization PR #3076 merges, this
+ // line below helps with performance when cx_limited_range is not available
+ // such as on Macs and Windows. Once the merge happens I'll push an update.
+ // gr::fast_cc_multiply(result, in[k], gr_complex(a_sin, a_cos));
+ result = in[k] * gr_complex(a_sin, a_cos);
+
out[k] = result.real();
// Update phase/freq error
- gr_complex filtered = d_afc.filter(result);
- float x = gr::fast_atan2f(filtered.imag(), filtered.real());
+ filtered = d_afc.filter(result);
+ x = gr::fast_atan2f(filtered.imag(), filtered.real());
// avoid slamming filter with big transitions
- static const float limit = GR_M_PI / 2.0;
- if (x > limit)
- x = limit;
- else if (x < -limit)
- x = -limit;
-
- static const float alpha = 0.01;
- static const float beta = alpha * alpha / 4.0;
+ if (x > M_PI_2)
+ x = M_PI_2;
+ else if (x < -M_PI_2)
+ x = -M_PI_2;
+
d_nco.adjust_phase(alpha * x);
d_nco.adjust_freq(beta * x);
}