- fixed peak sorting
git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@461 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -29,21 +29,7 @@ namespace jay {
|
||||
class peak_detect_impl : public peak_detect
|
||||
{
|
||||
private:
|
||||
struct Compare
|
||||
{
|
||||
float const *m_pData;
|
||||
Compare(float const *pData)
|
||||
: m_pData(pData)
|
||||
{
|
||||
|
||||
}
|
||||
bool operator() (int i,int j)
|
||||
{
|
||||
return (m_pData[i] < m_pData[j]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
float m_framerate;
|
||||
float m_peak_height_min;
|
||||
int m_peak_width_min;
|
||||
@@ -56,6 +42,7 @@ namespace jay {
|
||||
float *m_pXm;
|
||||
float *m_pXd;
|
||||
int *m_pPeakPos;
|
||||
int *m_pPeakPos_final;
|
||||
float *m_pPeakBox_rel;
|
||||
float *m_pPeakBox_abs;
|
||||
uint64_t m_frameCount;
|
||||
@@ -67,12 +54,31 @@ namespace jay {
|
||||
|
||||
// Where all the action really happens
|
||||
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
|
||||
private:
|
||||
void fill(float *pDst, int length, float value);
|
||||
float mean(float *pSrc, int length);
|
||||
int threshold(float *pDst, float *pSrc, int length, float thresh);
|
||||
int findPeakPos(int *pDst, float *pSrc, int length);
|
||||
|
||||
int cmp(const void *a, const void *b);
|
||||
inline void sort(float const * const pData, int *pPos, int numPos)
|
||||
{
|
||||
int n = numPos;
|
||||
do
|
||||
{
|
||||
int newn = 1;
|
||||
for (int i=0; i < (n-1); i++)
|
||||
{
|
||||
if (pData[pPos[i]] < pData[pPos[i+1]])
|
||||
{
|
||||
int temp = pPos[i+1];
|
||||
pPos[i+1] = pPos[i];
|
||||
pPos[i] = temp;
|
||||
newn = i+1;
|
||||
} // ende if
|
||||
} // ende for
|
||||
n = newn;
|
||||
} while (n > 1);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace jay
|
||||
|
||||
Reference in New Issue
Block a user