Skip to content

Commit

Permalink
added libcorrect source with inline popcnt function and 32 and 64 bit
Browse files Browse the repository at this point in the history
windows libraries. reduced signal threshold from 0.5 to 0.6.
  • Loading branch information
jontio committed Dec 29, 2017
1 parent f336ce5 commit 91086db
Show file tree
Hide file tree
Showing 81 changed files with 5,724 additions and 119 deletions.
17 changes: 10 additions & 7 deletions JAERO/DSP.cpp
Expand Up @@ -525,27 +525,30 @@ double DiffDecode::UpdateSoft(double soft)
double retval = 0;

// if the previous value is a zero and the current also zero just return zero
if(soft < 0 && lastsoftstate < 0){
if(soft < 0 && lastsoftstate < 0)
{

// last value is negative so just return to indicate a zero
retval = lastsoftstate;
lastsoftstate = soft;
}

// if the previous value is one and the current also one
else if(soft > 0 && lastsoftstate > 0){
// if the previous value is one and the current also one
else if(soft > 0 && lastsoftstate > 0)
{

// last value is postive so flip sign to indicate zero
retval =- lastsoftstate;
lastsoftstate = soft;
}
else{
}
else
{


// retval and soft have different signs, so always return positive
retval = std::abs(lastsoftstate);
retval = std::fabs(lastsoftstate);
lastsoftstate = soft;
}
}

return retval;

Expand Down
120 changes: 59 additions & 61 deletions JAERO/aerol.cpp
Expand Up @@ -1008,17 +1008,18 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit
quint16 bit=0;
quint16 soft_bit=0;

for(int i=0;i<bits.size();i++)
for(int i=0;i<bits.size();i++)
{


if(soft){
if(soft)
{
if(((uchar)bits[i])>=128)bit=1;
else bit=0;

}else{
bit=bits[i];
}
else
{
bit=bits[i];
}
soft_bit=bits[i];

//for burst mode to allow tolerance of UW
Expand All @@ -1044,15 +1045,15 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit
gotsync=0;
} else gotsync_last=0;
}
else
{
else
{
gotsync=preambledetectorphaseinvariantreal.Update(bit);
if(!gotsync_last)
{
gotsync_last=gotsync;
gotsync=0;
} else gotsync_last=0;
}
}

//for 10500 UW should be about 80 samples after start of packet signal from demodulator if not we have a false positive
if(gotsync&&burstmode)
Expand Down Expand Up @@ -1086,47 +1087,55 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit
{
bit=1-bit;

if(soft_bit > 128){
if(soft_bit > 128)
{
soft_bit = 255-soft_bit;
} else if (soft_bit < 128){
soft_bit = 255-soft_bit;
}
else if (soft_bit < 128)
{
soft_bit = 255-soft_bit;
}
}
}

} //non 10500 burst mode use a phase invariant preamble detector
else if(burstmode){


else if(burstmode)
{

bool inverted = mskBurstDetector.inverted;
bool inverted = mskBurstDetector.inverted;

gotsync=mskBurstDetector.Update(bit);
gotsync=mskBurstDetector.Update(bit);

if( muw > 250 && gotsync){
if( muw > 250 && gotsync)
{

if(inverted != mskBurstDetector.inverted){
mskBurstDetector.inverted = inverted;
}
gotsync = false;
if(inverted != mskBurstDetector.inverted)
{
mskBurstDetector.inverted = inverted;
}
gotsync = false;

}
}

if(mskBurstDetector.inverted){
if(mskBurstDetector.inverted)
{

bit=1-bit;

if(soft_bit > 128){
if(soft_bit > 128)
{
soft_bit = 255-soft_bit;
} else if (soft_bit < 128){
soft_bit = 255-soft_bit;
}
else if (soft_bit < 128)
{
soft_bit = 255-soft_bit;
}
}
}
else{

}
else
{
gotsync=preambledetector.Update(bit);
}
}

if(cntr<1000000000)cntr++;
if(cntr<16)
Expand Down Expand Up @@ -1186,28 +1195,16 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit

RTChannelDeleaveFECScram::ReturnResult result;

if(useingOQPSK){

if(soft){
result = rtchanneldeleavefecscram.update(soft_bit);
}else
{
result = rtchanneldeleavefecscram.update(bit);

}

}else{

if(soft){


result = rtchanneldeleavefecscram.updateMSK(soft_bit);
}
else{
result = rtchanneldeleavefecscram.updateMSK(bit);
}

if(useingOQPSK)
{
if(soft)result = rtchanneldeleavefecscram.update(soft_bit);
else result = rtchanneldeleavefecscram.update(bit);
}
else
{
if(soft)result = rtchanneldeleavefecscram.updateMSK(soft_bit);
else result = rtchanneldeleavefecscram.updateMSK(bit);
}

switch(result)
{
Expand Down Expand Up @@ -1410,7 +1407,8 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit

}

else{
else
{

// its a p channel

Expand Down Expand Up @@ -1773,11 +1771,11 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit


}
else
{
else
{
decline+=" Bad CRC\n";
//allgood=false;
}
}

/*if(crc_calc==crc_rec)qDebug()<<k<<((QString)"").sprintf("rec = %02X", crc_rec)<<((QString)"").sprintf("calc = %02X", crc_calc)<<"OK"<<unencoded_BER_estimate*100.0;
else
Expand All @@ -1803,7 +1801,7 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit
}


}
}


}
Expand Down Expand Up @@ -1852,8 +1850,8 @@ QByteArray &AeroL::Decode(QVector<short> &bits, bool soft)//0 bit --> oldest bit

}

if((!datacd)&&(!burstmode)){

if((!datacd)&&(!burstmode))
{
decodedbytes.clear();
}

Expand Down Expand Up @@ -1896,8 +1894,8 @@ qint64 AeroL::writeData(const char *data, qint64 len)
return len;
}

void AeroL::processDemodulatedSoftBits(const QVector<short> &soft_bits){

void AeroL::processDemodulatedSoftBits(const QVector<short> &soft_bits)
{

sbits.clear();

Expand Down
10 changes: 4 additions & 6 deletions JAERO/aerol.h
Expand Up @@ -542,8 +542,8 @@ class RTChannelDeleaveFECScram

ReturnResult updateMSK(int bit)
{
if(blockptr>=block.size()){

if(blockptr>=block.size())
{
return FULL;
}
block[blockptr]=bit;
Expand All @@ -558,13 +558,11 @@ class RTChannelDeleaveFECScram
bool cont = false;


if((((blockptr-(64*5))%(64*3))==0) && (blockptr /64 == 5 || blockptr /64 == targetBlocks || blockptr/64 == 8 || blockptr/64 == 50)){

if((((blockptr-(64*5))%(64*3))==0) && (blockptr /64 == 5 || blockptr /64 == targetBlocks || blockptr/64 == 8 || blockptr/64 == 50))
{
cont = true;

}


//test if interleaver length works
if(cont)//true for R and T packets
{
Expand Down
10 changes: 6 additions & 4 deletions JAERO/burstmskdemodulator.cpp
Expand Up @@ -445,7 +445,8 @@ qint64 BurstMskDemodulator::writeData(const char *data, qint64 len)
int size_base = 126;
int size_top = 74;

if(fb < 1200){
if(fb < 1200)
{

size_base = 150;
size_top = 74;
Expand Down Expand Up @@ -494,7 +495,8 @@ qint64 BurstMskDemodulator::writeData(const char *data, qint64 len)
int maxtopposhigh =0;
double maxtophigh =0;

for(int i=0; i < out_top.size(); i++){
for(int i=0; i < out_top.size(); i++)
{

if(i > 50)
{
Expand Down Expand Up @@ -756,7 +758,7 @@ qint64 BurstMskDemodulator::writeData(const char *data, qint64 len)

double imagin = diffdecode.UpdateSoft(pt_msk.imag());

int ibit=qRound((imagin)*127.0+128.0);
int ibit=qRound(0.75*(imagin)*127.0+128.0);
if(ibit>255)ibit=255;
if(ibit<0)ibit=0;

Expand All @@ -766,7 +768,7 @@ qint64 BurstMskDemodulator::writeData(const char *data, qint64 len)

real =- real;

ibit=qRound((real)*127.0+128.0);
ibit=qRound(0.75*(real)*127.0+128.0);

if(ibit>255)ibit=255;
if(ibit<0)ibit=0;
Expand Down
2 changes: 1 addition & 1 deletion JAERO/burstmskdemodulator.h
Expand Up @@ -41,7 +41,7 @@ class BurstMskDemodulator : public QIODevice
fb=125;//bps
Fs=8000;//Hz
symbolspercycle=16;
signalthreshold=0.5;
signalthreshold=0.6;
}
};
explicit BurstMskDemodulator(QObject *parent);
Expand Down
4 changes: 2 additions & 2 deletions JAERO/burstoqpskdemodulator.cpp
Expand Up @@ -694,13 +694,13 @@ void BurstOqpskDemodulator::writeDataSlot(const char *data, qint64 len)



int ibit=qRound(pt_qpsk.imag()*127.0+128.0);
int ibit=qRound(0.75*pt_qpsk.imag()*127.0+128.0);
if(ibit>255)ibit=255;
if(ibit<0)ibit=0;

RxDataBits.push_back((uchar)ibit);

ibit=qRound(pt_qpsk.real()*127.0+128.0);
ibit=qRound(0.75*pt_qpsk.real()*127.0+128.0);
if(ibit>255)ibit=255;
if(ibit<0)ibit=0;

Expand Down
2 changes: 1 addition & 1 deletion JAERO/burstoqpskdemodulator.h
Expand Up @@ -37,7 +37,7 @@ class BurstOqpskDemodulator : public QIODevice
lockingbw=10500;//Hz
fb=10500;//bps
Fs=48000;//Hz
signalthreshold=0.5;
signalthreshold=0.6;
channel_stereo=false;
}
};
Expand Down
8 changes: 5 additions & 3 deletions JAERO/jconvolutionalcodec.cpp
Expand Up @@ -135,13 +135,15 @@ QByteArray& JConvolutionalCodec::Hard_To_Soft_Convert(QByteArray& hard_bits_in)

for(int i=0;i<hard_bits_in.size();i++)
{
if(((uchar)(hard_bits_in.at(i)))==0){
if(((uchar)(hard_bits_in.at(i)))==0)
{
hard_bits_in[i] = uchar(0);
}
else{
else
{
hard_bits_in[i] = uchar(255);

}
}
}
return hard_bits_in;
}
Expand Down
4 changes: 2 additions & 2 deletions JAERO/mskdemodulator.cpp
Expand Up @@ -486,7 +486,7 @@ qint64 MskDemodulator::writeData(const char *data, qint64 len)

double imagin = diffdecode.UpdateSoft(thisonpt.imag());

int ibit=qRound((imagin)*127.0+128.0);
int ibit=qRound(0.75*(imagin)*127.0+128.0);
if(ibit>255)ibit=255;
if(ibit<0)ibit=0;

Expand All @@ -496,7 +496,7 @@ qint64 MskDemodulator::writeData(const char *data, qint64 len)

real =- real;

ibit=qRound((real)*127.0+128.0);
ibit=qRound(0.75*(real)*127.0+128.0);

if(ibit>255)ibit=255;
if(ibit<0)ibit=0;
Expand Down
2 changes: 1 addition & 1 deletion JAERO/mskdemodulator.h
Expand Up @@ -37,7 +37,7 @@ class MskDemodulator : public QIODevice
fb=125;//bps
Fs=8000;//Hz
symbolspercycle=16;
signalthreshold=0.5;
signalthreshold=0.6;
}
};
explicit MskDemodulator(QObject *parent);
Expand Down

0 comments on commit 91086db

Please sign in to comment.