GNU Radio 3.5.1 C++ API
atsci_fs_correlator_naive.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_FS_CORRELATOR_NAIVE_H_
00024 #define _ATSC_FS_CORRELATOR_NAIVE_H_
00025 
00026 #include <atsc_api.h>
00027 #include <atsci_fs_correlator.h>
00028 
00029 /*!
00030  * \brief Naive concrete implementation of field sync correlator
00031  */
00032 class ATSC_API atsci_fs_correlator_naive : public atsci_fs_correlator {
00033 
00034  private:
00035   static const int      SRSIZE = 1024;          // must be power of two
00036   int                   d_index;                // points at oldest sample
00037   float                 d_sample_sr[SRSIZE];    // sample shift register
00038   unsigned char         d_bit_sr[SRSIZE];       // binary decision shift register
00039 
00040   static const int      OFFSET_511 = 0;         // offset to PN 511 pattern
00041   static const int      LENGTH_511 = 511 + 4;   // length of PN 511 pattern (+ 4 seg sync)
00042   static const int      OFFSET_2ND_63 = 578;    // offset to second PN 63 pattern
00043   static const int      LENGTH_2ND_63 = 63;     // length of PN 63 pattern
00044 
00045   static unsigned char  s_511[LENGTH_511];      // PN 511 pattern
00046   static unsigned char  s_63[LENGTH_2ND_63];    // PN 63 pattern
00047 
00048   inline static int wrap (int index){ return index & (SRSIZE - 1); }
00049   inline static int incr (int index){ return wrap (index + 1); }
00050   inline static int decr (int index){ return wrap (index - 1); }
00051 
00052  public:
00053 
00054   // CREATORS
00055   atsci_fs_correlator_naive ();
00056   ~atsci_fs_correlator_naive ();
00057 
00058   // MANIPULATORS
00059   virtual void reset ();
00060   void filter (float input_sample, float *output_sample, float *output_tag);
00061 
00062   // ACCESSORS
00063 
00064   //! return delay in samples from input to output
00065   int delay () const;
00066   
00067 };
00068 
00069 
00070 #endif /* _ATSC_FS_CORRELATOR_NAIVE_H_ */