commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/09: dtv: adds remainder of atsc receive


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/09: dtv: adds remainder of atsc receive pipeline
Date: Tue, 22 Jul 2014 19:33:56 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 658d778a41df89a34bd81e5ab79defc667b400a9
Author: Andrew Davis <address@hidden>
Date:   Mon Jun 9 14:51:34 2014 -0700

    dtv: adds remainder of atsc receive pipeline
    
    dtv::atsc_deinterleaver
    dtv::atsc_rs_decoder
    dtv::atsc_derandomizer
    dtv::atsc_depad
---
 gr-dtv/grc/CMakeLists.txt                          |   4 +
 gr-dtv/grc/dtv_atsc_deinterleaver.xml              |  25 ++++
 gr-dtv/grc/dtv_atsc_depad.xml                      |  24 ++++
 gr-dtv/grc/dtv_atsc_derandomizer.xml               |  25 ++++
 gr-dtv/grc/dtv_atsc_rs_decoder.xml                 |  25 ++++
 gr-dtv/grc/dtv_atsc_rx.xml                         |   1 -
 gr-dtv/include/gnuradio/dtv/CMakeLists.txt         |   4 +
 .../gnuradio/dtv/atsc_deinterleaver.h}             |  58 ++++-----
 .../gnuradio/dtv/atsc_depad.h}                     |  58 ++++-----
 .../gnuradio/dtv/atsc_derandomizer.h}              |  58 ++++-----
 .../gnuradio/dtv/atsc_rs_decoder.h}                |  57 ++++-----
 gr-dtv/lib/CMakeLists.txt                          |   7 ++
 gr-dtv/lib/atsc_deinterleaver_impl.cc              |  96 +++++++++++++++
 gr-dtv/lib/atsc_deinterleaver_impl.h               |  75 ++++++++++++
 gr-dtv/lib/atsc_depad_impl.cc                      |  68 +++++++++++
 gr-dtv/{swig/dtv_swig.i => lib/atsc_depad_impl.h}  |  40 +++----
 gr-dtv/lib/atsc_derandomizer_impl.cc               |  85 ++++++++++++++
 .../dtv_swig.i => lib/atsc_derandomizer_impl.h}    |  53 ++++-----
 gr-dtv/lib/atsc_randomize.cc                       | 117 +++++++++++++++++++
 gr-dtv/lib/atsc_randomize.h                        |  92 +++++++++++++++
 gr-dtv/lib/atsc_rs_decoder_impl.cc                 | 129 +++++++++++++++++++++
 gr-dtv/lib/atsc_rs_decoder_impl.h                  |  65 +++++++++++
 gr-dtv/lib/interleaver_fifo.h                      |  84 ++++++++++++++
 gr-dtv/python/dtv/atsc_rx.py                       |  18 ++-
 gr-dtv/swig/dtv_swig.i                             |  12 ++
 25 files changed, 1125 insertions(+), 155 deletions(-)

diff --git a/gr-dtv/grc/CMakeLists.txt b/gr-dtv/grc/CMakeLists.txt
index 21c8fe5..bd8d67a 100644
--- a/gr-dtv/grc/CMakeLists.txt
+++ b/gr-dtv/grc/CMakeLists.txt
@@ -18,9 +18,13 @@
 # Boston, MA 02110-1301, USA.
 
 install(FILES
+    dtv_atsc_deinterleaver.xml
+    dtv_atsc_depad.xml
+    dtv_atsc_derandomizer.xml
     dtv_atsc_equalizer.xml
     dtv_atsc_fpll.xml
     dtv_atsc_fs_checker.xml
+    dtv_atsc_rs_decoder.xml
     dtv_atsc_rx.xml
     dtv_atsc_rx_filter.xml
     dtv_atsc_sync.xml
diff --git a/gr-dtv/grc/dtv_atsc_deinterleaver.xml 
b/gr-dtv/grc/dtv_atsc_deinterleaver.xml
new file mode 100644
index 0000000..051ea77
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_deinterleaver.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Deinterleaver
+###################################################
+ -->
+<block>
+  <name>ATSC Deinterleaver</name>
+  <key>dtv_atsc_deinterleaver</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_deinterleaver()</make>
+
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </source>
+
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_depad.xml b/gr-dtv/grc/dtv_atsc_depad.xml
new file mode 100644
index 0000000..95a1380
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_depad.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Depad
+###################################################
+ -->
+<block>
+  <name>ATSC Depad</name>
+  <key>dtv_atsc_depad</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_depad()</make>
+
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>byte</type>
+  </source>
+
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_derandomizer.xml 
b/gr-dtv/grc/dtv_atsc_derandomizer.xml
new file mode 100644
index 0000000..5473f47
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_derandomizer.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Derandomizer
+###################################################
+ -->
+<block>
+  <name>ATSC Derandomizer</name>
+  <key>dtv_atsc_derandomizer</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_derandomizer()</make>
+
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </source>
+
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_rs_decoder.xml 
b/gr-dtv/grc/dtv_atsc_rs_decoder.xml
new file mode 100644
index 0000000..18a3053
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_rs_decoder.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Reed–Solomon Decoder
+###################################################
+ -->
+<block>
+  <name>ATSC Reed–Solomon Decoder</name>
+  <key>dtv_atsc_rs_decoder</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_rs_decoder()</make>
+
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </sink>
+
+  <source>
+    <name>out</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </source>
+
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_rx.xml b/gr-dtv/grc/dtv_atsc_rx.xml
index f32be01..9007696 100644
--- a/gr-dtv/grc/dtv_atsc_rx.xml
+++ b/gr-dtv/grc/dtv_atsc_rx.xml
@@ -30,7 +30,6 @@
   <source>
     <name>out</name>
     <type>byte</type>
-    <vlen>256</vlen>
   </source>
 
 </block>
diff --git a/gr-dtv/include/gnuradio/dtv/CMakeLists.txt 
b/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
index cf59661..d9a0142 100644
--- a/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
+++ b/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
@@ -23,9 +23,13 @@
 install(FILES
     api.h
     atsc_consts.h
+    atsc_deinterleaver.h
+    atsc_depad.h
+    atsc_derandomizer.h
     atsc_equalizer.h
     atsc_fpll.h
     atsc_fs_checker.h
+    atsc_rs_decoder.h
     atsc_sync.h
     atsc_viterbi_decoder.h
     DESTINATION ${GR_INCLUDE_DIR}/gnuradio/dtv
diff --git a/gr-dtv/swig/dtv_swig.i 
b/gr-dtv/include/gnuradio/dtv/atsc_deinterleaver.h
similarity index 50%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/include/gnuradio/dtv/atsc_deinterleaver.h
index 11cca69..658aa47 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/include/gnuradio/dtv/atsc_deinterleaver.h
@@ -20,29 +20,35 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "dtv_swig_doc.i"
-
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
-
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
-
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+#ifndef INCLUDED_DTV_ATSC_DEINTERLEAVER_H
+#define INCLUDED_DTV_ATSC_DEINTERLEAVER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief ATSC deinterleave RS encoded ATSC data ( 
atsc_mpeg_packet_rs_encoded --> atsc_mpeg_packet_rs_encoded)
+     * \ingroup dtv_atsc
+     *
+     * input: atsc_mpeg_packet_rs_encoded; output: atsc_mpeg_packet_rs_encoded
+     */
+    class DTV_API atsc_deinterleaver : virtual public gr::sync_block
+    {
+    public:
+
+      // gr::dtv::atsc_deinterleaver::sptr
+      typedef boost::shared_ptr<atsc_deinterleaver> sptr;
+
+      /*!
+       * \brief Make a new instance of gr::dtv::atsc_deinterleaver.
+       */
+      static sptr make();
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DEINTERLEAVER_H */
diff --git a/gr-dtv/swig/dtv_swig.i b/gr-dtv/include/gnuradio/dtv/atsc_depad.h
similarity index 53%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/include/gnuradio/dtv/atsc_depad.h
index 11cca69..4dfe21a 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/include/gnuradio/dtv/atsc_depad.h
@@ -20,29 +20,35 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "dtv_swig_doc.i"
-
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
-
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
-
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+#ifndef INCLUDED_DTV_ATSC_DEPAD_H
+#define INCLUDED_DTV_ATSC_DEPAD_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_interpolator.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief ATSC depad mpeg ts packets from 256 byte atsc_mpeg_packet to 188 
byte char
+     * \ingroup dtv_atsc
+     *
+     * input: atsc_mpeg_packet; output: unsigned char
+     */
+    class DTV_API atsc_depad : virtual public gr::sync_interpolator
+    {
+    public:
+
+      // gr::dtv::atsc_depad::sptr
+      typedef boost::shared_ptr<atsc_depad> sptr;
+
+      /*!
+       * \brief Make a new instance of gr::dtv::atsc_depad.
+       */
+      static sptr make();
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DEPAD_H */
diff --git a/gr-dtv/swig/dtv_swig.i 
b/gr-dtv/include/gnuradio/dtv/atsc_derandomizer.h
similarity index 52%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/include/gnuradio/dtv/atsc_derandomizer.h
index 11cca69..d941cae 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/include/gnuradio/dtv/atsc_derandomizer.h
@@ -20,29 +20,35 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "dtv_swig_doc.i"
-
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
-
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
-
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+#ifndef INCLUDED_DTV_ATSC_DERANDOMIZER_H
+#define INCLUDED_DTV_ATSC_DERANDOMIZER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief ATSC "dewhiten" incoming mpeg transport stream packets
+     * \ingroup dtv_atsc
+     *
+     * input: atsc_mpeg_packet_no_sync; output: atsc_mpeg_packet;
+     */
+    class DTV_API atsc_derandomizer : virtual public gr::sync_block
+    {
+    public:
+
+      // gr::dtv::atsc_derandomizer::sptr
+      typedef boost::shared_ptr<atsc_derandomizer> sptr;
+
+      /*!
+       * \brief Make a new instance of gr::dtv::atsc_derandomizer.
+       */
+      static sptr make();
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DERANDOMIZER_H */
diff --git a/gr-dtv/swig/dtv_swig.i 
b/gr-dtv/include/gnuradio/dtv/atsc_rs_decoder.h
similarity index 53%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/include/gnuradio/dtv/atsc_rs_decoder.h
index 11cca69..3f5c198 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/include/gnuradio/dtv/atsc_rs_decoder.h
@@ -20,29 +20,34 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "dtv_swig_doc.i"
-
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
-
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
-
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+#ifndef INCLUDED_DTV_ATSC_RS_DECODER_H
+#define INCLUDED_DTV_ATSC_RS_DECODER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief ATSC Receiver RS_DECODER
+     *
+     * \ingroup dtv_atsc
+     */
+    class DTV_API atsc_rs_decoder : virtual public gr::sync_block
+    {
+    public:
+
+      // gr::dtv::atsc_rs_decoder::sptr
+      typedef boost::shared_ptr<atsc_rs_decoder> sptr;
+
+      /*!
+       * \brief Make a new instance of gr::dtv::atsc_rs_decoder.
+       */
+      static sptr make();
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_RS_DECODER_H */
diff --git a/gr-dtv/lib/CMakeLists.txt b/gr-dtv/lib/CMakeLists.txt
index 7a4ea0f..23d6a98 100644
--- a/gr-dtv/lib/CMakeLists.txt
+++ b/gr-dtv/lib/CMakeLists.txt
@@ -25,6 +25,7 @@ include_directories(
     ${GR_DTV_INCLUDE_DIRS}
     ${GR_FILTER_INCLUDE_DIRS}
     ${GR_ANALOG_INCLUDE_DIRS}
+    ${GR_FEC_INCLUDE_DIRS}
     ${GNURADIO_RUNTIME_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
 )
@@ -58,9 +59,14 @@ add_custom_command(
 ########################################################################
 list(APPEND dtv_sources
   ${atsc_viterbi_mux_cc}
+  atsc_deinterleaver_impl.cc
+  atsc_depad_impl.cc
+  atsc_derandomizer_impl.cc
   atsc_equalizer_impl.cc
   atsc_fpll_impl.cc
   atsc_fs_checker_impl.cc
+  atsc_randomize.cc
+  atsc_rs_decoder_impl.cc
   atsc_sync_impl.cc
   atsc_fake_single_viterbi.cc
   atsc_single_viterbi.cc
@@ -76,6 +82,7 @@ list(APPEND dtv_libs
     gnuradio-runtime
     gnuradio-analog
     gnuradio-filter
+    gnuradio-fec
 )
 
 #Add Windows DLL resource file if using MSVC
diff --git a/gr-dtv/lib/atsc_deinterleaver_impl.cc 
b/gr-dtv/lib/atsc_deinterleaver_impl.cc
new file mode 100644
index 0000000..0d6d131
--- /dev/null
+++ b/gr-dtv/lib/atsc_deinterleaver_impl.cc
@@ -0,0 +1,96 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "atsc_deinterleaver_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+#include <gnuradio/io_signature.h>
+
+namespace gr {
+  namespace dtv {
+
+    atsc_deinterleaver::sptr
+    atsc_deinterleaver::make()
+    {
+      return gnuradio::get_initial_sptr
+       (new atsc_deinterleaver_impl());
+    }
+
+    atsc_deinterleaver_impl::atsc_deinterleaver_impl()
+        : gr::sync_block("atsc_deinterleaver",
+                    io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)),
+                    io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded))), alignment_fifo (156)
+    {
+      m_fifo.resize (52);
+
+      for (int i = 0; i < 52; i++)
+        m_fifo[52 - 1 - i] = new interleaver_fifo<unsigned char>(i * 4);
+
+      sync ();
+    }
+
+    atsc_deinterleaver_impl::~atsc_deinterleaver_impl()
+    {
+      for (int i = 0; i < 52; i++)
+        delete m_fifo[i];
+    }
+
+    void atsc_deinterleaver_impl::reset ()
+    {
+      sync ();
+      for (int i = 0; i < 52; i++)
+        m_fifo[i]->reset ();
+    }
+
+    int
+    atsc_deinterleaver_impl::work (int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+    {
+      const atsc_mpeg_packet_rs_encoded *in = (const 
atsc_mpeg_packet_rs_encoded *) input_items[0];
+      atsc_mpeg_packet_rs_encoded *out = (atsc_mpeg_packet_rs_encoded *) 
output_items[0];
+
+      for (int i = 0; i < noutput_items; i++){
+        assert (in[i].pli.regular_seg_p ());
+        plinfo::sanity_check (in[i].pli);
+
+        // reset commutator if required using INPUT pipeline info
+        if (in[i].pli.first_regular_seg_p ())
+          sync ();
+
+        // remap OUTPUT pipeline info to reflect 52 data segment end-to-end 
delay
+        plinfo::delay (out[i].pli, in[i].pli, 52);
+
+        // now do the actual deinterleaving
+        for (unsigned int j = 0; j < sizeof (in[i].data); j++){
+          out[i].data[j] = alignment_fifo.stuff (transform (in[i].data[j]));
+        }
+      }
+
+      return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
diff --git a/gr-dtv/lib/atsc_deinterleaver_impl.h 
b/gr-dtv/lib/atsc_deinterleaver_impl.h
new file mode 100644
index 0000000..2baf413
--- /dev/null
+++ b/gr-dtv/lib/atsc_deinterleaver_impl.h
@@ -0,0 +1,75 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_DTV_ATSC_DEINTERLEAVER_IMPL_H
+#define INCLUDED_DTV_ATSC_DEINTERLEAVER_IMPL_H
+
+#include <gnuradio/dtv/atsc_deinterleaver.h>
+#include "atsc_types.h"
+#include "interleaver_fifo.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_deinterleaver_impl : public atsc_deinterleaver
+    {
+    private:
+      //! transform a single symbol
+      unsigned char transform (unsigned char input){
+        unsigned char retval = m_fifo[m_commutator]->stuff (input);
+        m_commutator++;
+        if (m_commutator >= 52)
+          m_commutator = 0;
+        return retval;
+      }
+
+      /*!
+       * Note: The use of the alignment_fifo keeps the encoder and decoder
+       * aligned if both are synced to a field boundary.  There may be other
+       * ways to implement this function.  This is a best guess as to how
+       * this should behave, as we have no test vectors for either the
+       * interleaver or deinterleaver.
+       */
+      interleaver_fifo<unsigned char> alignment_fifo;
+
+      int m_commutator;
+      std::vector<interleaver_fifo<unsigned char> *> m_fifo;
+
+    public:
+      atsc_deinterleaver_impl();
+      ~atsc_deinterleaver_impl();
+
+      int work (int noutput_items,
+            gr_vector_const_void_star &input_items,
+            gr_vector_void_star &output_items);
+
+      //! reset interleaver (flushes contents and resets commutator)
+      void reset ();
+
+      //! sync interleaver (resets commutator, but doesn't flush fifos)
+      void sync () { m_commutator = 0; }
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DEINTERLEAVER_IMPL_H */
diff --git a/gr-dtv/lib/atsc_depad_impl.cc b/gr-dtv/lib/atsc_depad_impl.cc
new file mode 100644
index 0000000..9264b19
--- /dev/null
+++ b/gr-dtv/lib/atsc_depad_impl.cc
@@ -0,0 +1,68 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "atsc_depad_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+#include <gnuradio/io_signature.h>
+
+namespace gr {
+  namespace dtv {
+
+    atsc_depad::sptr
+    atsc_depad::make()
+    {
+      return gnuradio::get_initial_sptr
+       (new atsc_depad_impl());
+    }
+
+    atsc_depad_impl::atsc_depad_impl()
+      : gr::sync_interpolator("atsc_depad",
+                              io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet)),
+                              io_signature::make(1, 1, sizeof(unsigned char)),
+                              ATSC_MPEG_PKT_LENGTH)
+    {
+      reset();
+    }
+
+    int
+    atsc_depad_impl::work (int noutput_items,
+                    gr_vector_const_void_star &input_items,
+                    gr_vector_void_star &output_items)
+    {
+      const atsc_mpeg_packet *in = (const atsc_mpeg_packet *) input_items[0];
+      unsigned char *out = (unsigned char *) output_items[0];
+
+      int i;
+
+      for (i = 0; i < noutput_items/ATSC_MPEG_PKT_LENGTH; i++){
+        memcpy(&out[i * ATSC_MPEG_PKT_LENGTH], in[i].data, 
ATSC_MPEG_PKT_LENGTH);
+      }
+
+      return i * ATSC_MPEG_PKT_LENGTH;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
diff --git a/gr-dtv/swig/dtv_swig.i b/gr-dtv/lib/atsc_depad_impl.h
similarity index 53%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/lib/atsc_depad_impl.h
index 11cca69..81b3ab7 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/lib/atsc_depad_impl.h
@@ -20,29 +20,27 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
+#ifndef INCLUDED_DTV_ATSC_DEPAD_IMPL_H
+#define INCLUDED_DTV_ATSC_DEPAD_IMPL_H
 
-%include "gnuradio.i"
+#include <gnuradio/dtv/atsc_depad.h>
+#include "atsc_types.h"
 
-//load generated python docstrings
-%include "dtv_swig_doc.i"
+namespace gr {
+  namespace dtv {
 
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
+    class atsc_depad_impl : public atsc_depad
+    {
+    public:
+      atsc_depad_impl();
+      int work (int noutput_items,
+            gr_vector_const_void_star &input_items,
+            gr_vector_void_star &output_items);
 
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
+      void reset() { /* nop */ }
+    };
 
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DEPAD_IMPL_H */
diff --git a/gr-dtv/lib/atsc_derandomizer_impl.cc 
b/gr-dtv/lib/atsc_derandomizer_impl.cc
new file mode 100644
index 0000000..f62580b
--- /dev/null
+++ b/gr-dtv/lib/atsc_derandomizer_impl.cc
@@ -0,0 +1,85 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "atsc_derandomizer_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+#include <gnuradio/io_signature.h>
+
+namespace gr {
+  namespace dtv {
+
+    atsc_derandomizer::sptr
+    atsc_derandomizer::make()
+    {
+      return gnuradio::get_initial_sptr
+       (new atsc_derandomizer_impl());
+    }
+
+    atsc_derandomizer_impl::atsc_derandomizer_impl()
+      : gr::sync_block("dtv_atsc_derandomizer",
+                  io_signature::make(1, 1, sizeof(atsc_mpeg_packet_no_sync)),
+                  io_signature::make(1, 1, sizeof(atsc_mpeg_packet)))
+    {
+      reset();
+    }
+
+    void
+    atsc_derandomizer_impl::reset()
+    {
+      d_rand.reset();
+    }
+
+    int
+    atsc_derandomizer_impl::work (int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+    {
+      const atsc_mpeg_packet_no_sync *in = (const atsc_mpeg_packet_no_sync *) 
input_items[0];
+      atsc_mpeg_packet *out = (atsc_mpeg_packet *) output_items[0];
+
+      for (int i = 0; i < noutput_items; i++){
+
+        assert(in[i].pli.regular_seg_p());
+
+        if (in[i].pli.first_regular_seg_p())
+          d_rand.reset();
+
+        d_rand.derandomize(out[i], in[i]);
+
+        // Check the pipeline info for error status and and set the
+        // corresponding bit in transport packet header.
+
+        if (in[i].pli.transport_error_p())
+          out[i].data[1] |= MPEG_TRANSPORT_ERROR_BIT;
+        else
+          out[i].data[1] &= ~MPEG_TRANSPORT_ERROR_BIT;
+      }
+
+      return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
diff --git a/gr-dtv/swig/dtv_swig.i b/gr-dtv/lib/atsc_derandomizer_impl.h
similarity index 53%
copy from gr-dtv/swig/dtv_swig.i
copy to gr-dtv/lib/atsc_derandomizer_impl.h
index 11cca69..39a58e0 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/lib/atsc_derandomizer_impl.h
@@ -20,29 +20,30 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#define DTV_API
-
-%include "gnuradio.i"
-
-//load generated python docstrings
-%include "dtv_swig_doc.i"
-
-%{
-#include "gnuradio/dtv/atsc_equalizer.h"
-#include "gnuradio/dtv/atsc_fpll.h"
-#include "gnuradio/dtv/atsc_fs_checker.h"
-#include "gnuradio/dtv/atsc_sync.h"
-#include "gnuradio/dtv/atsc_viterbi_decoder.h"
-%}
-
-%include "gnuradio/dtv/atsc_equalizer.h"
-%include "gnuradio/dtv/atsc_fpll.h"
-%include "gnuradio/dtv/atsc_fs_checker.h"
-%include "gnuradio/dtv/atsc_sync.h"
-%include "gnuradio/dtv/atsc_viterbi_decoder.h"
-
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
-GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);
+#ifndef INCLUDED_DTV_ATSC_DERANDOMIZER_IMPL_H
+#define INCLUDED_DTV_ATSC_DERANDOMIZER_IMPL_H
+
+#include <gnuradio/dtv/atsc_derandomizer.h>
+#include "atsc_randomize.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_derandomizer_impl : public atsc_derandomizer
+    {
+    private:
+      atsc_randomize d_rand;
+
+    public:
+      atsc_derandomizer_impl();
+      int work (int noutput_items,
+            gr_vector_const_void_star &input_items,
+            gr_vector_void_star &output_items);
+
+      void reset();
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_DERANDOMIZER_IMPL_H */
diff --git a/gr-dtv/lib/atsc_randomize.cc b/gr-dtv/lib/atsc_randomize.cc
new file mode 100644
index 0000000..769b085
--- /dev/null
+++ b/gr-dtv/lib/atsc_randomize.cc
@@ -0,0 +1,117 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "atsc_randomize.h"
+
+namespace gr {
+  namespace dtv {
+
+    unsigned char atsc_randomize::s_output_map[1 << 14];
+    bool atsc_randomize::s_output_map_initialized_p = false;
+
+    atsc_randomize::atsc_randomize ()
+    {
+      d_state = PRELOAD_VALUE;
+
+      if (!s_output_map_initialized_p)
+        initialize_output_map ();
+    }
+
+    /*!
+     * \brief Generate the table used in the fast_output_map function.
+     *
+     * The table has 16K byte entries, but because of how is is used, only
+     * 256 entries end up being resident in the cache.  This seems
+     * like a good use of memory.  We can get away with a 16K table
+     * because the low two bits of the state do not affect the output
+     * function.  By shifting right those two bits we shrink the table,
+     * and also get better cache line utilization.
+     */
+    void
+    atsc_randomize::initialize_output_map ()
+    {
+      s_output_map_initialized_p = true;
+
+      for (int i = 0; i < (1 << 14); i++)
+        s_output_map[i] = slow_output_map (i << 2);
+    }
+
+
+    void
+    atsc_randomize::reset ()
+    {
+      d_state = PRELOAD_VALUE;
+    }
+
+    void
+    atsc_randomize::randomize (atsc_mpeg_packet_no_sync &out, const 
atsc_mpeg_packet &in)
+    {
+      assert (in.data[0] == MPEG_SYNC_BYTE);   // confirm it's there, then drop
+
+      for (int i = 0; i < ATSC_MPEG_DATA_LENGTH; i++)
+        out.data[i] = in.data[i + 1] ^ output_and_clk ();
+    }
+
+    void
+    atsc_randomize::derandomize (atsc_mpeg_packet &out, const 
atsc_mpeg_packet_no_sync &in)
+    {
+      out.data[0] = MPEG_SYNC_BYTE;            // add sync byte to beginning 
of packet
+
+      for (int i = 0; i < ATSC_MPEG_DATA_LENGTH; i++)
+        out.data[i + 1] = in.data[i] ^ output_and_clk ();
+    }
+
+
+    unsigned char
+    atsc_randomize::slow_output_map (int st)
+    {
+      int      output = 0;
+
+      if (st & 0x8000)
+        output |= 0x01;
+
+      if (st & 0x2000)
+        output |= 0x02;
+
+      if (st & 0x1000)
+        output |= 0x04;
+
+      if (st & 0x0200)
+        output |= 0x08;
+
+      if (st & 0x0020)
+        output |= 0x10;
+
+      if (st & 0x0010)
+        output |= 0x20;
+
+      if (st & 0x0008)
+        output |= 0x40;
+
+      if (st & 0x0004)
+        output |= 0x80;
+
+      return output;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
diff --git a/gr-dtv/lib/atsc_randomize.h b/gr-dtv/lib/atsc_randomize.h
new file mode 100644
index 0000000..0903240
--- /dev/null
+++ b/gr-dtv/lib/atsc_randomize.h
@@ -0,0 +1,92 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_ATSC_RANDOMIZE_H
+#define INCLUDED_ATSC_RANDOMIZE_H
+
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_randomize
+    {
+    public:
+      atsc_randomize();
+
+      /*! \brief reset randomizer LFSR
+       *
+       * must be called during the Data Segment Sync interval prior to the
+       * first data segment.  I.e., the LFSR is reset prior to the first
+       * field of each VSB data frame.
+       */
+      void reset ();
+
+      //! randomize (whiten) mpeg packet and remove leading MPEG-2 sync byte
+      void randomize (atsc_mpeg_packet_no_sync &out, const atsc_mpeg_packet 
&in);
+
+      //! derandomize (de-whiten) mpeg packet and add leading MPEG-2 sync byte
+      void derandomize (atsc_mpeg_packet &out, const atsc_mpeg_packet_no_sync 
&in);
+
+      unsigned int state() const { return d_state; }
+    private:
+      static void initialize_output_map ();
+      static unsigned char slow_output_map (int st);
+
+      static unsigned char fast_output_map (int st){
+        return s_output_map[(st & 0xb23c) >> 2]; // Magic const with 8 bits 
set improves cache
+                                                 // utilization.  The bits 
correspond to the taps
+                                                 // used in output 
calculation.  Others may be
+                                                 // safely ignored.
+      }
+
+      //! return current output value
+      unsigned char output (){
+        return fast_output_map (d_state);
+      }
+
+      //! clock LFSR; advance to next state.
+      void clk (){
+        if (d_state & 0x1)
+          d_state = ((d_state ^ MASK) >> 1) | 0x8000;
+        else
+          d_state = d_state >> 1;
+      }
+
+      //! return current output value and advance to next state
+      unsigned char output_and_clk (){
+        unsigned char r = output ();
+        clk ();
+        return r;
+      }
+
+      unsigned int                 d_state;
+
+      static const unsigned int PRELOAD_VALUE = 0x018f; /* 0xf180 bit reversed 
*/
+      static const unsigned int MASK = 0xa638;
+      static unsigned char         s_output_map[1 << 14];
+      static bool                  s_output_map_initialized_p;
+    };
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_ATSC_RANDOMIZE_H */
diff --git a/gr-dtv/lib/atsc_rs_decoder_impl.cc 
b/gr-dtv/lib/atsc_rs_decoder_impl.cc
new file mode 100644
index 0000000..890afde
--- /dev/null
+++ b/gr-dtv/lib/atsc_rs_decoder_impl.cc
@@ -0,0 +1,129 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "atsc_rs_decoder_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+#include <gnuradio/io_signature.h>
+
+namespace gr {
+  namespace dtv {
+
+    static const int rs_init_symsize =     8;
+    static const int rs_init_gfpoly  = 0x11d;
+    static const int rs_init_fcr     =     0;  // first consecutive root
+    static const int rs_init_prim    =     1;  // primitive is 1 (alpha)
+    static const int rs_init_nroots  =    20;
+
+    static const int N = (1 << rs_init_symsize) - 1;   // 255
+    static const int K = N - rs_init_nroots;           // 235
+
+    static const int amount_of_pad = N - ATSC_MPEG_RS_ENCODED_LENGTH;    // 48
+
+    atsc_rs_decoder::sptr
+    atsc_rs_decoder::make()
+    {
+      return gnuradio::get_initial_sptr
+       (new atsc_rs_decoder_impl());
+    }
+
+    atsc_rs_decoder_impl::atsc_rs_decoder_impl()
+      : gr::sync_block("dtv_atsc_rs_decoder",
+                  io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)),
+                  io_signature::make(1, 1, sizeof(atsc_mpeg_packet_no_sync)))
+    {
+      d_rs = init_rs_char (rs_init_symsize, rs_init_gfpoly, rs_init_fcr, 
rs_init_prim, rs_init_nroots);
+      assert (d_rs != 0);
+      nerrors_corrrected_count = 0;
+      bad_packet_count = 0;
+      total_packets = 0;
+      reset_counter = 0;
+      reset();
+    }
+
+    int atsc_rs_decoder_impl::decode (atsc_mpeg_packet_no_sync &out, const 
atsc_mpeg_packet_rs_encoded &in)
+    {
+      unsigned char tmp[N];
+      int ncorrections;
+
+      assert ((int)(amount_of_pad + sizeof (in.data)) == N);
+
+      // add missing prefix zero padding to message
+      memset (tmp, 0, amount_of_pad);
+      memcpy (&tmp[amount_of_pad], in.data, sizeof (in.data));
+
+      // correct message...
+      ncorrections = decode_rs_char (d_rs, tmp, 0, 0);
+
+      // copy corrected message to output, skipping prefix zero padding
+      memcpy (out.data, &tmp[amount_of_pad], sizeof (out.data));
+
+      return ncorrections;
+    }
+
+    atsc_rs_decoder_impl::~atsc_rs_decoder_impl()
+    {
+      if (d_rs)
+        free_rs_char (d_rs);
+      d_rs = 0;
+    }
+
+    int
+    atsc_rs_decoder_impl::work (int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+    {
+      const atsc_mpeg_packet_rs_encoded *in = (const 
atsc_mpeg_packet_rs_encoded *) input_items[0];
+      atsc_mpeg_packet_no_sync *out = (atsc_mpeg_packet_no_sync *) 
output_items[0];
+
+      for (int i = 0; i < noutput_items; i++){
+        assert(in[i].pli.regular_seg_p());
+        out[i].pli = in[i].pli;                        // copy pipeline info...
+
+        int nerrors_corrrected = decode(out[i], in[i]);
+        out[i].pli.set_transport_error(nerrors_corrrected == -1);
+        if( nerrors_corrrected == -1 )
+          bad_packet_count++;
+        else
+          nerrors_corrrected_count += nerrors_corrrected;
+      }
+
+      total_packets += noutput_items;
+      reset_counter++;
+
+      if( reset_counter > 100 )
+      {
+        std::cout << "Error rate: " << 
(float)nerrors_corrrected_count/total_packets << "\tPacket error rate: " << 
(float)bad_packet_count/total_packets << std::endl;
+        nerrors_corrrected_count = 0;
+        bad_packet_count = 0;
+        total_packets = 0;
+        reset_counter = 0;
+      }
+
+      return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
diff --git a/gr-dtv/lib/atsc_rs_decoder_impl.h 
b/gr-dtv/lib/atsc_rs_decoder_impl.h
new file mode 100644
index 0000000..b2f3a8c
--- /dev/null
+++ b/gr-dtv/lib/atsc_rs_decoder_impl.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_DTV_ATSC_RS_DECODER_IMPL_H
+#define INCLUDED_DTV_ATSC_RS_DECODER_IMPL_H
+
+#include <gnuradio/dtv/atsc_rs_decoder.h>
+#include "atsc_types.h"
+
+extern "C" {
+#include <gnuradio/fec/rs.h>
+}
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_rs_decoder_impl : public atsc_rs_decoder
+    {
+    private:
+      int nerrors_corrrected_count;
+      int bad_packet_count;
+      int total_packets;
+      int reset_counter;
+      void *d_rs;
+
+    public:
+      atsc_rs_decoder_impl();
+      ~atsc_rs_decoder_impl();
+
+      /*!
+       * Decode RS encoded packet.
+       * \returns a count of corrected symbols, or -1 if the block was 
uncorrectible.
+       */
+      int decode (atsc_mpeg_packet_no_sync &out, const 
atsc_mpeg_packet_rs_encoded &in);
+
+      int work (int noutput_items,
+            gr_vector_const_void_star &input_items,
+            gr_vector_void_star &output_items);
+
+      void reset() { /* nop */ }
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_DTV_ATSC_RS_DECODER_IMPL_H */
diff --git a/gr-dtv/lib/interleaver_fifo.h b/gr-dtv/lib/interleaver_fifo.h
new file mode 100644
index 0000000..c1e6e3a
--- /dev/null
+++ b/gr-dtv/lib/interleaver_fifo.h
@@ -0,0 +1,84 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2002 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _INTERLEAVER_FIFO_H_
+#define _INTERLEAVER_FIFO_H_
+
+#include <string.h>
+
+/*!
+ * \brief template class for interleaver fifo
+ */
+
+template<class symbol_type>
+class interleaver_fifo {
+ public:
+
+  interleaver_fifo (unsigned int size);
+  ~interleaver_fifo ();
+
+  //! reset interleaver (flushes contents and resets commutator)
+  void reset ();
+
+  //! stuff a symbol into the fifo and return the oldest
+  symbol_type stuff (symbol_type input){
+    if (m_size == 0)
+      return input;
+
+    symbol_type retval = m_fifo[m_position];
+    m_fifo[m_position] = input;
+    m_position++;
+    if (m_position >= m_size)
+      m_position = 0;
+
+    return retval;
+  }
+
+protected:
+  unsigned int m_size;
+  unsigned int m_position;
+  symbol_type  *m_fifo;
+};
+
+template<class symbol_type>
+interleaver_fifo<symbol_type>::interleaver_fifo (unsigned int size)
+{
+  m_size = size;
+  m_position = 0;
+  m_fifo = new symbol_type[size];
+  memset (m_fifo, 0, m_size * sizeof (symbol_type));
+}
+
+template<class symbol_type>
+interleaver_fifo<symbol_type>::~interleaver_fifo ()
+{
+  delete [] m_fifo;
+}
+
+template<class symbol_type> void
+interleaver_fifo<symbol_type>::reset ()
+{
+  m_position = 0;
+  memset (m_fifo, 0, m_size * sizeof (symbol_type));
+}
+
+#endif /* _INTERLEAVER_FIFO_H_ */
diff --git a/gr-dtv/python/dtv/atsc_rx.py b/gr-dtv/python/dtv/atsc_rx.py
index 063ee31..71e9f46 100644
--- a/gr-dtv/python/dtv/atsc_rx.py
+++ b/gr-dtv/python/dtv/atsc_rx.py
@@ -26,7 +26,7 @@ class atsc_rx(gr.hier_block2):
     def __init__(self, input_rate, sps):
         gr.hier_block2.__init__(self, "atsc_rx",
                                 gr.io_signature(1, 1, gr.sizeof_gr_complex), # 
Input signature
-                                gr.io_signature(1, 1, 256))                  # 
Output signature
+                                gr.io_signature(1, 1, gr.sizeof_char))       # 
Output signature
 
         # ATSC receiver filter/interpolator
         rx_filt = atsc_rx_filter(input_rate, sps)
@@ -36,7 +36,7 @@ class atsc_rx(gr.hier_block2):
         pll = dtv.atsc_fpll(output_rate)
 
         # Remove pilot tone now at DC
-        dcr = filter.dc_blocker_ff(128)
+        dcr = filter.dc_blocker_ff(1024)
 
         # Normalize signal to proper constellation amplitude
         agc = analog.agc_ff(1e-5, 4.0)
@@ -53,6 +53,18 @@ class atsc_rx(gr.hier_block2):
         # Remove convolutional trellis coding
         vit = dtv.atsc_viterbi_decoder()
 
+       # Remove convolutianal interleave
+       dei = dtv.atsc_deinterleaver()
+
+       # Reed-Solomon decode
+       rsd = dtv.atsc_rs_decoder()
+
+       # Derandomize MPEG2-TS packet
+       der = dtv.atsc_derandomizer()
+
+       # Remove padding from packet
+       dep = dtv.atsc_depad()
+
         # Connect pipeline
         self.connect(self, rx_filt, pll, dcr, agc, btl, fsc, equ)
-        self.connect(equ, vit, self)
+        self.connect(equ, vit, dei, rsd, der, dep, self)
diff --git a/gr-dtv/swig/dtv_swig.i b/gr-dtv/swig/dtv_swig.i
index 11cca69..91c910d 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/swig/dtv_swig.i
@@ -28,21 +28,33 @@
 %include "dtv_swig_doc.i"
 
 %{
+#include "gnuradio/dtv/atsc_deinterleaver.h"
+#include "gnuradio/dtv/atsc_depad.h"
+#include "gnuradio/dtv/atsc_derandomizer.h"
 #include "gnuradio/dtv/atsc_equalizer.h"
 #include "gnuradio/dtv/atsc_fpll.h"
 #include "gnuradio/dtv/atsc_fs_checker.h"
+#include "gnuradio/dtv/atsc_rs_decoder.h"
 #include "gnuradio/dtv/atsc_sync.h"
 #include "gnuradio/dtv/atsc_viterbi_decoder.h"
 %}
 
+%include "gnuradio/dtv/atsc_deinterleaver.h"
+%include "gnuradio/dtv/atsc_depad.h"
+%include "gnuradio/dtv/atsc_derandomizer.h"
 %include "gnuradio/dtv/atsc_equalizer.h"
 %include "gnuradio/dtv/atsc_fpll.h"
 %include "gnuradio/dtv/atsc_fs_checker.h"
+%include "gnuradio/dtv/atsc_rs_decoder.h"
 %include "gnuradio/dtv/atsc_sync.h"
 %include "gnuradio/dtv/atsc_viterbi_decoder.h"
 
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_deinterleaver);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_depad);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_derandomizer);
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_equalizer)
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fpll);
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_fs_checker);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_rs_decoder);
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_sync);
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_viterbi_decoder);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]