mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-21 13:15:40 -05:00
P25 -- Cleanup 1/2 Rate Decoding;
This commit is contained in:
45
src/p25_12.c
45
src/p25_12.c
@@ -3,7 +3,7 @@
|
|||||||
* P25p1 1/2 Rate Simple Trellis Decoder
|
* P25p1 1/2 Rate Simple Trellis Decoder
|
||||||
*
|
*
|
||||||
* LWVMOBILE
|
* LWVMOBILE
|
||||||
* 2023-09 DSD-FME Florida Man Edition
|
* 2023-10 DSD-FME Florida Man Edition
|
||||||
*-----------------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "dsd.h"
|
#include "dsd.h"
|
||||||
@@ -30,7 +30,10 @@ uint8_t p25_fsm[16] = {
|
|||||||
13,2,1,14,
|
13,2,1,14,
|
||||||
9,6,5,10 };
|
9,6,5,10 };
|
||||||
|
|
||||||
uint8_t p25_ecc[16] = {
|
//this is a dibit-pair to trellis dibit transition matrix (SDRTrunk and Ossmann)
|
||||||
|
//when evaluating hamming distance, we want to use this xor the dibit-pair nib,
|
||||||
|
//and not the fsm xor the constellation point
|
||||||
|
uint8_t p25_dtm[16] = {
|
||||||
2,12,1,15,
|
2,12,1,15,
|
||||||
14,0,13,3,
|
14,0,13,3,
|
||||||
9,7,10,4,
|
9,7,10,4,
|
||||||
@@ -51,7 +54,6 @@ uint8_t find_min(uint8_t list[4], int len)
|
|||||||
{
|
{
|
||||||
int min = list[0];
|
int min = list[0];
|
||||||
uint8_t index = 0;
|
uint8_t index = 0;
|
||||||
int unique = 1; //start with flagged on, list[0] could be the min
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 1; i < len; i++)
|
for (i = 1; i < len; i++)
|
||||||
@@ -60,18 +62,14 @@ uint8_t find_min(uint8_t list[4], int len)
|
|||||||
{
|
{
|
||||||
min = list[i];
|
min = list[i];
|
||||||
index = (uint8_t)i;
|
index = (uint8_t)i;
|
||||||
unique = 1;
|
|
||||||
}
|
}
|
||||||
// else if (list[i] == min)
|
|
||||||
// {
|
|
||||||
// unique = 0; //only change to 0 if another non-unique match is found
|
|
||||||
|
|
||||||
// }
|
//NOTE: Disqualifying result on uniqueness can impact decoding
|
||||||
|
//let the CRC determine if the result is good or bad
|
||||||
|
//its not uncommon for two values of the same min
|
||||||
|
//distance to emerge, so its 50/50 each time
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unique == 0)
|
|
||||||
return 0xF;
|
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +107,6 @@ int p25_12(uint8_t * input, uint8_t treturn[12])
|
|||||||
|
|
||||||
//convert constellation points into tdibit values using the FSM
|
//convert constellation points into tdibit values using the FSM
|
||||||
uint8_t state = 0;
|
uint8_t state = 0;
|
||||||
uint8_t temp_s = 0;
|
|
||||||
uint8_t tdibits[49]; //trellis dibits 1/2 rate
|
uint8_t tdibits[49]; //trellis dibits 1/2 rate
|
||||||
memset (tdibits, 0xF, sizeof(tdibits));
|
memset (tdibits, 0xF, sizeof(tdibits));
|
||||||
uint8_t hd[4]; //array of the four fsm words hamming distance
|
uint8_t hd[4]; //array of the four fsm words hamming distance
|
||||||
@@ -119,14 +116,6 @@ int p25_12(uint8_t * input, uint8_t treturn[12])
|
|||||||
for (i = 0; i < 49; i++)
|
for (i = 0; i < 49; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//just quickly peek for the location of the current point in the fsm
|
|
||||||
for (j = 0; j < 16; j++)
|
|
||||||
{
|
|
||||||
if (p25_fsm[j] == point[i])
|
|
||||||
temp_s = j&3; //set position to correct state output value
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
if ( p25_fsm[(state*4)+j] == point[i] )
|
if ( p25_fsm[(state*4)+j] == point[i] )
|
||||||
@@ -147,20 +136,10 @@ int p25_12(uint8_t * input, uint8_t treturn[12])
|
|||||||
|
|
||||||
//this method only seems to be reliable up to 1-2 bit errors...sometimes
|
//this method only seems to be reliable up to 1-2 bit errors...sometimes
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
hd[j] = count_bits ( ((nibs[i] ^ p25_ecc[(state*4)+j]) & 0xF ), 4 );
|
hd[j] = count_bits ( ((nibs[i] ^ p25_dtm[(state*4)+j]) & 0xF ), 4 );
|
||||||
min = find_min (hd, 4);
|
min = find_min (hd, 4);
|
||||||
|
tdibits[i] = state = min;
|
||||||
|
|
||||||
if (min != 15) //unique value returned
|
|
||||||
{
|
|
||||||
tdibits[i] = state = min;
|
|
||||||
// irr_err--; //decrement 'corrected' point err
|
|
||||||
}
|
|
||||||
|
|
||||||
//use the predicted correct state/value at output instead -- last resort
|
|
||||||
else
|
|
||||||
tdibits[i] = state = temp_s;
|
|
||||||
|
|
||||||
temp_s = 0;
|
|
||||||
memset (hd, 0, sizeof(hd));
|
memset (hd, 0, sizeof(hd));
|
||||||
min = 0;
|
min = 0;
|
||||||
|
|
||||||
@@ -179,7 +158,7 @@ int p25_12(uint8_t * input, uint8_t treturn[12])
|
|||||||
|
|
||||||
//trellis point/state err tally
|
//trellis point/state err tally
|
||||||
// if (irr_err != 0)
|
// if (irr_err != 0)
|
||||||
// fprintf (stderr, " ERR = %d", irr_err);
|
// fprintf (stderr, " P_ERR = %d", irr_err);
|
||||||
|
|
||||||
return (irr_err);
|
return (irr_err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user