3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <atsc_viterbi_decoder.h>
28 #include <gr_io_signature.h>
29 #include <atsc_consts.h>
33 atsc_viterbi_decoder_sptr
34 atsc_make_viterbi_decoder()
36 return atsc_viterbi_decoder_sptr(new atsc_viterbi_decoder());
39 atsc_viterbi_decoder::atsc_viterbi_decoder()
40 : gr_sync_block("atsc_viterbi_decoder",
41 gr_make_io_signature(1, 1, sizeof(atsc_soft_data_segment)),
42 gr_make_io_signature(1, 1, sizeof(atsc_mpeg_packet_rs_encoded))),
45 set_output_multiple(atsci_viterbi_decoder::NCODERS);
50 atsc_viterbi_decoder::work (int noutput_items,
51 gr_vector_const_void_star &input_items,
52 gr_vector_void_star &output_items)
54 const atsc_soft_data_segment *in = (const atsc_soft_data_segment *) input_items[0];
55 atsc_mpeg_packet_rs_encoded *out = (atsc_mpeg_packet_rs_encoded *) output_items[0];
57 assert (noutput_items % atsci_viterbi_decoder::NCODERS == 0);
59 // find the first mod 12 boundary to begin decoding
61 for (start = 0; start < atsci_viterbi_decoder::NCODERS; start++){
62 assert (in[start].pli.regular_seg_p ());
63 if ((in[start].pli.segno () % atsci_viterbi_decoder::NCODERS) == 0)
67 if (start == atsci_viterbi_decoder::NCODERS){
68 // we didn't find a mod 12 boundary. There's some kind of problem
69 // upstream of us (not yet sync'd??)
70 cerr << "!!!atsc_viterbi_decoder: no mod-12 boundary found\7\n";
73 else if (start != last_start){
74 cerr << "atsc_viterbi_decoder: new starting offset = " << start
79 for (int i = 0; i < atsci_viterbi_decoder::NCODERS; i += atsci_viterbi_decoder::NCODERS){
80 d_viterbi_decoder.decode(&out[i], &in[i + start]);
82 return atsci_viterbi_decoder::NCODERS;