00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <string>
00023 #include <string.h>
00024
00025 #ifndef _ATSC_SLIDING_CORRELATOR_H_
00026 #define _ATSC_SLIDING_CORRELATOR_H_
00027
00028 extern const unsigned char atsc_pn511[511];
00029 extern const unsigned char atsc_pn63[63];
00030
00034 class atsci_sliding_correlator {
00035 public:
00036
00037 atsci_sliding_correlator ();
00038 ~atsci_sliding_correlator (){};
00039
00041
00042
00043
00044 int input_bit (int bit);
00045
00047
00048
00049
00050 int input_int (int sample){
00051 return input_bit (sample < 0 ? 0 : 1);
00052 }
00053
00055
00056
00057
00058 int input_float (float sample){
00059 return input_bit (sample < 0 ? 0 : 1);
00060 }
00061
00062 void reset () { input.reset (); }
00063
00064 private:
00065
00066 typedef unsigned long srblock;
00067 static const int bits_per_char = 8;
00068 static const int srblock_bitsize = sizeof (srblock) * bits_per_char;
00069 static const int NSRBLOCKS = (511 + srblock_bitsize - 1) / srblock_bitsize;
00070
00071 class shift_reg {
00072 public:
00073 shift_reg () { reset (); }
00074 void reset () { memset (d, 0, sizeof (d)); }
00075 void shift_in (int bit);
00076 srblock d[NSRBLOCKS];
00077 };
00078
00079 shift_reg mask;
00080 shift_reg input;
00081 shift_reg and_mask;
00082 };
00083
00084 #endif