diff --git a/RTCP/CNProc/src/BeamFormer.cc b/RTCP/CNProc/src/BeamFormer.cc index c8c537bf53edb016dda830aaba0b263de3986590..a2f9415b0f63d9a4ab04254480520dd24dfa7f82 100644 --- a/RTCP/CNProc/src/BeamFormer.cc +++ b/RTCP/CNProc/src/BeamFormer.cc @@ -74,27 +74,10 @@ void BeamFormer::initStationMergeMap( const std::vector<unsigned> &station2BeamF } } -// functor for determining whether a station should be included based on -// its amount of flags -class stationValidator -{ - public: - stationValidator( const SampleData<> *samples, const unsigned upperBound ): - samples(samples), upperBound(upperBound) {} - - bool operator ()(unsigned stationNr) const - { - return samples->flags[stationNr].count() <= upperBound; - } - private: - const SampleData<> *samples; - const unsigned upperBound; -}; void BeamFormer::mergeStationFlags( const SampleData<> *in, SampleData<> *out ) { const unsigned upperBound = static_cast<unsigned>(itsNrSamplesPerIntegration * BeamFormer::MAX_FLAGGED_PERCENTAGE); - const stationValidator isValid( in, upperBound ); for( unsigned d = 0; d < itsMergeDestStations.size(); d++ ) { const unsigned destStation = itsMergeDestStations[d]; @@ -103,12 +86,18 @@ void BeamFormer::mergeStationFlags( const SampleData<> *in, SampleData<> *out ) validSourceStations.clear(); - // copy valid stations from sourceStations -> validSourceStations - for( unsigned s = 0; s < sourceStations.size(); s++ ) { - if( isValid( sourceStations[s] ) ) { - validSourceStations.push_back( sourceStations[s] ); + if (sourceStations.size() == 1) { + // source and dest are the same (no beamforming), so checking for + // MAX_FLAGGED_PERCENTAGE is unnecessary conservative + validSourceStations.push_back( sourceStations[0] ); + } else { + // copy valid stations from sourceStations -> validSourceStations + for( unsigned s = 0; s < sourceStations.size(); s++ ) { + if( in->flags[sourceStations[s]].count() <= upperBound ) { + validSourceStations.push_back( sourceStations[s] ); + } } - } + } // conservative flagging: flag output if any input was flagged if( validSourceStations.empty() ) { @@ -133,19 +122,18 @@ void BeamFormer::mergeStationFlags( const SampleData<> *in, SampleData<> *out ) void BeamFormer::computeFlags( const SampleData<> *in, SampleData<> *out, unsigned nrBeams ) { const unsigned upperBound = static_cast<unsigned>(itsNrSamplesPerIntegration * BeamFormer::MAX_FLAGGED_PERCENTAGE); - const stationValidator isValid( in, upperBound ); // determine which stations have too much flagged data // also, source stations from a merge are set as invalid, since the ASM implementation // can only combine consecutive stations, we have to consider them. itsNrValidStations = 0; - for(unsigned i = 0; i < itsNrStations; i++ ) { + for (unsigned i = 0; i < itsNrStations; i++) { itsValidStations[i] = false; } - for(std::vector<unsigned>::const_iterator stat = itsMergeDestStations.begin(); stat != itsMergeDestStations.end(); stat++ ) { - if( isValid( *stat ) ) { - itsValidStations[*stat] = true; + for (unsigned i = 0; i < itsMergeDestStations.size(); i++) { + if (in->flags[i].count() <= upperBound) { + itsValidStations[i] = true; itsNrValidStations++; } }