00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _GRATSCSYMBOLMAPPER_H_
00024 #define _GRATSCSYMBOLMAPPER_H_
00025
00026
00027 #include <VrInterpolatingSigProcNoWork.h>
00028 #include <atsc_types.h>
00029 #include <gr_nco.h>
00030
00040 template<class oType>
00041 class GrAtscSymbolMapper
00042 : public VrInterpolatingSigProcNoWork<atsc_data_segment, oType> {
00043
00044 public:
00045 GrAtscSymbolMapper ()
00046 : VrInterpolatingSigProcNoWork<atsc_data_segment, oType>(1, INTERP_FACTOR) {};
00047
00048 ~GrAtscSymbolMapper () {};
00049
00050 const char *name () { return "GrAtscSymbolMapper"; }
00051
00052 int work (VrSampleRange output, void *ao[],
00053 VrSampleRange inputs[], void *ai[]);
00054
00055 protected:
00056 static const int INTERP_FACTOR = ATSC_DATA_SEGMENT_LENGTH;
00057 };
00058
00059
00060 template<class oType>
00061 int
00062 GrAtscSymbolMapper<oType>::work (VrSampleRange output, void *ao[],
00063 VrSampleRange inputs[], void *ai[])
00064 {
00065 atsc_data_segment *in = ((atsc_data_segment **) ai)[0];
00066 oType *out = ((oType **) ao)[0];
00067
00068 assert ((output.size % INTERP_FACTOR) == 0);
00069
00070 static const float pilot_add = 1.25;
00071 static const float map[8] = {
00072 -7 + pilot_add,
00073 -5 + pilot_add,
00074 -3 + pilot_add,
00075 -1 + pilot_add,
00076 1 + pilot_add,
00077 3 + pilot_add,
00078 5 + pilot_add,
00079 7 + pilot_add
00080 };
00081
00082 unsigned int oo = 0;
00083 unsigned int nsegs = output.size / INTERP_FACTOR;
00084
00085 for (unsigned int n = 0; n < nsegs; n++){
00086 unsigned char *symbol = in[n].data;
00087
00088 for (int i = 0; i < ATSC_DATA_SEGMENT_LENGTH; i++){
00089 out[oo++] = (oType) map[symbol[i] & 0x7];
00090 }
00091 }
00092
00093 assert (oo == output.size);
00094 return output.size;
00095 }
00096
00097 #endif