commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/03: Add ATSC transmitter blocks and flow


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/03: Add ATSC transmitter blocks and flow graph to gr-dtv.
Date: Wed, 21 Jan 2015 21:18:26 +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 a8fbd0c6f0fef8da457fcf26f23991ef1237a5bb
Author: Ron Economos <address@hidden>
Date:   Tue Jan 20 18:56:31 2015 -0800

    Add ATSC transmitter blocks and flow graph to gr-dtv.
---
 gr-dtv/examples/file_atsc_tx.grc                   | 984 +++++++++++++++++++++
 gr-dtv/grc/CMakeLists.txt                          |   8 +-
 gr-dtv/grc/dtv_atsc_field_sync_mux.xml             |  22 +
 gr-dtv/grc/dtv_atsc_interleaver.xml                |  22 +
 gr-dtv/grc/dtv_atsc_pad.xml                        |  21 +
 gr-dtv/grc/dtv_atsc_randomizer.xml                 |  22 +
 gr-dtv/grc/dtv_atsc_rs_encoder.xml                 |  22 +
 gr-dtv/grc/dtv_atsc_trellis_encoder.xml            |  22 +
 gr-dtv/grc/dtv_block_tree.xml                      |   8 +-
 gr-dtv/include/gnuradio/dtv/CMakeLists.txt         |   8 +-
 gr-dtv/include/gnuradio/dtv/atsc_field_sync_mux.h  |  56 ++
 gr-dtv/include/gnuradio/dtv/atsc_interleaver.h     |  56 ++
 gr-dtv/include/gnuradio/dtv/atsc_pad.h             |  56 ++
 gr-dtv/include/gnuradio/dtv/atsc_randomizer.h      |  56 ++
 gr-dtv/include/gnuradio/dtv/atsc_rs_encoder.h      |  56 ++
 gr-dtv/include/gnuradio/dtv/atsc_trellis_encoder.h |  56 ++
 gr-dtv/lib/CMakeLists.txt                          |   9 +-
 gr-dtv/lib/atsc/atsc_basic_trellis_encoder.cc      |  65 ++
 gr-dtv/lib/atsc/atsc_basic_trellis_encoder.h       |  63 ++
 gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc        | 243 +++++
 gr-dtv/lib/atsc/atsc_field_sync_mux_impl.h         |  60 ++
 gr-dtv/lib/atsc/atsc_interleaver_impl.cc           | 122 +++
 gr-dtv/lib/atsc/atsc_interleaver_impl.h            |  51 ++
 gr-dtv/lib/atsc/atsc_pad_impl.cc                   |  74 ++
 gr-dtv/lib/atsc/atsc_pad_impl.h                    |  45 +
 gr-dtv/lib/atsc/atsc_randomizer_impl.cc            | 106 +++
 gr-dtv/lib/atsc/atsc_randomizer_impl.h             |  53 ++
 gr-dtv/lib/atsc/atsc_rs_encoder_impl.cc            | 112 +++
 gr-dtv/lib/atsc/atsc_rs_encoder_impl.h             |  54 ++
 gr-dtv/lib/atsc/atsc_trellis_encoder_impl.cc       | 264 ++++++
 gr-dtv/lib/atsc/atsc_trellis_encoder_impl.h        |  60 ++
 gr-dtv/swig/dtv_swig.i                             |  20 +-
 32 files changed, 2871 insertions(+), 5 deletions(-)

diff --git a/gr-dtv/examples/file_atsc_tx.grc b/gr-dtv/examples/file_atsc_tx.grc
new file mode 100644
index 0000000..f212ab3
--- /dev/null
+++ b/gr-dtv/examples/file_atsc_tx.grc
@@ -0,0 +1,984 @@
+<?xml version='1.0' encoding='ASCII'?>
+<?grc format='1' created='3.7.7'?>
+<flow_graph>
+  <timestamp>Sat Jan 17 12:37:25 2015</timestamp>
+  <block>
+    <key>options</key>
+    <param>
+      <key>id</key>
+      <value>file_atsc_tx</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value></value>
+    </param>
+    <param>
+      <key>author</key>
+      <value></value>
+    </param>
+    <param>
+      <key>description</key>
+      <value></value>
+    </param>
+    <param>
+      <key>window_size</key>
+      <value>1280, 1024</value>
+    </param>
+    <param>
+      <key>generate_options</key>
+      <value>wx_gui</value>
+    </param>
+    <param>
+      <key>category</key>
+      <value>Custom</value>
+    </param>
+    <param>
+      <key>run_options</key>
+      <value>prompt</value>
+    </param>
+    <param>
+      <key>run</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>max_nouts</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>realtime_scheduling</key>
+      <value></value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(584, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>symbol_rate</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>4500000.0 / 286 * 684</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(360, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>variable</key>
+    <param>
+      <key>id</key>
+      <value>pilot_freq</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>value</key>
+      <value>309441</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(472, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_pad</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_pad_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(96, 112)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_randomizer</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_randomizer_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(72, 168)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_rs_encoder</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_rs_encoder_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(72, 224)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_keep_m_in_n</key>
+    <param>
+      <key>id</key>
+      <value>blocks_keep_m_in_n_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>m</key>
+      <value>832</value>
+    </param>
+    <param>
+      <key>n</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>offset</key>
+      <value>4</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(80, 515)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>digital_chunks_to_symbols_xx</key>
+    <param>
+      <key>id</key>
+      <value>digital_chunks_to_symbols_xx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>in_type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>out_type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>symbol_table</key>
+      <value>[symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]</value>
+    </param>
+    <param>
+      <key>dimension</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>num_ports</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(360, 523)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_multiply_xx</key>
+    <param>
+      <key>id</key>
+      <value>blocks_multiply_xx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>num_inputs</key>
+      <value>2</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(376, 296)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>analog_sig_source_x</key>
+    <param>
+      <key>id</key>
+      <value>analog_sig_source_x_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>symbol_rate</value>
+    </param>
+    <param>
+      <key>waveform</key>
+      <value>analog.GR_COS_WAVE</value>
+    </param>
+    <param>
+      <key>freq</key>
+      <value>-3000000+pilot_freq</value>
+    </param>
+    <param>
+      <key>amp</key>
+      <value>0.9</value>
+    </param>
+    <param>
+      <key>offset</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(416, 131)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>fft_filter_xxx</key>
+    <param>
+      <key>id</key>
+      <value>fft_filter_xxx_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>ccc</value>
+    </param>
+    <param>
+      <key>decim</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>taps</key>
+      <value>firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate/2, 
0.1152, 100)</value>
+    </param>
+    <param>
+      <key>samp_delay</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>nthreads</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(576, 291)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>wxgui_fftsink2</key>
+    <param>
+      <key>id</key>
+      <value>wxgui_fftsink2_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>title</key>
+      <value>FFT Plot</value>
+    </param>
+    <param>
+      <key>samp_rate</key>
+      <value>symbol_rate</value>
+    </param>
+    <param>
+      <key>baseband_freq</key>
+      <value>429000000</value>
+    </param>
+    <param>
+      <key>y_per_div</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>y_divs</key>
+      <value>10</value>
+    </param>
+    <param>
+      <key>ref_level</key>
+      <value>-10</value>
+    </param>
+    <param>
+      <key>ref_scale</key>
+      <value>2.0</value>
+    </param>
+    <param>
+      <key>fft_size</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>fft_rate</key>
+      <value>15</value>
+    </param>
+    <param>
+      <key>peak_hold</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>average</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>avg_alpha</key>
+      <value>0.1333</value>
+    </param>
+    <param>
+      <key>win</key>
+      <value>None</value>
+    </param>
+    <param>
+      <key>win_size</key>
+      <value>800,600</value>
+    </param>
+    <param>
+      <key>grid_pos</key>
+      <value></value>
+    </param>
+    <param>
+      <key>notebook</key>
+      <value></value>
+    </param>
+    <param>
+      <key>freqvar</key>
+      <value>None</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1048, 331)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_interleaver</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_interleaver_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(72, 280)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_throttle</key>
+    <param>
+      <key>id</key>
+      <value>blocks_throttle_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>samples_per_second</key>
+      <value>symbol_rate</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>ignoretag</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(808, 307)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_file_sink</key>
+    <param>
+      <key>id</key>
+      <value>blocks_file_sink_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>file</key>
+      <value>atsc.cfile</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>complex</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>unbuffered</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>append</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(1048, 171)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_trellis_encoder</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_trellis_encoder_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(64, 336)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_vector_to_stream</key>
+    <param>
+      <key>id</key>
+      <value>blocks_vector_to_stream_1</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>num_items</key>
+      <value>1024</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(72, 451)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>180</value>
+    </param>
+  </block>
+  <block>
+    <key>dtv_atsc_field_sync_mux</key>
+    <param>
+      <key>id</key>
+      <value>dtv_atsc_field_sync_mux_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(64, 392)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <block>
+    <key>blocks_file_source</key>
+    <param>
+      <key>id</key>
+      <value>blocks_file_source_0</value>
+    </param>
+    <param>
+      <key>_enabled</key>
+      <value>True</value>
+    </param>
+    <param>
+      <key>file</key>
+      <value>test.ts</value>
+    </param>
+    <param>
+      <key>type</key>
+      <value>byte</value>
+    </param>
+    <param>
+      <key>repeat</key>
+      <value>False</value>
+    </param>
+    <param>
+      <key>vlen</key>
+      <value>1</value>
+    </param>
+    <param>
+      <key>alias</key>
+      <value></value>
+    </param>
+    <param>
+      <key>affinity</key>
+      <value></value>
+    </param>
+    <param>
+      <key>minoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>maxoutbuf</key>
+      <value>0</value>
+    </param>
+    <param>
+      <key>_coordinate</key>
+      <value>(48, 19)</value>
+    </param>
+    <param>
+      <key>_rotation</key>
+      <value>0</value>
+    </param>
+  </block>
+  <connection>
+    <source_block_id>blocks_vector_to_stream_1</source_block_id>
+    <sink_block_id>blocks_keep_m_in_n_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_keep_m_in_n_0</source_block_id>
+    <sink_block_id>digital_chunks_to_symbols_xx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_multiply_xx_0</source_block_id>
+    <sink_block_id>fft_filter_xxx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>analog_sig_source_x_0</source_block_id>
+    <sink_block_id>blocks_multiply_xx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id>
+    <sink_block_id>blocks_multiply_xx_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>1</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>fft_filter_xxx_0</source_block_id>
+    <sink_block_id>blocks_throttle_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_throttle_0</source_block_id>
+    <sink_block_id>wxgui_fftsink2_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_file_source_0</source_block_id>
+    <sink_block_id>dtv_atsc_pad_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_pad_0</source_block_id>
+    <sink_block_id>dtv_atsc_randomizer_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_randomizer_0</source_block_id>
+    <sink_block_id>dtv_atsc_rs_encoder_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_rs_encoder_0</source_block_id>
+    <sink_block_id>dtv_atsc_interleaver_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_interleaver_0</source_block_id>
+    <sink_block_id>dtv_atsc_trellis_encoder_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>blocks_throttle_0</source_block_id>
+    <sink_block_id>blocks_file_sink_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_trellis_encoder_0</source_block_id>
+    <sink_block_id>dtv_atsc_field_sync_mux_0</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+  <connection>
+    <source_block_id>dtv_atsc_field_sync_mux_0</source_block_id>
+    <sink_block_id>blocks_vector_to_stream_1</sink_block_id>
+    <source_key>0</source_key>
+    <sink_key>0</sink_key>
+  </connection>
+</flow_graph>
diff --git a/gr-dtv/grc/CMakeLists.txt b/gr-dtv/grc/CMakeLists.txt
index bd8d67a..146c5b4 100644
--- a/gr-dtv/grc/CMakeLists.txt
+++ b/gr-dtv/grc/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2014 Free Software Foundation, Inc.
+# Copyright 2014,2015 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -30,6 +30,12 @@ install(FILES
     dtv_atsc_sync.xml
     dtv_atsc_viterbi_decoder.xml
     dtv_block_tree.xml
+    dtv_atsc_pad.xml
+    dtv_atsc_randomizer.xml
+    dtv_atsc_rs_encoder.xml
+    dtv_atsc_interleaver.xml
+    dtv_atsc_trellis_encoder.xml
+    dtv_atsc_field_sync_mux.xml
     DESTINATION ${GRC_BLOCKS_DIR}
     COMPONENT "dtv_python"
 )
diff --git a/gr-dtv/grc/dtv_atsc_field_sync_mux.xml 
b/gr-dtv/grc/dtv_atsc_field_sync_mux.xml
new file mode 100644
index 0000000..0037a93
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_field_sync_mux.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Field Sync Mux
+###################################################
+ -->
+<block>
+  <name>ATSC Field Sync Mux</name>
+  <key>dtv_atsc_field_sync_mux</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_field_sync_mux()</make>
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </sink>
+  <source>
+    <name>out</name>
+    <type>byte</type>
+    <vlen>1024</vlen>
+  </source>
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_interleaver.xml 
b/gr-dtv/grc/dtv_atsc_interleaver.xml
new file mode 100644
index 0000000..3b1045c
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_interleaver.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Interleaver
+###################################################
+ -->
+<block>
+  <name>ATSC Interleaver</name>
+  <key>dtv_atsc_interleaver</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_interleaver()</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_pad.xml b/gr-dtv/grc/dtv_atsc_pad.xml
new file mode 100644
index 0000000..87b8921
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_pad.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Pad
+###################################################
+ -->
+<block>
+  <name>ATSC Pad</name>
+  <key>dtv_atsc_pad</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_pad()</make>
+  <sink>
+    <name>in</name>
+    <type>byte</type>
+  </sink>
+  <source>
+    <name>out</name>
+    <type>byte</type>
+    <vlen>256</vlen>
+  </source>
+</block>
diff --git a/gr-dtv/grc/dtv_atsc_randomizer.xml 
b/gr-dtv/grc/dtv_atsc_randomizer.xml
new file mode 100644
index 0000000..73c0991
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_randomizer.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Randomizer
+###################################################
+ -->
+<block>
+  <name>ATSC Randomizer</name>
+  <key>dtv_atsc_randomizer</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_randomizer()</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_encoder.xml 
b/gr-dtv/grc/dtv_atsc_rs_encoder.xml
new file mode 100644
index 0000000..af35523
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_rs_encoder.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Reed-Solomom Encoder
+###################################################
+ -->
+<block>
+  <name>ATSC RS Encoder</name>
+  <key>dtv_atsc_rs_encoder</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_rs_encoder()</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_trellis_encoder.xml 
b/gr-dtv/grc/dtv_atsc_trellis_encoder.xml
new file mode 100644
index 0000000..2189075
--- /dev/null
+++ b/gr-dtv/grc/dtv_atsc_trellis_encoder.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## ATSC Trellis Encoder
+###################################################
+ -->
+<block>
+  <name>ATSC Trellis Encoder</name>
+  <key>dtv_atsc_trellis_encoder</key>
+  <import>from gnuradio import dtv</import>
+  <make>dtv.atsc_trellis_encoder()</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_block_tree.xml b/gr-dtv/grc/dtv_block_tree.xml
index 8b84c36..72e8ebf 100644
--- a/gr-dtv/grc/dtv_block_tree.xml
+++ b/gr-dtv/grc/dtv_block_tree.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 
 <!--
- Copyright 2014 Free Software Foundation, Inc.
+ Copyright 2014,2015 Free Software Foundation, Inc.
 
  This file is part of GNU Radio
 
@@ -43,6 +43,12 @@
       <block>dtv_atsc_rx_filter</block>
       <block>dtv_atsc_sync</block>
       <block>dtv_atsc_viterbi_decoder</block>
+      <block>dtv_atsc_pad</block>
+      <block>dtv_atsc_randomizer</block>
+      <block>dtv_atsc_rs_encoder</block>
+      <block>dtv_atsc_interleaver</block>
+      <block>dtv_atsc_trellis_encoder</block>
+      <block>dtv_atsc_field_sync_mux</block>
     </cat>
   </cat>
 </cat>
diff --git a/gr-dtv/include/gnuradio/dtv/CMakeLists.txt 
b/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
index d9a0142..8aff3eb 100644
--- a/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
+++ b/gr-dtv/include/gnuradio/dtv/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2014 Free Software Foundation, Inc.
+# Copyright 2014,2015 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -32,6 +32,12 @@ install(FILES
     atsc_rs_decoder.h
     atsc_sync.h
     atsc_viterbi_decoder.h
+    atsc_depad.h
+    atsc_randomizer.h
+    atsc_rs_encoder.h
+    atsc_interleaver.h
+    atsc_trellis_encoder.h
+    atsc_field_sync_mux.h
     DESTINATION ${GR_INCLUDE_DIR}/gnuradio/dtv
     COMPONENT "dtv_devel"
 )
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_field_sync_mux.h 
b/gr-dtv/include/gnuradio/dtv/atsc_field_sync_mux.h
new file mode 100644
index 0000000..9eeef02
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_field_sync_mux.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_FIELD_SYNC_MUX_H
+#define INCLUDED_DTV_ATSC_FIELD_SYNC_MUX_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_field_sync_mux : virtual public gr::block
+    {
+     public:
+      typedef boost::shared_ptr<atsc_field_sync_mux> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of 
dtv::atsc_field_sync_mux.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_field_sync_mux's
+       * constructor is in a private implementation
+       * class. dtv::atsc_field_sync_mux::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_FIELD_SYNC_MUX_H */
+
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_interleaver.h 
b/gr-dtv/include/gnuradio/dtv/atsc_interleaver.h
new file mode 100644
index 0000000..86d5493
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_interleaver.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_INTERLEAVER_H
+#define INCLUDED_DTV_ATSC_INTERLEAVER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_interleaver : virtual public gr::sync_block
+    {
+     public:
+      typedef boost::shared_ptr<atsc_interleaver> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of dtv::atsc_interleaver.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_interleaver's
+       * constructor is in a private implementation
+       * class. dtv::atsc_interleaver::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_INTERLEAVER_H */
+
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_pad.h 
b/gr-dtv/include/gnuradio/dtv/atsc_pad.h
new file mode 100644
index 0000000..efd1680
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_pad.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_PAD_H
+#define INCLUDED_DTV_ATSC_PAD_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_decimator.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_pad : virtual public gr::sync_decimator
+    {
+     public:
+      typedef boost::shared_ptr<atsc_pad> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of dtv::atsc_pad.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_pad's
+       * constructor is in a private implementation
+       * class. dtv::atsc_pad::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_PAD_H */
+
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_randomizer.h 
b/gr-dtv/include/gnuradio/dtv/atsc_randomizer.h
new file mode 100644
index 0000000..f9823a7
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_randomizer.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_RANDOMIZER_H
+#define INCLUDED_DTV_ATSC_RANDOMIZER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_randomizer : virtual public gr::sync_block
+    {
+     public:
+      typedef boost::shared_ptr<atsc_randomizer> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of dtv::atsc_randomizer.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_randomizer's
+       * constructor is in a private implementation
+       * class. dtv::atsc_randomizer::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_RANDOMIZER_H */
+
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_rs_encoder.h 
b/gr-dtv/include/gnuradio/dtv/atsc_rs_encoder.h
new file mode 100644
index 0000000..bca73fd
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_rs_encoder.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_ENCODER_H
+#define INCLUDED_DTV_ATSC_RS_ENCODER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_rs_encoder : virtual public gr::sync_block
+    {
+     public:
+      typedef boost::shared_ptr<atsc_rs_encoder> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of dtv::atsc_rs_encoder.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_rs_encoder's
+       * constructor is in a private implementation
+       * class. dtv::atsc_rs_encoder::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_RS_ENCODER_H */
+
diff --git a/gr-dtv/include/gnuradio/dtv/atsc_trellis_encoder.h 
b/gr-dtv/include/gnuradio/dtv/atsc_trellis_encoder.h
new file mode 100644
index 0000000..1c1e0a4
--- /dev/null
+++ b/gr-dtv/include/gnuradio/dtv/atsc_trellis_encoder.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_TRELLIS_ENCODER_H
+#define INCLUDED_DTV_ATSC_TRELLIS_ENCODER_H
+
+#include <gnuradio/dtv/api.h>
+#include <gnuradio/sync_block.h>
+
+namespace gr {
+  namespace dtv {
+
+    /*!
+     * \brief <+description of block+>
+     * \ingroup dtv
+     *
+     */
+    class DTV_API atsc_trellis_encoder : virtual public gr::sync_block
+    {
+     public:
+      typedef boost::shared_ptr<atsc_trellis_encoder> sptr;
+
+      /*!
+       * \brief Return a shared_ptr to a new instance of 
dtv::atsc_trellis_encoder.
+       *
+       * To avoid accidental use of raw pointers, dtv::atsc_trellis_encoder's
+       * constructor is in a private implementation
+       * class. dtv::atsc_trellis_encoder::make is the public interface for
+       * creating new instances.
+       */
+      static sptr make();
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_TRELLIS_ENCODER_H */
+
diff --git a/gr-dtv/lib/CMakeLists.txt b/gr-dtv/lib/CMakeLists.txt
index 1035bcc..4afe91f 100644
--- a/gr-dtv/lib/CMakeLists.txt
+++ b/gr-dtv/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2014 Free Software Foundation, Inc.
+# Copyright 2014,2015 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -70,6 +70,13 @@ list(APPEND dtv_sources
   atsc/atsc_fake_single_viterbi.cc
   atsc/atsc_single_viterbi.cc
   atsc/atsc_viterbi_decoder_impl.cc
+  atsc/atsc_pad_impl.cc
+  atsc/atsc_randomizer_impl.cc
+  atsc/atsc_rs_encoder_impl.cc
+  atsc/atsc_interleaver_impl.cc
+  atsc/atsc_basic_trellis_encoder.cc
+  atsc/atsc_trellis_encoder_impl.cc
+  atsc/atsc_field_sync_mux_impl.cc
 )
 
 if(ENABLE_GR_CTRLPORT)
diff --git a/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.cc 
b/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.cc
new file mode 100644
index 0000000..f7327c7
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.cc
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "atsc_basic_trellis_encoder.h"
+#include <assert.h>
+
+namespace gr {
+  namespace dtv {
+
+    const unsigned char atsc_basic_trellis_encoder::next_state[32] = {
+        0,1,4,5,
+        2,3,6,7,
+        1,0,5,4,
+        3,2,7,6,
+        4,5,0,1,
+        6,7,2,3,
+        5,4,1,0,
+        7,6,3,2
+    };
+
+    const unsigned char atsc_basic_trellis_encoder::out_symbol[32] = {
+        0,2,4,6,
+        1,3,5,7,
+        0,2,4,6,
+        1,3,5,7,
+        4,6,0,2,
+        5,7,1,3,
+        4,6,0,2,
+        5,7,1,3
+    };
+
+    /*!
+     * Encode two bit INPUT into 3 bit return value. Domain is [0,3],
+     * Range is [0,7]. The mapping to bipolar levels is not done.
+     */
+
+    int
+    atsc_basic_trellis_encoder::encode(unsigned int input)
+    {
+        assert (input < 4);
+        int index = (state << 2) + input;
+        state = next_state[index];
+        return out_symbol[index];
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.h 
b/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.h
new file mode 100644
index 0000000..a4e64fb
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_basic_trellis_encoder.h
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_ATSC_TRELLIS_ENCODER_H
+#define INCLUDED_ATSC_TRELLIS_ENCODER_H
+
+/*!
+ * \brief ATSC trellis encoder building block.
+ *
+ * Note this is NOT the 12x interleaved interface.
+ *
+ * This implements a single instance of the ATSC trellis encoder.
+ * This is a rate 2/3 encoder (really a constraint length 3, rate 1/2
+ * encoder with the top bit passed through unencoded. This does not
+ * implement the "precoding" of the top bit, because the NTSC rejection
+ * filter is not supported.
+ */
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_basic_trellis_encoder
+    {
+     private:
+      int state;    // two bit state;
+
+     public:
+      atsc_basic_trellis_encoder() : state(0) {}
+
+      /*!
+       * Encode two bit INPUT into 3 bit return value. Domain is [0,3],
+       * Range is [0,7]. The mapping to bipolar levels is not done.
+       */
+      int encode(unsigned int input);
+
+      //! reset encoder state
+      void reset() {state = 0;}
+
+      static const unsigned char next_state[32];
+      static const unsigned char out_symbol[32];
+    };
+
+  } /* namespace dtv */
+} /* namespace gr */
+
+#endif /* INCLUDED_ATSC_TRELLIS_ENCODER_H */
diff --git a/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc 
b/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc
new file mode 100644
index 0000000..01400e6
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.cc
@@ -0,0 +1,243 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_field_sync_mux_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+
+namespace gr {
+  namespace dtv {
+
+    static const int N_SAVED_SYMBOLS = 12;
+
+    atsc_field_sync_mux::sptr
+    atsc_field_sync_mux::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_field_sync_mux_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_field_sync_mux_impl::atsc_field_sync_mux_impl()
+      : gr::block("atsc_field_sync_mux",
+              gr::io_signature::make(1, 1, sizeof(atsc_data_segment)),
+              gr::io_signature::make(1, 1, sizeof(atsc_data_segment)))
+    {
+        d_already_output_field_sync = false;
+        for (int i = 0; i < N_SAVED_SYMBOLS; i++)
+        {
+            d_saved_symbols[i] = 0;
+        }
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_field_sync_mux_impl::~atsc_field_sync_mux_impl()
+    {
+    }
+
+    void
+    atsc_field_sync_mux_impl::init_field_sync_common(unsigned char *p, int 
mask,
+                             const unsigned char 
saved_symbols[N_SAVED_SYMBOLS])
+    {
+        static const unsigned char bin_map[2] = {1, 6};    // map binary 
values to 1 of 8 levels
+
+        int i = 0;
+
+        p[i++] = bin_map[1];    // data segment sync pulse
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+
+        for (int j = 0; j < 511; j++)    // PN511
+        {
+            p[i++] = bin_map[atsc_pn511[j]];
+        }
+
+        for (int j = 0; j < 63; j++)     // PN63
+        {
+            p[i++] = bin_map[atsc_pn63[j]];
+        }
+
+        for (int j = 0; j < 63; j++)     // PN63, toggled on field 2
+        {
+            p[i++] = bin_map[atsc_pn63[j] ^ mask];
+        }
+
+        for (int j = 0; j < 63; j++)     // PN63
+        {
+            p[i++] = bin_map[atsc_pn63[j]];
+        }
+
+        p[i++] = bin_map[0];    // 24 bits of 8VSB mode identifier
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[0];
+
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[1];
+
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+        p[i++] = bin_map[1];
+        p[i++] = bin_map[0];
+
+        for (int j = 0; j < 92; j++)    // 92 more bits
+        {
+            p[i++] = bin_map[atsc_pn63[j % 63]];
+        }
+
+        // now copy the last 12 symbols of the previous segment
+
+        for (int j = 0; j < N_SAVED_SYMBOLS; j++)
+        {
+            p[i++] = saved_symbols[j];
+        }
+
+        assert (i == ATSC_DATA_SEGMENT_LENGTH);
+    }
+
+    inline void
+    atsc_field_sync_mux_impl::init_field_sync_1(atsc_data_segment *s,
+                  const unsigned char saved_symbols[N_SAVED_SYMBOLS])
+    {
+        init_field_sync_common(&s->data[0], 0, saved_symbols);
+    }
+
+    inline void
+    atsc_field_sync_mux_impl::init_field_sync_2(atsc_data_segment *s,
+                  const unsigned char saved_symbols[N_SAVED_SYMBOLS])
+    {
+        init_field_sync_common(&s->data[0], 1, saved_symbols);
+    }
+
+    void
+    atsc_field_sync_mux_impl::save_last_symbols(unsigned char 
saved_symbols[N_SAVED_SYMBOLS],
+                                                const atsc_data_segment &seg)
+    {
+        for (int i = 0; i < N_SAVED_SYMBOLS; i++)
+        {
+            saved_symbols[i] = seg.data[i + ATSC_DATA_SEGMENT_LENGTH - 
N_SAVED_SYMBOLS];
+        }
+    }
+
+    inline bool
+    atsc_field_sync_mux_impl::last_regular_seg_p(const plinfo &pli)
+    {
+        return pli.regular_seg_p() && (pli.segno() == ATSC_DSEGS_PER_FIELD - 
1);
+    }
+
+    void
+    atsc_field_sync_mux_impl::forecast (int noutput_items, gr_vector_int 
&ninput_items_required)
+    {
+        ninput_items_required[0] = noutput_items;
+    }
+
+    int
+    atsc_field_sync_mux_impl::general_work (int noutput_items,
+                       gr_vector_int &ninput_items,
+                       gr_vector_const_void_star &input_items,
+                       gr_vector_void_star &output_items)
+    {
+        const atsc_data_segment *in = (const atsc_data_segment *) 
input_items[0];
+        atsc_data_segment *out = (atsc_data_segment *) output_items[0];
+        int in_length = ninput_items[0];
+        int index = 0;
+        int outdex = 0;
+
+        for (outdex = 0; outdex < noutput_items && index < in_length; outdex++)
+        {
+            assert(in[index].pli.regular_seg_p());
+
+            if (!in[index].pli.first_regular_seg_p())
+            {
+                out[outdex] = in[index];    // just copy in to out
+
+                if (last_regular_seg_p(in[index].pli))
+                {
+                    save_last_symbols(d_saved_symbols, in[index]);
+                }
+                index++;
+            }
+            else
+            {   // first_regular_seg_p
+                if (!d_already_output_field_sync)
+                {
+                    // write out field sync...
+                    atsc_data_segment field_sync;
+
+                    if (in[index].pli.in_field1_p())
+                    {
+                        init_field_sync_1(&field_sync, d_saved_symbols);
+                    }
+                    else
+                    {
+                        init_field_sync_2(&field_sync, d_saved_symbols);
+                    }
+
+                    // note that index doesn't advance in this branch
+                    out[outdex] = field_sync;
+                    d_already_output_field_sync = true;
+                }
+                else
+                {
+                    // already output field sync, now output first regular 
segment
+                    out[outdex] = in[index];
+                    index++;
+                    d_already_output_field_sync = false;
+                }
+            }
+        }
+
+        // Tell runtime system how many input items we consumed on
+        // each input stream.
+        consume_each (index);
+
+        // Tell runtime system how many output items we produced.
+        return outdex;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.h 
b/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.h
new file mode 100644
index 0000000..ba73faa
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_field_sync_mux_impl.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_FIELD_SYNC_MUX_IMPL_H
+#define INCLUDED_DTV_ATSC_FIELD_SYNC_MUX_IMPL_H
+
+#include <gnuradio/dtv/atsc_field_sync_mux.h>
+#include "atsc_pnXXX_impl.h"
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_field_sync_mux_impl : public atsc_field_sync_mux
+    {
+     private:
+      static const int N_SAVED_SYMBOLS = 12;
+      bool d_already_output_field_sync;
+      unsigned char d_saved_symbols[N_SAVED_SYMBOLS];
+
+      void init_field_sync_common(unsigned char *p, int mask, const unsigned 
char saved_symbols[N_SAVED_SYMBOLS]);
+      inline void init_field_sync_1(atsc_data_segment *s, const unsigned char 
saved_symbols[N_SAVED_SYMBOLS]);
+      inline void init_field_sync_2(atsc_data_segment *s, const unsigned char 
saved_symbols[N_SAVED_SYMBOLS]);
+      void save_last_symbols(unsigned char saved_symbols[N_SAVED_SYMBOLS], 
const atsc_data_segment &seg);
+      inline bool last_regular_seg_p(const plinfo &pli);
+
+     public:
+      atsc_field_sync_mux_impl();
+      ~atsc_field_sync_mux_impl();
+
+      void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+      int general_work(int noutput_items,
+                       gr_vector_int &ninput_items,
+                       gr_vector_const_void_star &input_items,
+                       gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_FIELD_SYNC_MUX_IMPL_H */
+
diff --git a/gr-dtv/lib/atsc/atsc_interleaver_impl.cc 
b/gr-dtv/lib/atsc/atsc_interleaver_impl.cc
new file mode 100644
index 0000000..6d147f5
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_interleaver_impl.cc
@@ -0,0 +1,122 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_interleaver_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+
+namespace gr {
+  namespace dtv {
+
+    atsc_interleaver::sptr
+    atsc_interleaver::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_interleaver_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_interleaver_impl::atsc_interleaver_impl()
+      : gr::sync_block("atsc_interleaver",
+              gr::io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)),
+              gr::io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)))
+    {
+        I = 52;    /* ATSC interleaver */
+        J = 4;
+        registers = (unsigned char *) malloc(sizeof(unsigned char) * I * ((I - 
1) * J));
+        if (registers == NULL) {
+            fprintf(stderr, "Out of memory.\n");
+            exit(1);
+        }
+
+        pointers = (int *) malloc(sizeof(int) * I);
+        if (pointers == NULL) {
+            fprintf(stderr, "Out of memory.\n");
+            exit(1);
+        }
+
+        memset(registers, 0, sizeof(unsigned char) * I * ((I - 1) * J));
+        memset(pointers, 0, sizeof(int) * I);
+
+        this->I = I;
+        this->J = J;
+        commutator = 0;
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_interleaver_impl::~atsc_interleaver_impl()
+    {
+        free(pointers);
+        free(registers);
+    }
+
+    int
+    atsc_interleaver_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];
+        int p, n = ATSC_MPEG_RS_ENCODED_LENGTH;
+
+        for (int i = 0; i < noutput_items; i++)
+        {
+            assert(in[i].pli.regular_seg_p());
+            plinfo::sanity_check(in[i].pli);
+
+            out[i].pli = in[i].pli;                 // copy pipeline info
+            if (in[i].pli.first_regular_seg_p())    // reset commutator if 
required
+            {
+                commutator = 0;
+            }
+            for (int j = 0; j < n; j++)
+            {
+                if (commutator == 0)
+                {
+                    out[i].data[j] = in[i].data[j];
+                }
+                else
+                {
+                    p = pointers[commutator];
+
+                    out[i].data[j] = registers[commutator * (I - 1) * J + p];
+                    registers[commutator * (I - 1) * J + p] = in[i].data[j];
+
+                    pointers[commutator] = (p + 1) % (commutator * J);
+                }
+                commutator = (commutator + 1) % I;
+            }
+        }
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_interleaver_impl.h 
b/gr-dtv/lib/atsc/atsc_interleaver_impl.h
new file mode 100644
index 0000000..337edcf
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_interleaver_impl.h
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_INTERLEAVER_IMPL_H
+#define INCLUDED_DTV_ATSC_INTERLEAVER_IMPL_H
+
+#include <gnuradio/dtv/atsc_interleaver.h>
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_interleaver_impl : public atsc_interleaver
+    {
+     private:
+      int I, J;
+      int commutator;
+      unsigned char *registers;
+      int *pointers;
+
+     public:
+      atsc_interleaver_impl();
+      ~atsc_interleaver_impl();
+
+      int work(int noutput_items,
+               gr_vector_const_void_star &input_items,
+               gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_INTERLEAVER_IMPL_H */
+
diff --git a/gr-dtv/lib/atsc/atsc_pad_impl.cc b/gr-dtv/lib/atsc/atsc_pad_impl.cc
new file mode 100644
index 0000000..1b5e733
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_pad_impl.cc
@@ -0,0 +1,74 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_pad_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+
+namespace gr {
+  namespace dtv {
+
+    atsc_pad::sptr
+    atsc_pad::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_pad_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_pad_impl::atsc_pad_impl()
+      : gr::sync_decimator("atsc_pad",
+              gr::io_signature::make(1, 1, sizeof(unsigned char)),
+              gr::io_signature::make(1, 1, sizeof(atsc_mpeg_packet)), 
ATSC_MPEG_PKT_LENGTH)
+    {}
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_pad_impl::~atsc_pad_impl()
+    {
+    }
+
+    int
+    atsc_pad_impl::work(int noutput_items,
+                        gr_vector_const_void_star &input_items,
+                        gr_vector_void_star &output_items)
+    {
+        const unsigned char *in = (const unsigned char *) input_items[0];
+        atsc_mpeg_packet *out = (atsc_mpeg_packet *) output_items[0];
+
+        for (int i = 0; i < noutput_items; i++)
+        {
+            memcpy(out[i].data, &in[i * ATSC_MPEG_PKT_LENGTH], 
ATSC_MPEG_PKT_LENGTH);
+        }
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_pad_impl.h b/gr-dtv/lib/atsc/atsc_pad_impl.h
new file mode 100644
index 0000000..4a661bd
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_pad_impl.h
@@ -0,0 +1,45 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_PAD_IMPL_H
+#define INCLUDED_DTV_ATSC_PAD_IMPL_H
+
+#include <gnuradio/dtv/atsc_pad.h>
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_pad_impl : public atsc_pad
+    {
+     public:
+      atsc_pad_impl();
+      ~atsc_pad_impl();
+
+      int work(int noutput_items,
+               gr_vector_const_void_star &input_items,
+               gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_PAD_IMPL_H */
+
diff --git a/gr-dtv/lib/atsc/atsc_randomizer_impl.cc 
b/gr-dtv/lib/atsc/atsc_randomizer_impl.cc
new file mode 100644
index 0000000..55d4785
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_randomizer_impl.cc
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_randomizer_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+
+namespace gr {
+  namespace dtv {
+
+    atsc_randomizer::sptr
+    atsc_randomizer::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_randomizer_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_randomizer_impl::atsc_randomizer_impl()
+      : gr::sync_block("atsc_randomizer",
+              gr::io_signature::make(1, 1, sizeof(atsc_mpeg_packet)),
+              gr::io_signature::make(1, 1, sizeof(atsc_mpeg_packet_no_sync)))
+    {
+        reset();
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_randomizer_impl::~atsc_randomizer_impl()
+    {
+    }
+
+    void
+    atsc_randomizer_impl::reset()
+    {
+        d_rand.reset();
+        d_field2 = false;
+        d_segno = 0;
+    }
+
+    int
+    atsc_randomizer_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];
+        atsc_mpeg_packet_no_sync *out = (atsc_mpeg_packet_no_sync *) 
output_items[0];
+
+        for (int i = 0; i < noutput_items; i++)
+        {
+            // sanity check incoming data.
+            assert((in[i].data[0] == MPEG_SYNC_BYTE));
+            assert((in[i].data[1] & MPEG_TRANSPORT_ERROR_BIT) == 0);
+
+            // initialize plinfo for downstream
+            //
+            // We do this here because the randomizer is effectively
+            // the head of the tx processing chain
+            //
+            out[i].pli.set_regular_seg(d_field2, d_segno);
+            d_segno++;
+            if (d_segno == 312)
+            {
+                d_segno = 0;
+                d_field2 = !d_field2;
+            }
+
+            if (out[i].pli.first_regular_seg_p())
+            {
+                d_rand.reset();
+            }
+
+            d_rand.randomize(out[i], in[i]);
+        }
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_randomizer_impl.h 
b/gr-dtv/lib/atsc/atsc_randomizer_impl.h
new file mode 100644
index 0000000..48ee213
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_randomizer_impl.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_RANDOMIZER_IMPL_H
+#define INCLUDED_DTV_ATSC_RANDOMIZER_IMPL_H
+
+#include <gnuradio/dtv/atsc_randomizer.h>
+#include "atsc_randomize.h"
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_randomizer_impl : public atsc_randomizer
+    {
+     private:
+      atsc_randomize d_rand;
+      int d_segno;
+      bool d_field2;
+
+      void reset(void);
+
+     public:
+      atsc_randomizer_impl();
+      ~atsc_randomizer_impl();
+
+      int work(int noutput_items,
+               gr_vector_const_void_star &input_items,
+               gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_RANDOMIZER_IMPL_H */
+
diff --git a/gr-dtv/lib/atsc/atsc_rs_encoder_impl.cc 
b/gr-dtv/lib/atsc/atsc_rs_encoder_impl.cc
new file mode 100644
index 0000000..002dc17
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_rs_encoder_impl.cc
@@ -0,0 +1,112 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_rs_encoder_impl.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_encoder::sptr
+    atsc_rs_encoder::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_rs_encoder_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_rs_encoder_impl::atsc_rs_encoder_impl()
+      : gr::sync_block("atsc_rs_encoder",
+              gr::io_signature::make(1, 1, sizeof(atsc_mpeg_packet_no_sync)),
+              gr::io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)))
+    {
+        d_rs = init_rs_char(rs_init_symsize, rs_init_gfpoly, rs_init_fcr, 
rs_init_prim, rs_init_nroots);
+        assert (d_rs != 0);
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_rs_encoder_impl::~atsc_rs_encoder_impl()
+    {
+        if (d_rs)
+        {
+            free_rs_char(d_rs);
+        }
+        d_rs = 0;
+    }
+
+    void
+    atsc_rs_encoder_impl::encode(atsc_mpeg_packet_rs_encoded &out, const 
atsc_mpeg_packet_no_sync &in)
+    {
+        unsigned char tmp[K];
+
+        assert((int)(amount_of_pad + sizeof (in.data)) == K);
+
+        // add missing prefix zero padding to message
+        memset(tmp, 0, amount_of_pad);
+        memcpy(&tmp[amount_of_pad], in.data, sizeof (in.data));
+
+        // copy message portion to output packet
+        memcpy(out.data, in.data, sizeof (in.data));
+
+        // now compute parity bytes and add them to tail end of output packet
+        encode_rs_char(d_rs, tmp, &out.data[sizeof (in.data)]);
+    }
+
+    int
+    atsc_rs_encoder_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_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());
+            out[i].pli = in[i].pli;                // copy pipeline info...
+            encode(out[i], in[i]);
+        }
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_rs_encoder_impl.h 
b/gr-dtv/lib/atsc/atsc_rs_encoder_impl.h
new file mode 100644
index 0000000..3f82a29
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_rs_encoder_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_ENCODER_IMPL_H
+#define INCLUDED_DTV_ATSC_RS_ENCODER_IMPL_H
+
+#include <gnuradio/dtv/atsc_rs_encoder.h>
+#include "atsc_types.h"
+
+extern "C"
+{
+#include <gnuradio/fec/rs.h>
+}
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_rs_encoder_impl : public atsc_rs_encoder
+    {
+     private:
+      void *d_rs;
+      void encode(atsc_mpeg_packet_rs_encoded &out, const 
atsc_mpeg_packet_no_sync &in);
+
+     public:
+      atsc_rs_encoder_impl();
+      ~atsc_rs_encoder_impl();
+
+      int work(int noutput_items,
+               gr_vector_const_void_star &input_items,
+               gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_RS_ENCODER_IMPL_H */
+
diff --git a/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.cc 
b/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.cc
new file mode 100644
index 0000000..3baf045
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.cc
@@ -0,0 +1,264 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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 <gnuradio/io_signature.h>
+#include "atsc_trellis_encoder_impl.h"
+#include "gnuradio/dtv/atsc_consts.h"
+#include <stdio.h>
+
+namespace gr {
+  namespace dtv {
+
+static const int DIBITS_PER_BYTE = 4;
+
+#define SEGOF(x) ( (x) / ((SEGMENT_SIZE + 1) * DIBITS_PER_BYTE))
+#define SYMOF(x) (((x) % ((SEGMENT_SIZE + 1) * DIBITS_PER_BYTE)) - 4)
+
+/* How many separate Trellis encoders / Viterbi decoders run in parallel */
+static const int NCODERS = 12;
+
+#define ENCODER_SEG_BUMP 4
+
+/* A Segment sync symbol is an 8VSB +5,-5,-5,+5 sequence that occurs at
+   the start of each 207-byte segment (including field sync segments).  */
+#define DSEG_SYNC_SYM1 0x06    /* +5 */
+#define DSEG_SYNC_SYM2 0x01    /* -5 */
+#define DSEG_SYNC_SYM3 0x01    /* -5 */
+#define DSEG_SYNC_SYM4 0x06    /* +5 */
+
+/* Shift counts to bit numbers (high order, low order); 9x entries unused */
+static const int bit1[8] = {1, 99, 3, 98, 5, 97, 7, 96};
+static const int bit2[8] = {0, 99, 2, 98, 4, 97, 6, 96};
+
+    atsc_trellis_encoder::sptr
+    atsc_trellis_encoder::make()
+    {
+      return gnuradio::get_initial_sptr
+        (new atsc_trellis_encoder_impl());
+    }
+
+    /*
+     * The private constructor
+     */
+    atsc_trellis_encoder_impl::atsc_trellis_encoder_impl()
+      : gr::sync_block("atsc_trellis_encoder",
+              gr::io_signature::make(1, 1, 
sizeof(atsc_mpeg_packet_rs_encoded)),
+              gr::io_signature::make(1, 1, sizeof(atsc_data_segment)))
+    {
+        reset();
+        debug = false;
+        set_output_multiple(NCODERS);
+    }
+
+    /*
+     * Our virtual destructor.
+     */
+    atsc_trellis_encoder_impl::~atsc_trellis_encoder_impl()
+    {
+    }
+
+    void
+    atsc_trellis_encoder_impl::reset()
+    {
+        for (int i = 0; i < NCODERS; i++)
+        {
+            enc[i].reset();
+        }
+    }
+
+    void
+    atsc_trellis_encoder_impl::encode(atsc_data_segment out[NCODERS],
+                                      const atsc_mpeg_packet_rs_encoded 
in[NCODERS])
+    {
+        unsigned char out_copy[OUTPUT_SIZE];
+        unsigned char in_copy[INPUT_SIZE];
+
+        assert (sizeof (in_copy) == sizeof (in[0].data) * NCODERS);
+        assert (sizeof (out_copy) == sizeof (out[0].data) * NCODERS);
+
+        // copy input into continguous temporary buffer
+        for (int i = 0; i < NCODERS; i++)
+        {
+            assert(in[i].pli.regular_seg_p());
+            plinfo::sanity_check (in[i].pli);
+            memcpy(&in_copy[i * INPUT_SIZE / NCODERS], &in[i].data[0], 
ATSC_MPEG_RS_ENCODED_LENGTH * sizeof (in_copy[0]));
+        }
+
+        memset(out_copy, 0, sizeof (out_copy));    // FIXME, sanity check
+
+        // do the deed...
+        encode_helper(out_copy, in_copy);
+
+        // copy output from contiguous temp buffer into final output
+        for (int i = 0; i < NCODERS; i++)
+        {
+            memcpy(&out[i].data[0], &out_copy[i * OUTPUT_SIZE / NCODERS], 
ATSC_DATA_SEGMENT_LENGTH * sizeof (out_copy[0]));
+
+            // copy pipeline info
+            out[i].pli = in[i].pli;
+
+            plinfo::sanity_check(out[i].pli);
+            assert(out[i].pli.regular_seg_p());
+        }
+    }
+
+    /*
+     * This code expects contiguous arrrays. Use it as is, it computes
+     * the correct answer. Maybe someday, when we've run out of better
+     * things to do, rework to avoid the copying in encode.
+     */
+    void
+    atsc_trellis_encoder_impl::encode_helper(unsigned char output[OUTPUT_SIZE],
+                                             const unsigned char 
input[INPUT_SIZE])
+    {
+        int i;
+        int encoder;
+        unsigned char trellis_buffer[NCODERS];
+        int trellis_wherefrom[NCODERS];
+        unsigned char *out, *next_out_seg;
+        int chunk;
+        int shift;
+        unsigned char dibit;
+        unsigned char symbol;
+        int skip_encoder_bump;
+
+        /* FIXME, we may want special processing here for a flag
+         * byte to keep track of which part of the field we're in?
+         */
+
+        encoder = NCODERS - ENCODER_SEG_BUMP;
+        skip_encoder_bump = 0;
+        out = output;
+        next_out_seg = out;
+
+        for (chunk = 0; chunk < INPUT_SIZE; chunk += NCODERS)
+        {
+            /* Load a new chunk of bytes into the Trellis encoder buffers.
+             * They get loaded in an order that depends on where we are in
+             * the segment sync progress (sigh).
+             * GRR! When the chunk reload happens at the same time as the
+             * segment boundary, we should bump the encoder NOW for the reload,
+             * rather than LATER during the bitshift transition!!!
+             */
+            if (out >= next_out_seg)
+            {
+                encoder = (encoder + ENCODER_SEG_BUMP) % NCODERS;
+                skip_encoder_bump = 1;
+            }
+
+            for (i = 0; i < NCODERS; i++)
+            {
+                /* for debug */
+                trellis_wherefrom[encoder] = chunk + i;
+                trellis_buffer[encoder] = input [chunk + i];
+                encoder++;
+                if (encoder >= NCODERS)
+                {
+                    encoder = 0;
+                }
+            }
+
+            for (shift = 6; shift >= 0; shift -= 2)
+            {
+                /* Segment boundaries happen to occur on some bitshift 
transitions. */
+                if (out >= next_out_seg)
+                {
+                    /* Segment transition. Output a data segment sync symbol,
+                     * and mess with the trellis encoder mux.
+                     */
+                    *out++ = DSEG_SYNC_SYM1;
+                    *out++ = DSEG_SYNC_SYM2;
+                    *out++ = DSEG_SYNC_SYM3;
+                    *out++ = DSEG_SYNC_SYM4;
+                    if (debug)
+                    {
+                        printf("SYNC SYNC SYNC SYNC\n");
+                    }
+                    next_out_seg = out + (SEGMENT_SIZE * DIBITS_PER_BYTE);
+
+                    if (!skip_encoder_bump)
+                    {
+                        encoder = (encoder + ENCODER_SEG_BUMP) % NCODERS;
+                    }
+                    skip_encoder_bump = 0;
+                }
+
+                /* Now run each of the 12 Trellis encoders to spit out 12 
symbols.
+                 * Each encoder takes input from the same byte of the chunk, 
but
+                 * the outputs of the encoders come out in various orders.
+                 * NOPE -- this is false. The encoders take input from various
+                 * bytes of the chunk (which changes at segment sync time), AND
+                 * they also come out in various orders. You really do have to
+                 * keep separate track of: the input bytes, the encoders, and
+                 * the output bytes -- because they're all moving with respect
+                 * to each other!!!
+                 */
+                for (i = 0; i < NCODERS; i++)
+                {
+                    dibit = 0x03 & (trellis_buffer[encoder] >> shift);
+                    if (debug)
+                    {
+                        printf("Seg %ld Symb %3ld Trell %2d Byte %6d Bits 
%d-%d = dibit %d ", (long) SEGOF(out-output), (long) SYMOF(out-output), 
encoder, trellis_wherefrom[encoder], bit1[shift], bit2[shift], dibit);
+                    }
+                    symbol = enc[encoder].encode(dibit);
+                    *out++ = symbol;
+                    encoder++;
+                    if (encoder >= NCODERS)
+                    {
+                        encoder = 0;
+                    }
+                    if (debug)
+                    {
+                        printf("sym %d\n", symbol);
+                    }
+                } /* Encoders */
+            } /* Bit shifts */
+        } /* Chunks */
+
+        /* Check up on ourselves */
+        assert (0 ==  (INPUT_SIZE * DIBITS_PER_BYTE) % NCODERS);
+        assert (OUTPUT_SIZE == out - output);
+        assert (NCODERS - ENCODER_SEG_BUMP == encoder);
+    }
+
+    int
+    atsc_trellis_encoder_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_data_segment *out = (atsc_data_segment *) output_items[0];
+
+        for (int i = 0; i < noutput_items; i += NCODERS)
+        {
+            encode(&out[i], &in[i]);
+        }
+
+        // Tell runtime system how many output items we produced.
+        return noutput_items;
+    }
+
+  } /* namespace dtv */
+} /* namespace gr */
+
diff --git a/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.h 
b/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.h
new file mode 100644
index 0000000..f81b4d0
--- /dev/null
+++ b/gr-dtv/lib/atsc/atsc_trellis_encoder_impl.h
@@ -0,0 +1,60 @@
+/* -*- c++ -*- */
+/* 
+ * Copyright 2015 Free Software Foundation, Inc.
+ * 
+ * This 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.
+ * 
+ * This software 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 this software; 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_TRELLIS_ENCODER_IMPL_H
+#define INCLUDED_DTV_ATSC_TRELLIS_ENCODER_IMPL_H
+
+#include <gnuradio/dtv/atsc_trellis_encoder.h>
+#include "atsc_basic_trellis_encoder.h"
+#include "atsc_types.h"
+
+namespace gr {
+  namespace dtv {
+
+    class atsc_trellis_encoder_impl : public atsc_trellis_encoder
+    {
+     private:
+      bool debug;
+
+      static const int NCODERS = 12;
+      static const int SEGMENT_SIZE = ATSC_MPEG_RS_ENCODED_LENGTH;
+      static const int INPUT_SIZE = (SEGMENT_SIZE * 12);
+      static const int OUTPUT_SIZE = (ATSC_DATA_SEGMENT_LENGTH * 12);
+
+      void reset();
+      void encode(atsc_data_segment out[NCODERS], const 
atsc_mpeg_packet_rs_encoded in[NCODERS]);
+      void encode_helper(unsigned char output[OUTPUT_SIZE], const unsigned 
char input[INPUT_SIZE]);
+
+      atsc_basic_trellis_encoder enc[NCODERS];
+
+     public:
+      atsc_trellis_encoder_impl();
+      ~atsc_trellis_encoder_impl();
+
+      int work(int noutput_items,
+               gr_vector_const_void_star &input_items,
+               gr_vector_void_star &output_items);
+    };
+
+  } // namespace dtv
+} // namespace gr
+
+#endif /* INCLUDED_DTV_ATSC_TRELLIS_ENCODER_IMPL_H */
+
diff --git a/gr-dtv/swig/dtv_swig.i b/gr-dtv/swig/dtv_swig.i
index 91c910d..0baaafd 100644
--- a/gr-dtv/swig/dtv_swig.i
+++ b/gr-dtv/swig/dtv_swig.i
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2014 Free Software Foundation, Inc.
+ * Copyright 2014,2015 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -37,6 +37,12 @@
 #include "gnuradio/dtv/atsc_rs_decoder.h"
 #include "gnuradio/dtv/atsc_sync.h"
 #include "gnuradio/dtv/atsc_viterbi_decoder.h"
+#include "gnuradio/dtv/atsc_pad.h"
+#include "gnuradio/dtv/atsc_randomizer.h"
+#include "gnuradio/dtv/atsc_rs_encoder.h"
+#include "gnuradio/dtv/atsc_interleaver.h"
+#include "gnuradio/dtv/atsc_trellis_encoder.h"
+#include "gnuradio/dtv/atsc_field_sync_mux.h"
 %}
 
 %include "gnuradio/dtv/atsc_deinterleaver.h"
@@ -48,6 +54,12 @@
 %include "gnuradio/dtv/atsc_rs_decoder.h"
 %include "gnuradio/dtv/atsc_sync.h"
 %include "gnuradio/dtv/atsc_viterbi_decoder.h"
+%include "gnuradio/dtv/atsc_pad.h"
+%include "gnuradio/dtv/atsc_randomizer.h"
+%include "gnuradio/dtv/atsc_rs_encoder.h"
+%include "gnuradio/dtv/atsc_interleaver.h"
+%include "gnuradio/dtv/atsc_trellis_encoder.h"
+%include "gnuradio/dtv/atsc_field_sync_mux.h"
 
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_deinterleaver);
 GR_SWIG_BLOCK_MAGIC2(dtv, atsc_depad);
@@ -58,3 +70,9 @@ 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);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_pad);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_randomizer);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_rs_encoder);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_interleaver);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_trellis_encoder);
+GR_SWIG_BLOCK_MAGIC2(dtv, atsc_field_sync_mux);



reply via email to

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