kopia lustrzana https://github.com/M17-Project/M17_Implementations
Porównaj commity
2 Commity
b52d1c1fd0
...
9a5c06be78
Autor | SHA1 | Data |
---|---|---|
Wojciech Kaczmarski | 9a5c06be78 | |
Wojciech Kaczmarski | cd77e8ae76 |
|
@ -14,7 +14,7 @@
|
|||
|
||||
float sample; //last raw sample from the stdin
|
||||
float last[8]; //look-back buffer for finding syncwords
|
||||
float xcorr, meanx, normx; //cross correlation related variables for finding syncwords
|
||||
float dist; //Euclidean distance for finding syncwords in the symbol stream
|
||||
float pld[SYM_PER_PLD]; //raw frame symbols
|
||||
uint16_t soft_bit[2*SYM_PER_PLD]; //raw frame soft bits
|
||||
uint16_t d_soft_bit[2*SYM_PER_PLD]; //deinterleaved soft bits
|
||||
|
@ -91,6 +91,18 @@ void decode_callsign(uint8_t *outp, const uint8_t *inp)
|
|||
outp[i]=0;
|
||||
}
|
||||
|
||||
float eucl_norm(const float* in1, const int8_t* in2, uint8_t len)
|
||||
{
|
||||
float tmp = 0.0f;
|
||||
|
||||
for(uint8_t i=0; i<len; i++)
|
||||
{
|
||||
tmp += powf(in1[i]-(float)in2[i], 2.0f);
|
||||
}
|
||||
|
||||
return sqrt(tmp);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
while(1)
|
||||
|
@ -108,35 +120,28 @@ int main(void)
|
|||
|
||||
last[7]=sample;
|
||||
|
||||
//calculate cross-correlation
|
||||
meanx=0.0f;
|
||||
for(uint8_t i=0; i<8; i++)
|
||||
meanx+=last[i];
|
||||
meanx=meanx/8.0f;
|
||||
//calculate euclidean norm
|
||||
dist = eucl_norm(last, str_sync, 8);
|
||||
|
||||
xcorr=0.0f;
|
||||
normx=0.0f;
|
||||
for(uint8_t i=0; i<8; i++)
|
||||
{
|
||||
xcorr+=(last[i]-meanx)*(str_sync[i]-SW_MEAN);
|
||||
normx+=(last[i]-meanx)*(last[i]-meanx);
|
||||
}
|
||||
|
||||
xcorr=xcorr/(sqrtf(normx)*SW_STD);
|
||||
|
||||
//printf("%f\n", xcorr);
|
||||
|
||||
if(xcorr>XCORR_THRESH) //Frame syncword detected
|
||||
if(dist<DIST_THRESH) //frame syncword detected
|
||||
{
|
||||
//fprintf(stderr, "str_sync dist: %3.5f\n", dist);
|
||||
syncd=1;
|
||||
pushed=0;
|
||||
fl=0;
|
||||
}
|
||||
else if(xcorr<-XCORR_THRESH) //LSF syncword
|
||||
else
|
||||
{
|
||||
syncd=1;
|
||||
pushed=0;
|
||||
fl=1;
|
||||
//calculate euclidean norm again, this time against LSF syncword
|
||||
dist = eucl_norm(last, lsf_sync, 8);
|
||||
|
||||
if(dist<DIST_THRESH) //LSF syncword
|
||||
{
|
||||
//fprintf(stderr, "lsf_sync dist: %3.5f\n", dist);
|
||||
syncd=1;
|
||||
pushed=0;
|
||||
fl=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Ładowanie…
Reference in New Issue