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