Merge pull request #378 from juribeparada/nxdn
More Viterbi decoder work for NXDN
This commit is contained in:
commit
121af6278b
4 changed files with 34 additions and 31 deletions
|
@ -27,12 +27,12 @@ const unsigned char BIT_MASK_TABLE[] = {0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04U
|
|||
#define WRITE_BIT1(p,i,b) p[(i)>>3] = (b) ? (p[(i)>>3] | BIT_MASK_TABLE[(i)&7]) : (p[(i)>>3] & ~BIT_MASK_TABLE[(i)&7])
|
||||
#define READ_BIT1(p,i) (p[(i)>>3] & BIT_MASK_TABLE[(i)&7])
|
||||
|
||||
const uint8_t BRANCH_TABLE1[] = {0U, 0U, 0U, 0U, 1U, 1U, 1U, 1U};
|
||||
const uint8_t BRANCH_TABLE2[] = {0U, 1U, 1U, 0U, 0U, 1U, 1U, 0U};
|
||||
const uint8_t BRANCH_TABLE1[] = {0U, 0U, 0U, 0U, 2U, 2U, 2U, 2U};
|
||||
const uint8_t BRANCH_TABLE2[] = {0U, 2U, 2U, 0U, 0U, 2U, 2U, 0U};
|
||||
|
||||
const unsigned int NUM_OF_STATES_D2 = 8U;
|
||||
const unsigned int NUM_OF_STATES = 16U;
|
||||
const uint32_t M = 2U;
|
||||
const uint32_t M = 4U;
|
||||
const unsigned int K = 5U;
|
||||
|
||||
CNXDNConvolution::CNXDNConvolution() :
|
||||
|
@ -72,16 +72,7 @@ void CNXDNConvolution::decode(uint8_t s0, uint8_t s1)
|
|||
for (uint8_t i = 0U; i < NUM_OF_STATES_D2; i++) {
|
||||
uint8_t j = i * 2U;
|
||||
|
||||
uint16_t metric0 = 0;
|
||||
uint16_t metric1 = 0;
|
||||
|
||||
if (s0 != 99U)
|
||||
metric0 = (BRANCH_TABLE1[i] ^ s0);
|
||||
|
||||
if (s1 != 99U)
|
||||
metric1 = (BRANCH_TABLE2[i] ^ s1);
|
||||
|
||||
uint16_t metric = metric0 + metric1;
|
||||
uint16_t metric = abs(BRANCH_TABLE1[i] - s0) + abs(BRANCH_TABLE2[i] - s1);
|
||||
|
||||
uint16_t m0 = m_oldMetrics[i] + metric;
|
||||
uint16_t m1 = m_oldMetrics[i + NUM_OF_STATES_D2] + (M - metric);
|
||||
|
|
|
@ -84,32 +84,36 @@ bool CNXDNFACCH1::decode(const unsigned char* data, unsigned int offset)
|
|||
|
||||
// CUtils::dump("NXDN, FACCH1 de-interleaved", temp1, 18U);
|
||||
|
||||
uint8_t temp2[192U];
|
||||
uint8_t temp2[210U];
|
||||
|
||||
unsigned int n = 0U;
|
||||
unsigned int index = 0U;
|
||||
for (unsigned int i = 0U; i < NXDN_FACCH1_LENGTH_BITS; i++) {
|
||||
if (n == PUNCTURE_LIST[index]) {
|
||||
temp2[n++] = 99U;
|
||||
temp2[n++] = 1U;
|
||||
index++;
|
||||
}
|
||||
|
||||
bool b = READ_BIT1(temp1, i);
|
||||
temp2[n++] = b ? 1U : 0U;
|
||||
temp2[n++] = b ? 2U : 0U;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0U; i < 8U; i++) {
|
||||
temp2[n++] = 0U;
|
||||
}
|
||||
|
||||
CNXDNConvolution conv;
|
||||
conv.start();
|
||||
|
||||
n = 0U;
|
||||
for (unsigned int i = 0U; i < 96U; i++) {
|
||||
for (unsigned int i = 0U; i < 100U; i++) {
|
||||
uint8_t s0 = temp2[n++];
|
||||
uint8_t s1 = temp2[n++];
|
||||
|
||||
conv.decode(s0, s1);
|
||||
}
|
||||
|
||||
conv.chainback(m_data, 92U);
|
||||
conv.chainback(m_data, 96U);
|
||||
|
||||
CUtils::dump("NXDN, FACCH1 decoded", m_data, 12U);
|
||||
|
||||
|
|
|
@ -77,32 +77,36 @@ bool CNXDNSACCH::decode(const unsigned char* data)
|
|||
|
||||
// CUtils::dump("NXDN, SACCH de-interleaved", temp1, 8U);
|
||||
|
||||
uint8_t temp2[72U];
|
||||
uint8_t temp2[90U];
|
||||
|
||||
unsigned int n = 0U;
|
||||
unsigned int index = 0U;
|
||||
for (unsigned int i = 0U; i < NXDN_SACCH_LENGTH_BITS; i++) {
|
||||
if (n == PUNCTURE_LIST[index]) {
|
||||
temp2[n++] = 99U;
|
||||
temp2[n++] = 1U;
|
||||
index++;
|
||||
}
|
||||
|
||||
bool b = READ_BIT1(temp1, i);
|
||||
temp2[n++] = b ? 1U : 0U;
|
||||
temp2[n++] = b ? 2U : 0U;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0U; i < 8U; i++) {
|
||||
temp2[n++] = 0U;
|
||||
}
|
||||
|
||||
CNXDNConvolution conv;
|
||||
conv.start();
|
||||
|
||||
n = 0U;
|
||||
for (unsigned int i = 0U; i < 36U; i++) {
|
||||
for (unsigned int i = 0U; i < 40U; i++) {
|
||||
uint8_t s0 = temp2[n++];
|
||||
uint8_t s1 = temp2[n++];
|
||||
|
||||
conv.decode(s0, s1);
|
||||
}
|
||||
|
||||
conv.chainback(m_data, 32U);
|
||||
conv.chainback(m_data, 36U);
|
||||
|
||||
CUtils::dump("NXDN, SACCH decoded", m_data, 4U);
|
||||
|
||||
|
|
20
NXDNUDCH.cpp
20
NXDNUDCH.cpp
|
@ -74,14 +74,14 @@ const unsigned char BIT_MASK_TABLE[] = { 0x80U, 0x40U, 0x20U, 0x10U, 0x08U, 0x04
|
|||
CNXDNUDCH::CNXDNUDCH(const CNXDNUDCH& udch) :
|
||||
m_data(NULL)
|
||||
{
|
||||
m_data = new unsigned char[23U + 2U];
|
||||
::memcpy(m_data, udch.m_data, 23U + 2U);
|
||||
m_data = new unsigned char[23U + 3U];
|
||||
::memcpy(m_data, udch.m_data, 23U + 3U);
|
||||
}
|
||||
|
||||
CNXDNUDCH::CNXDNUDCH() :
|
||||
m_data(NULL)
|
||||
{
|
||||
m_data = new unsigned char[23U + 2U];
|
||||
m_data = new unsigned char[23U + 3U];
|
||||
}
|
||||
|
||||
CNXDNUDCH::~CNXDNUDCH()
|
||||
|
@ -105,32 +105,36 @@ bool CNXDNUDCH::decode(const unsigned char* data)
|
|||
|
||||
CUtils::dump("NXDN, UDCH/FACCH2 de-interleaved", temp1, 44U);
|
||||
|
||||
uint8_t temp2[406U];
|
||||
uint8_t temp2[420U];
|
||||
|
||||
unsigned int n = 0U;
|
||||
unsigned int index = 0U;
|
||||
for (unsigned int i = 0U; i < NXDN_FACCH2_LENGTH_BITS; i++) {
|
||||
if (n == PUNCTURE_LIST[index]) {
|
||||
temp2[n++] = 99U;
|
||||
temp2[n++] = 1U;
|
||||
index++;
|
||||
}
|
||||
|
||||
bool b = READ_BIT1(temp1, i);
|
||||
temp2[n++] = b ? 1U : 0U;
|
||||
temp2[n++] = b ? 2U : 0U;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0U; i < 8U; i++) {
|
||||
temp2[n++] = 0U;
|
||||
}
|
||||
|
||||
CNXDNConvolution conv;
|
||||
conv.start();
|
||||
|
||||
n = 0U;
|
||||
for (unsigned int i = 0U; i < 203U; i++) {
|
||||
for (unsigned int i = 0U; i < 207U; i++) {
|
||||
uint8_t s0 = temp2[n++];
|
||||
uint8_t s1 = temp2[n++];
|
||||
|
||||
conv.decode(s0, s1);
|
||||
}
|
||||
|
||||
conv.chainback(m_data, 199U);
|
||||
conv.chainback(m_data, 203U);
|
||||
|
||||
CUtils::dump("NXDN, UDCH/FACCH2 decoded", m_data, 25U);
|
||||
|
||||
|
|
Loading…
Reference in a new issue