Skip to content

Commit

Permalink
Finish the System Fusion AMBE regeneration.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Apr 28, 2016
1 parent d517a1d commit a41cd74
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
29 changes: 13 additions & 16 deletions AMBEFEC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,16 +651,19 @@ unsigned int CAMBEFEC::regenerateYSF3(unsigned char* bytes) const
}
bit += 23U;

// De-whiten some bits
unsigned int prn = 0x00U;
for (unsigned int i = 0U; i < 12U; i++)
prn = (prn << 1) | (temp[i] ? 0x01U : 0x00U);
prn <<= 4;
for (unsigned int i = 23U; i < 137U; i++) {
prn = ((173U * prn) + 13849U) & 0xFFFFU;
temp[i] ^= (prn & 0x80U) == 0x80U;
bool prn[114U];

// Create the whitening vector and save it for future use
unsigned int p = 16U * c0data;
for (unsigned int i = 0U; i < 114U; i++) {
p = (173U * p + 13849U) % 65536U;
prn[i] = p >= 32768U;
}

// De-whiten some bits
for (unsigned int i = 0U; i < 114U; i++)
temp[i + 23U] ^= prn[i];

// c1
g1 = 0U;
for (unsigned int i = 0U; i < 23U; i++)
Expand Down Expand Up @@ -709,14 +712,8 @@ unsigned int CAMBEFEC::regenerateYSF3(unsigned char* bytes) const
CHamming::decode15113_1(bit);

// Whiten some bits
prn = 0x00U;
for (unsigned int i = 0U; i < 12U; i++)
prn = (prn << 1) | (temp[i] ? 0x01U : 0x00U);
prn <<= 4;
for (unsigned int i = 23U; i < 137U; i++) {
prn = ((173U * prn) + 13849U) & 0xFFFFU;
temp[i] ^= (prn & 0x80U) == 0x80U;
}
for (unsigned int i = 0U; i < 114U; i++)
temp[i + 23U] ^= prn[i];

unsigned int errors = 0U;
for (unsigned int i = 0U; i < 144U; i++) {
Expand Down
1 change: 0 additions & 1 deletion ISSUES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ Split transmit and mode hang times.

System Fusion
-------------
Finish the VW (Voice FR Mode) AMBE FEC.
Finish the callsign extraction from the header and trailer.
4 changes: 2 additions & 2 deletions YSFControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ bool CYSFControl::writeModem(unsigned char *data)
default: // YSF_DT_VOICE_FR_MODE
if (fn != 0U || ft != 1U) {
// The first packet after the header is odd, don't try and regenerate it
// m_errs += m_payload.processVoiceFRModeAudio(data + 2U);
// m_bits += 720U;
m_errs += m_payload.processVoiceFRModeAudio(data + 2U);
m_bits += 720U;
}
valid = false;
break;
Expand Down

0 comments on commit a41cd74

Please sign in to comment.