Revert DMR 34 Rate FEC Tests;

This commit is contained in:
lwvmobile 2023-09-16 22:34:59 -04:00
parent d8958662d9
commit c61d2dd35d
1 changed files with 11 additions and 73 deletions

View File

@ -3,7 +3,7 @@
* DMR 3/4 Rate Simple Trellis Decoder
*
* LWVMOBILE
* 2023-08 DSD-FME Florida Man Edition
* 2023-09 DSD-FME Florida Man Edition
*-----------------------------------------------------------------------------*/
#include "dsd.h"
@ -34,45 +34,6 @@ uint8_t fsm[64] = {
2, 10, 6, 14, 0, 8, 4, 12,
6, 14, 0, 8, 4, 12, 2, 10};
int count_bits2(uint8_t b, int slen)
{
int i = 0; int j = 0;
for (j = 0; j < slen; j++)
{
if ( (b & 1) == 1) i++;
b = b >> 1;
}
return i;
}
uint8_t find_min2(uint8_t list[8], int len)
{
int min = list[0];
uint8_t index = 0;
int unique = 1; //start with flagged on, list[0] could be the min
int i;
for (i = 1; i < len; i++)
{
if (list[i] < min)
{
min = list[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
}
}
if (unique == 0)
return 0xF;
return index;
}
uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
{
int i, j;
@ -105,7 +66,7 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
// fprintf (stderr, " %02d", point[i]);
//free-bee on err correction, point[0] should always be zero (flush bits)
// point[0] = 0;
point[0] = 0;
//convert constellation points into tribit values using the FSM
uint8_t state = 0;
@ -113,7 +74,6 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
memset (tribits, 0xF, sizeof(tribits));
uint8_t hd[8];
memset (hd, 0, sizeof(hd));
uint8_t min = 0;
for (i = 0; i < 49; i++)
{
@ -136,30 +96,10 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
//debug point, position of error, and state value
// fprintf (stderr, "\n P: %d, %d:%d; ", point[i], i, state);
for (j = 0; j < 8; j++)
hd[j] = count_bits2 ( ((point[i] ^ fsm[(state*8)+j]) & 0xF ), 4 );
min = find_min2 (hd, 8);
//debug hamming and min values
// fprintf (stderr, "MIN: %d; HD: ", min);
// for (j = 0; j < 8; j++)
// fprintf (stderr, "%d,", hd[j]);
// fprintf (stderr, ";");
//P: 0, 34:2; MIN: 0; HD: 1,2,2,3,2,3,3,4,;
if (min != 15)
{
point[i] = fsm[(state*8)+min]; //this should return a point that is in the current state
// irr_err--; //decrement 'corrected' point err
}
//Make a hard decision and flip point to fit in current state
else
point[i] ^= 7; //lucky number 7 (0111)
point[i] ^= 7; //lucky number 7 (0111)
memset (hd, 0, sizeof(hd));
min = 0;
//decrement one and try again
if (i != 0) i--;
@ -178,17 +118,15 @@ uint32_t dmr_34(uint8_t * input, uint8_t treturn[18])
//convert tribits into a return payload
uint32_t temp = 0;
if (1 == 1) //irr_err == 0
{
//break into chunks of 24 bit values and shuffle into 8-bit (byte) treturn values
for (i = 0; i < 6; i++)
{
temp = (tribits[(i*8)+0] << 21) + (tribits[(i*8)+1] << 18) + (tribits[(i*8)+2] << 15) + (tribits[(i*8)+3] << 12) + (tribits[(i*8)+4] << 9) + (tribits[(i*8)+5] << 6) + (tribits[(i*8)+6] << 3) + (tribits[(i*8)+7] << 0);
treturn[(i*3)+0] = (temp >> 16) & 0xFF;
treturn[(i*3)+1] = (temp >> 8) & 0xFF;
treturn[(i*3)+2] = (temp >> 0) & 0xFF;
}
//break into chunks of 24 bit values and shuffle into 8-bit (byte) treturn values
for (i = 0; i < 6; i++)
{
temp = (tribits[(i*8)+0] << 21) + (tribits[(i*8)+1] << 18) + (tribits[(i*8)+2] << 15) + (tribits[(i*8)+3] << 12) + (tribits[(i*8)+4] << 9) + (tribits[(i*8)+5] << 6) + (tribits[(i*8)+6] << 3) + (tribits[(i*8)+7] << 0);
treturn[(i*3)+0] = (temp >> 16) & 0xFF;
treturn[(i*3)+1] = (temp >> 8) & 0xFF;
treturn[(i*3)+2] = (temp >> 0) & 0xFF;
}
//trellis point/state err tally