GNU Radio 3.5.1 C++ API
atsci_equalizer.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2002 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef _ATSC_EQUALIZER_H_
00024 #define _ATSC_EQUALIZER_H_
00025 
00026 #include <atsc_api.h>
00027 #include <atsci_syminfo.h>
00028 
00029 /*!
00030  * \brief abstract base class for ATSC equalizer
00031  */
00032 class ATSC_API atsci_equalizer {
00033 
00034 private:
00035 
00036   /*
00037    * have we seen a field sync since the last reset or problem?
00038    */
00039   bool  d_locked_p;
00040 
00041   /*
00042    * sample offset from the beginning of the last field sync we saw
00043    * to the beginning of our current input stream.  When we're locked
00044    * this will be in [0, 313*832] i.e., [0, 260416]
00045    */
00046   int   d_offset_from_last_field_sync;
00047 
00048   int   d_current_field;                // [0,1]
00049 
00050 
00051 public:
00052 
00053   // CREATORS
00054   atsci_equalizer ();
00055   virtual ~atsci_equalizer ();
00056   
00057   // MANIPULATORS
00058 
00059   /*!
00060    * \brief reset state (e.g., on channel change)
00061    *
00062    * Note, subclasses must invoke the superclass's method too!
00063    */
00064   virtual void reset ();
00065   
00066   /*!
00067    * \brief produce \p nsamples of output from given inputs and tags
00068    *
00069    * This is the main entry point.  It examines the input_tags
00070    * and local state and invokes the appropriate virtual function
00071    * to handle each sub-segment of the input data.
00072    *
00073    * \p input_samples must have (nsamples + ntaps() - 1) valid entries.
00074    * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] are 
00075    * referenced to compute the output values.
00076    *
00077    * \p input_tags must have nsamples valid entries.
00078    * input_tags[0] .. input_tags[nsamples - 1] are referenced to 
00079    * compute the output values.
00080    */
00081   virtual void filter (const float         *input_samples,
00082                        const atsc::syminfo *input_tags,
00083                        float               *output_samples,
00084                        int                  nsamples);
00085 
00086   // ACCESSORS
00087 
00088   /*!
00089    * \brief how much history the input data stream requires.
00090    *
00091    * This must return a value >= 1.  Think of this as the number
00092    * of samples you need to look at to compute a single output sample.
00093    */
00094   virtual int ntaps () const = 0;
00095 
00096   /*!
00097    * \brief how many taps are "in the future".  
00098    *
00099    * This allows us to handle what the ATSC folks call "pre-ghosts".
00100    * What it really does is allow the caller to jack with the offset 
00101    * between the tags and the data so that everything magically works out.
00102    *
00103    * npretaps () must return a value between 0 and ntaps() - 1.
00104    *
00105    * If npretaps () returns 0, this means that the equalizer will only handle
00106    * multipath "in the past."  I suspect that a good value would be something
00107    * like 15% - 20% of ntaps ().
00108    */
00109   virtual int npretaps () const = 0;
00110   
00111 
00112 protected:
00113 
00114   /*!
00115    * Input range is known NOT TO CONTAIN data segment syncs
00116    * or field syncs.  This should be the fast path.  In the
00117    * non decicion directed case, this just runs the input
00118    * through the filter without adapting it.
00119    *
00120    * \p input_samples has (nsamples + ntaps() - 1) valid entries.
00121    * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
00122    * referenced to compute the output values.
00123    */
00124   virtual void filter_normal (const float *input_samples,
00125                               float *output_samples,
00126                               int   nsamples) = 0;
00127 
00128   /*!
00129    * Input range is known to consist of only a data segment sync or a
00130    * portion of a data segment sync.  \p nsamples will be in [1,4].
00131    * \p offset will be in [0,3].  \p offset is the offset of the input
00132    * from the beginning of the data segment sync pattern.
00133    *
00134    * \p input_samples has (nsamples + ntaps() - 1) valid entries.
00135    * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
00136    * referenced to compute the output values.
00137    */
00138   virtual void filter_data_seg_sync (const float *input_samples,
00139                                      float *output_samples,
00140                                      int   nsamples,
00141                                      int   offset) = 0;
00142   
00143   /*!
00144    * Input range is known to consist of only a field sync segment or a
00145    * portion of a field sync segment.  \p nsamples will be in [1,832].
00146    * \p offset will be in [0,831].  \p offset is the offset of the input
00147    * from the beginning of the data segment sync pattern.  We consider the
00148    * 4 symbols of the immediately preceding data segment sync to be the
00149    * first symbols of the field sync segment.  \p which_field is in [0,1] 
00150    * and specifies which field (duh).
00151    *
00152    * \p input_samples has (nsamples + ntaps() - 1) valid entries.
00153    * input_samples[0] .. input_samples[nsamples - 1 + ntaps() - 1] may be
00154    * referenced to compute the output values.
00155    */
00156   virtual void filter_field_sync (const float *input_samples,
00157                                   float *output_samples,
00158                                   int   nsamples,
00159                                   int   offset,
00160                                   int   which_field) = 0;
00161 };
00162 
00163 
00164 #endif /* _ATSC_EQUALIZER_H_ */