3 * Copyright 2002 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 3, 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.
23 #include <GrAtscDerandomizer.h>
25 // typedefs for fundamental i/o types
27 typedef atsc_mpeg_packet_no_sync iType;
28 typedef atsc_mpeg_packet oType;
30 static const int NUMBER_OF_OUTPUTS = 1; // # of output streams (almost always one)
33 GrAtscDerandomizer::GrAtscDerandomizer ()
34 : VrHistoryProc<iType,oType> (NUMBER_OF_OUTPUTS)
36 // 1 + number of extra input elements at which we look. This is
37 // used by the superclass's forecast routine to get us the correct
38 // range on our inputs.
39 // We're one-to-one input-to-output so set it to 1.
42 // any other init here.
45 GrAtscDerandomizer::~GrAtscDerandomizer ()
47 // Anything that isn't automatically cleaned up...
51 * This is the real work horse. In general this interface can handle
52 * multiple streams of input and output, but we almost always
53 * use a single input and output stream.
57 GrAtscDerandomizer::work (VrSampleRange output, void *ao[],
58 VrSampleRange inputs[], void *ai[])
60 // If we have state that persists across invocations (e.g., we have
61 // instance variables that we modify), we must use the sync method
62 // to indicate to the scheduler that our output must be computed in
63 // order. This doesn't keep other things from being run in
64 // parallel, it just means that at any given time, there is only a
65 // single thread working this code, and that the scheduler will
66 // ensure that we are asked to produce output that is contiguous and
67 // that will be presented to us in order of increasing time.
69 // We have state, the current contents of the LFSR in the randomizer, hence
74 // construct some nicer i/o pointers to work with.
76 iType *in = ((iType **) ai)[0];
77 oType *out = ((oType **) ao)[0];
80 // We must produce output.size units of output.
82 for (unsigned int i = 0; i < output.size; i++){
84 assert (in[i].pli.regular_seg_p ());
86 if (in[i].pli.first_regular_seg_p ())
89 rand.derandomize (out[i], in[i]);
91 // take a look at the transport error bit in the pipeline info
92 // and set bit as required
94 if (in[i].pli.transport_error_p ())
95 out[i].data[1] |= MPEG_TRANSPORT_ERROR_BIT;
97 out[i].data[1] &= ~MPEG_TRANSPORT_ERROR_BIT;
101 // Return the number of units we produced.
102 // Note that for all intents and purposes, it is an error to
103 // produce less than you are asked for.