GNU Radio 3.7.1 C++ API
|
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 _GRATSCSYMBOLMAPPER_H_ 00024 #define _GRATSCSYMBOLMAPPER_H_ 00025 00026 00027 #include <VrInterpolatingSigProcNoWork.h> 00028 #include <gnuradio/atsc/types.h> 00029 #include <gnuradio/blocks/nco.h> 00030 00031 /*! 00032 * \brief take atsc_data_segments and map them to symbols. 00033 * 00034 * Input is a stream of atsc_data_segments. 00035 * Output is a stream of symbols at 1x the symbol rate 00036 * 00037 * This module performs the signal mapping & pilot addition. 00038 */ 00039 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 /* _GRATSCSYMBOLMAPPER_H_ */