Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

VrSum.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */ 00002 /* 00003 * Copyright 2001 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 2, 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., 59 Temple Place - Suite 330, 00020 * Boston, MA 02111-1307, USA. 00021 */ 00022 /* 00023 * Copyright 1997 Massachusetts Institute of Technology 00024 * 00025 * Permission to use, copy, modify, distribute, and sell this software and its 00026 * documentation for any purpose is hereby granted without fee, provided that 00027 * the above copyright notice appear in all copies and that both that 00028 * copyright notice and this permission notice appear in supporting 00029 * documentation, and that the name of M.I.T. not be used in advertising or 00030 * publicity pertaining to distribution of the software without specific, 00031 * written prior permission. M.I.T. makes no representations about the 00032 * suitability of this software for any purpose. It is provided "as is" 00033 * without express or implied warranty. 00034 * 00035 */ 00036 00037 #ifndef _VRSUM_H_ 00038 #define _VRSUM_H_ 00039 00040 #include <VrSigProc.h> 00041 #if defined (ENABLE_MMX) 00042 #include <VrMMX.h> 00043 #endif 00044 00045 template<class iType,class oType> 00046 class VrSum : public VrSigProc { 00047 protected: 00048 #if defined (ENABLE_MMX) 00049 char mmxReady; 00050 #endif 00051 public: 00052 virtual const char *name() { return "VrSum"; } 00053 virtual int work(VrSampleRange output, void *o[], 00054 VrSampleRange inputs[], void *i[]); 00055 virtual void initialize() { 00056 #if 0 00057 //work on 8-units blocks 00058 setHistory(8); 00059 setOutputSize(8); 00060 #endif 00061 }; 00062 VrSum(); 00063 }; 00064 00065 template<class iType,class oType> int 00066 VrSum<iType,oType>::work(VrSampleRange output, void *ao[], 00067 VrSampleRange inputs[], void *ai[]) 00068 { 00069 iType **i = (iType **)ai; 00070 oType **o = (oType **)ao; 00071 int size = output.size; 00072 int ni = getNumberInputs(); 00073 oType temp; 00074 00075 while(size-- > 0) { 00076 #if 0 00077 int units = availableUnits(); 00078 if(availableSpace() < units ) units = availableSpace(); 00079 if (n < units) units = n; 00080 00081 #ifdef XENABLE_MMX 00082 if(mmxReady && getNumberInputs()>1) { 00083 units=units-units%8; 00084 if (PARANOID && units <= 0){ 00085 fprintf(stderr, "Can't write any data in VrSum\n"); 00086 abort (); 00087 } 00088 00089 mmxAdd(inputHistoryPtrN(0), inputHistoryPtrN(1), 00090 units, outputWritePtr()); 00091 incReadPtrN(0,units); 00092 incReadPtrN(1,units); 00093 int jj=2; 00094 while(jj < getNumberInputs()){ 00095 mmxAdd(outputWritePtr(), inputHistoryPtrN(jj), 00096 units, outputWritePtr()); 00097 incReadPtrN(jj,units); 00098 jj++; 00099 } 00100 00101 } else 00102 #endif 00103 #endif 00104 { 00105 temp = *i[0]++; 00106 int j=1; 00107 while(j < ni) 00108 temp += *i[j++]++; 00109 *o[0]++ = temp; 00110 } 00111 } 00112 return output.size; 00113 } 00114 00115 template<class iType,class oType> 00116 VrSum<iType,oType>::VrSum() 00117 : VrSigProc(1, sizeof(iType), sizeof(oType)) 00118 { 00119 #ifdef ENABLE_MMX 00120 mmxReady=queryMMX(); 00121 #endif 00122 } 00123 #endif

Generated on Wed Aug 4 02:22:06 2004 for GNU Radio by doxygen 1.3.8