diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2015-03-22 10:19:19 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-03-22 10:19:19 -0700 |
commit | a709488d95cb71b0767e24e67a0cb70f46d30337 (patch) | |
tree | 8de71698575d22b79ac20a54b01028fdc8dcabc9 /gr-atsc/python | |
parent | 65df3e31166b8f517a3779cddcdb7db5e68cdc9c (diff) |
Removed top-level component gr-atsc.
This functionality has been migrated to the new gr-dtv top-level
component.
Diffstat (limited to 'gr-atsc/python')
-rw-r--r-- | gr-atsc/python/atsc/CMakeLists.txt | 63 | ||||
-rw-r--r-- | gr-atsc/python/atsc/README | 19 | ||||
-rw-r--r-- | gr-atsc/python/atsc/__init__.py | 34 | ||||
-rwxr-xr-x | gr-atsc/python/atsc/atsc_rx.py | 134 | ||||
-rw-r--r-- | gr-atsc/python/atsc/atsc_utils.py | 75 | ||||
-rwxr-xr-x | gr-atsc/python/atsc/qa_atsc.py | 225 |
6 files changed, 0 insertions, 550 deletions
diff --git a/gr-atsc/python/atsc/CMakeLists.txt b/gr-atsc/python/atsc/CMakeLists.txt deleted file mode 100644 index a26df35424..0000000000 --- a/gr-atsc/python/atsc/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# Install python examples -######################################################################## -include(GrPython) - -GR_PYTHON_INSTALL( - FILES - __init__.py - atsc_utils.py - DESTINATION ${GR_PYTHON_DIR}/gnuradio/atsc - COMPONENT "atsc_python" -) - -GR_PYTHON_INSTALL( - PROGRAMS - atsc_rx.py - DESTINATION ${GR_PKG_DATA_DIR}/examples/atsc - COMPONENT "atsc_examples" -) - -install( - FILES README - DESTINATION ${GR_PKG_DATA_DIR}/examples/atsc - COMPONENT "atsc_examples" -) - -######################################################################## -# Handle the unit tests -######################################################################## -if(ENABLE_TESTING) - - set(GR_TEST_TARGET_DEPS "") - set(GR_TEST_LIBRARY_DIRS "") - set(GR_TEST_PYTHON_DIRS - ${CMAKE_BINARY_DIR}/gnuradio-runtime/python - ) - - include(GrTest) - file(GLOB py_qa_test_files "qa_*.py") - foreach(py_qa_test_file ${py_qa_test_files}) - get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) - GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) - endforeach(py_qa_test_file) -endif(ENABLE_TESTING) diff --git a/gr-atsc/python/atsc/README b/gr-atsc/python/atsc/README deleted file mode 100644 index 38772c2f10..0000000000 --- a/gr-atsc/python/atsc/README +++ /dev/null @@ -1,19 +0,0 @@ -Decoding ATSC using 6.4MSps rate ---------------------------------- - -1) Verify signal, adjust antenna and find best gain setting using uhd_fft.py, -station frequency from the fcc video database, and sample rate to 6.4e6. - -2) Capture data - adjust gain (-g) frequency (-f) and which side -the daughterboard is on to fit your local setup: - -uhd_rx_cfile.py -s --samp-rate=6.4e6 -g 65 -f 503e6 atsc_data_6-4m_complex - -You probably still need fast disks to take the data, like a raid-0 set of -striped sata drives. Make sure there are no or very few Ou overruns. Saving -the raw usrp data in 'short' form halves the disk space/bus bandwidth that -the usual complex form uses. - -3) Run atsc_rx.py: - -./atsc_rx.py atsc_data_6-4m_complex outfile.ts
\ No newline at end of file diff --git a/gr-atsc/python/atsc/__init__.py b/gr-atsc/python/atsc/__init__.py deleted file mode 100644 index 155baa2547..0000000000 --- a/gr-atsc/python/atsc/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright 2013 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# The presence of this file turns this directory into a Python package - -''' -Blocks and utilities for ATSC (Advanced Television Systems Committee) module. -''' -import os - -try: - from atsc_swig import * -except ImportError: - dirname, filename = os.path.split(os.path.abspath(__file__)) - __path__.append(os.path.join(dirname, "..", "..", "swig")) - from atsc_swig import * diff --git a/gr-atsc/python/atsc/atsc_rx.py b/gr-atsc/python/atsc/atsc_rx.py deleted file mode 100755 index 940eeac4bd..0000000000 --- a/gr-atsc/python/atsc/atsc_rx.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env /usr/bin/python -# -# Copyright 2004, 2013 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This module starts the atsc processing chain taking the captured -# off-air signal created with: -# -# uhd_rx_cfile.py --samp-rate=6.4e6 -# -f <center of tv signal channel freq> -# -g <appropriate gain for best signal / noise> -# -s output shorts -# -# This python script converts from interleaved shorts to the complex data type, -# then multiplies the sample rate by 3, from 6.4e6 to 19.2e6 -# complex samples / sec, then lowpass filters with a cutoff of 3.2MHz -# and a transition band width of .5MHz. Center of the tv channels is -# now at 0 with edges at -3.2MHz and 3.2MHz. This puts the pilot at -# -3MHz + 309KHz. Next a root raised cosine filter is aplied to match the one -# in the transmitter and thus reduce ISI. The phased locked loop then locks to -# the pilot and outputs just the real part of the signal ( as information is -# not stored in the phase with atsc ), this is then feed to the bit lock -# loop, this looks for the bit sync marker put at the beginning of every segment -# field, this then adjusts the timing so the amplitude will be sampled at the -# correct sample ( sub-sample is used in this case ). -# -# Output is float. - -from gnuradio import gr, analog, atsc -from gnuradio import blocks -from gnuradio import filter -import sys, math, os - -def graph (args): - - print os.getpid() - - nargs = len(args) - if nargs == 2: - infile = args[0] - outfile = args[1] - else: - raise ValueError('usage: interp.py input_file output_file.ts\n') - - input_rate = 19.2e6 - IF_freq = 5.75e6 - - tb = gr.top_block() - - # Read from input file - srcf = blocks.file_source(gr.sizeof_short, infile) - - # Convert interleaved shorts (I,Q,I,Q) to complex - is2c = blocks.interleaved_short_to_complex() - - # 1/2 as wide because we're designing lp filter - symbol_rate = atsc.ATSC_SYMBOL_RATE/2. - NTAPS = 279 - tt = filter.firdes.root_raised_cosine (1.0, input_rate / 3, symbol_rate, .1152, NTAPS) - rrc = filter.fir_filter_ccf(1, tt) - - # Interpolate Filter our 6MHz wide signal centered at 0 - ilp_coeffs = filter.firdes.low_pass(1, input_rate, 3.2e6, .5e6, filter.firdes.WIN_HAMMING) - ilp = filter.interp_fir_filter_ccf(3, ilp_coeffs) - - # Move the center frequency to 5.75MHz ( this wont be needed soon ) - duc_coeffs = filter.firdes.low_pass ( 1, 19.2e6, 9e6, 1e6, filter.firdes.WIN_HAMMING ) - duc = filter.freq_xlating_fir_filter_ccf ( 1, duc_coeffs, -5.75e6, 19.2e6 ) - - # fpll input is float - c2f = blocks.complex_to_float() - - # Phase locked loop - fpll = atsc.fpll() - - # Clean fpll output - lp_coeffs2 = filter.firdes.low_pass (1.0, - input_rate, - 5.75e6, - 120e3, - filter.firdes.WIN_HAMMING); - lp_filter = filter.fir_filter_fff (1, lp_coeffs2) - - # Remove pilot ( at DC now ) - iir = filter.single_pole_iir_filter_ff(1e-5) - remove_dc = blocks.sub_ff() - - # Bit Timing Loop, Field Sync Checker and Equalizer - btl = atsc.bit_timing_loop() - fsc = atsc.fs_checker() - eq = atsc.equalizer() - fsd = atsc.field_sync_demux() - - # Viterbi - viterbi = atsc.viterbi_decoder() - deinter = atsc.deinterleaver() - rs_dec = atsc.rs_decoder() - derand = atsc.derandomizer() - depad = atsc.depad() - - # Write to output file - outf = blocks.file_sink(gr.sizeof_char,outfile) - - # Connect it all together - tb.connect( srcf, is2c, rrc, ilp, duc, c2f, fpll, lp_filter) - tb.connect( lp_filter, iir ) - tb.connect( lp_filter, (remove_dc, 0) ) - tb.connect( iir, (remove_dc, 1) ) - tb.connect( remove_dc, btl ) - tb.connect( (btl, 0), (fsc, 0), (eq, 0), (fsd,0) ) - tb.connect( (btl, 1), (fsc, 1), (eq, 1), (fsd,1) ) - tb.connect( fsd, viterbi, deinter, rs_dec, derand, depad, outf ) - - tb.run() - -if __name__ == '__main__': - graph (sys.argv[1:]) - diff --git a/gr-atsc/python/atsc/atsc_utils.py b/gr-atsc/python/atsc/atsc_utils.py deleted file mode 100644 index fc2465bed2..0000000000 --- a/gr-atsc/python/atsc/atsc_utils.py +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright 2006 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import random -import sys - -MPEG_SYNC_BYTE = 0x47 - -def make_fake_transport_stream_packet(npkts): - """ - Return a sequence of 8-bit ints that represents an MPEG Transport Stream packet. - - Args: - npkts: how many 188-byte packets to return - - FYI, each ATSC Data Frame contains two Data Fields, each of which contains - 312 data segments. Each transport stream packet maps to a data segment. - """ - r = [0] * (npkts * 188) - i = 0 - for j in range(npkts): - r[i+0] = MPEG_SYNC_BYTE - r[i+1] = random.randint(0, 127) # top bit (transport error bit) clear - i = i + 2 - for n in range(186): - r[i + n] = random.randint(0, 255) - i = i + 186 - - return r - - -def pad_stream(src, sizeof_total, sizeof_pad): - sizeof_valid = sizeof_total - sizeof_pad - assert sizeof_valid > 0 - assert (len(src) % sizeof_valid) == 0 - npkts = len(src) // sizeof_valid - dst = [0] * (npkts * sizeof_total) - for i in range(npkts): - src_s = i * sizeof_valid - dst_s = i * sizeof_total - dst[dst_s:dst_s + sizeof_valid] = src[src_s:src_s + sizeof_valid] - return dst - - -def depad_stream(src, sizeof_total, sizeof_pad): - sizeof_valid = sizeof_total - sizeof_pad - assert sizeof_valid > 0 - assert (len(src) % sizeof_total) == 0 - npkts = len(src) // sizeof_total - dst = [0] * (npkts * sizeof_valid) - for i in range(npkts): - src_s = i * sizeof_total - dst_s = i * sizeof_valid - dst[dst_s:dst_s + sizeof_valid] = src[src_s:src_s + sizeof_valid] - return dst - - diff --git a/gr-atsc/python/atsc/qa_atsc.py b/gr-atsc/python/atsc/qa_atsc.py deleted file mode 100755 index e6ea81a50e..0000000000 --- a/gr-atsc/python/atsc/qa_atsc.py +++ /dev/null @@ -1,225 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2006,2007,2013 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import sys - -from gnuradio import gr, gr_unittest, atsc, blocks -from gnuradio.atsc import atsc_utils - - -class memoize(object): - def __init__(self, thunk): - self.thunk = thunk - self.cached = False - self.value = None - - def __call__(self): - if self.cached: - return self.value - self.value = self.thunk() - self.cached = True - return self.value - - -""" -Make a fake transport stream that's big enough for our purposes. -We generate 8 full fields. This is relatively expensive. It -takes about 2 seconds to execute. -""" -make_transport_stream = \ - memoize(lambda : tuple(atsc_utils.make_fake_transport_stream_packet(8 * atsc.ATSC_DSEGS_PER_FIELD))) - - -def pad_transport_stream(src): - """ - An MPEG transport stream packet is 188 bytes long. Internally we use a packet - that is 256 bytes long to help with buffer alignment. This function adds the - appropriate trailing padding to convert each packet from 188 to 256 bytes. - """ - return atsc_utils.pad_stream(src, atsc.sizeof_atsc_mpeg_packet, atsc.sizeof_atsc_mpeg_packet_pad) - - -def depad_transport_stream(src): - """ - An MPEG transport stream packet is 188 bytes long. Internally we use a packet - that is 256 bytes long to help with buffer alignment. This function removes the - trailing padding to convert each packet from 256 back to 188 bytes. - """ - return atsc_utils.depad_stream(src, atsc.sizeof_atsc_mpeg_packet, atsc.sizeof_atsc_mpeg_packet_pad) - - -class vector_source_ts(gr.hier_block2): - """ - MPEG Transport stream source for testing. - """ - def __init__(self, ts): - """ - Pad tranport stream packets to 256 bytes and reformat appropriately. - - Args: - ts: MPEG transport stream. (sequence of ints in [0,255]; len(ts) % 188 == 0) - """ - - src = blocks.vector_source_b(pad_transport_stream(ts)) - s2v = blocks.stream_to_vector(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) - - gr.hier_block2.__init__(self, "vector_source_ts", - gr.io_signature(0, 0, 0), - s2v.output_signature()) - self.connect(src, s2v, self) - - -class vector_sink_ts(gr.hier_block2): - """ - MPEG Transport stream sink for testing. - """ - def __init__(self): - """ - """ - - v2s = blocks.vector_to_stream(gr.sizeof_char, atsc.sizeof_atsc_mpeg_packet) - self.sink = blocks.vector_sink_b() - gr.hier_block2.__init__(self, "vector_sink_ts", - v2s.input_signature(), - gr.io_signature(0, 0, 0)) - self.connect(self, v2s, self.sink) - - def data(self): - """ - Extracts tranport stream from sink and returns it to python. - - Depads tranport stream packets from 256 back to 188 bytes. - @rtype: tuple of ints in [0,255]; len(result) % 188 == 0 - """ - return tuple(depad_transport_stream(self.sink.data())) - - - -class qa_atsc(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - - # The tests are run in alphabetical order - - def test_loopback_000(self): - """ - Loopback randomizer to derandomizer - """ - src_data = make_transport_stream() - expected_result = src_data - - src = vector_source_ts(src_data) - rand = atsc.randomizer() - derand = atsc.derandomizer() - dst = vector_sink_ts() - - self.tb.connect(src, rand) - self.tb.connect(rand, derand) - self.tb.connect(derand, dst) - self.tb.run() - - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - def est_loopback_001(self): - """ - Loopback randomizer/rs_encoder to rs_decoder/derandomizer - """ - src_data = make_transport_stream() - expected_result = src_data - - src = vector_source_ts(src_data) - rand = atsc.randomizer() - rs_enc = atsc.rs_encoder() - rs_dec = atsc.rs_decoder() - derand = atsc.derandomizer() - dst = vector_sink_ts() - self.tb.connect(src, rand, rs_enc, rs_dec, derand, dst) - self.tb.run () - result_data = dst.data () - self.assertEqual (expected_result, result_data) - - def est_loopback_002(self): - """ - Loopback randomizer/rs_encoder/interleaver to - deinterleaver/rs_decoder/derandomizer - """ - src_data = make_transport_stream() - interleaver_delay = 52 - expected_result = src_data[0:len(src_data)-(interleaver_delay*atsc.ATSC_MPEG_PKT_LENGTH)] - - src = vector_source_ts(src_data) - rand = atsc.randomizer() - rs_enc = atsc.rs_encoder() - inter = atsc.interleaver() - deinter = atsc.deinterleaver() - rs_dec = atsc.rs_decoder() - derand = atsc.derandomizer() - dst = vector_sink_ts() - self.tb.connect(src, rand, rs_enc, inter, deinter, rs_dec, derand, dst) - self.tb.run () - result_data = dst.data () - result_data = result_data[(interleaver_delay*atsc.ATSC_MPEG_PKT_LENGTH):len(result_data)] - self.assertEqual (expected_result, result_data) - - - def est_loopback_003(self): - """ - Loopback randomizer/rs_encoder/interleaver/trellis_encoder - via ds_to_softds to - viterbi_decoder/deinterleaver/rs_decoder/derandomizer - """ - src_data = make_transport_stream() - interleaver_delay = 52 - viterbi_delay = 12 - expected_result = src_data[0:len(src_data)-((interleaver_delay+viterbi_delay)*atsc.ATSC_MPEG_PKT_LENGTH)] - - src = vector_source_ts(src_data) - rand = atsc.randomizer() - rs_enc = atsc.rs_encoder() - inter = atsc.interleaver() - trellis = atsc.trellis_encoder() - softds = atsc.ds_to_softds() - viterbi = atsc.viterbi_decoder() - deinter = atsc.deinterleaver() - rs_dec = atsc.rs_decoder() - derand = atsc.derandomizer() - dst = vector_sink_ts() - self.tb.connect(src, rand, rs_enc, inter, trellis, softds, viterbi, deinter, rs_dec, derand, dst) - self.tb.run () - result_data = dst.data ()[((interleaver_delay+viterbi_delay)*atsc.ATSC_MPEG_PKT_LENGTH):len(dst.data())] - self.assertEqual (expected_result, result_data) - - -if __name__ == '__main__': - gr_unittest.main() - - - - - - |