bug fixes

bug fixes and tweaks
This commit is contained in:
lwvmobile 2022-04-04 16:12:19 -04:00 committed by GitHub
parent c1eb511855
commit 672e5cbd44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 28 deletions

View File

@ -19,7 +19,40 @@
#include "dmr_const.h"
#include "p25p1_check_hdu.h"
//
int BP[256] = {
0x0000, 0x1F00, 0xE300, 0xFC00, 0x2503, 0x3A03, 0xC603, 0xD903,
0x4A05, 0x5505, 0xA905, 0xB605, 0x6F06, 0x7006, 0x8C06, 0x9306,
0x2618, 0x3918, 0xC518, 0xDA18, 0x031B, 0x1C1B, 0xE01B, 0xFF1B,
0x6C1D, 0x731D, 0x8F1D, 0x901D, 0x491E, 0x561E, 0xAA1E, 0xB51E, //31
0x4B28, 0x5428, 0xA828, 0xB728, 0x6E2B, 0x712B, 0x8D2B, 0x922B,
0x012D, 0x1E2D, 0xE22D, 0xFD2D, 0x242E, 0x3B2E, 0xC72E, 0xD82E,
0x6D30, 0x7230, 0x8E30, 0x9130, 0x4833, 0x5733, 0xAB33, 0xB433,
0x2735, 0x3835, 0xC435, 0xDB35, 0x0236, 0x1D36, 0xE136, 0xFE36, //63
0x2B49, 0x3449, 0xC849, 0xD749, 0x0E4A, 0x114A, 0xED4A, 0xF24A,
0x614C, 0xAE4C, 0x824C, 0x9D4C, 0x444F, 0x5B4F, 0xA74F, 0xB84F,
0x0D51, 0x1251, 0xEE51, 0xF151, 0x2852, 0x3752, 0xCB52, 0xD452,
0x4754, 0x5854, 0xA454, 0xBB54, 0x6257, 0x7D57, 0x8157, 0x9E57, //95
0x6061, 0x7F61, 0x8361, 0x9C61, 0x4562, 0x5A62, 0xA662, 0xB962,
0x2A64, 0x3564, 0xC964, 0xD664, 0x0F67, 0x1067, 0xEC67, 0xF367,
0x4679, 0x5979, 0xA579, 0xBA79, 0x637A, 0x7C7A, 0x807A, 0x9F7A,
0x0C7C, 0x137C, 0xEF7C, 0xF07C, 0x297F, 0x367F, 0xCA7F, 0xD57F, //127
0x4D89, 0x5289, 0xAE89, 0xB189, 0x688A, 0x778A, 0x8B8A, 0x948A,
0x078C, 0x188C, 0xE48C, 0xFB8C, 0x228F, 0x3D8F, 0xC18F, 0xDE8F,
0x6B91, 0x7491, 0x8891, 0x9791, 0x4E92, 0x5192, 0xAD92, 0xB292,
0x2194, 0x3E94, 0xC294, 0xDD94, 0x0497, 0x1B97, 0xE797, 0xF897, //159
0x06A1, 0x19A1, 0xE5A1, 0xFAA1, 0x23A2, 0x3CA2, 0xC0A2, 0xDFA2,
0x4CA4, 0x53A4, 0xAFA4, 0xB0A4, 0x69A7, 0x76A7, 0x8AA7, 0x95A7,
0x20B9, 0x3FB9, 0xC3B9, 0xDCB9, 0x05BA, 0x1ABA, 0xE6BA, 0xF9BA,
0x6ABC, 0x75BC, 0x89BC, 0x96BC, 0x4FBF, 0x50BF, 0xACBF, 0xB3BF, //191
0x66C0, 0x79C0, 0x85C0, 0x9AC0, 0x43C3, 0x5CC3, 0xA0C3, 0xBFC3,
0x2CC5, 0x33C5, 0xCFC5, 0xD0C5, 0x09C6, 0x16C6, 0xEAC6, 0xF5C6,
0x84D0, 0x85DF, 0x8AD3, 0x8BDC, 0xB6D5, 0xB7DA, 0xB8D6, 0xB9D9,
0xD0DA, 0xD1D5, 0xDED9, 0xDFD6, 0xE2DF, 0xE3D0, 0xECDC, 0xEDD3, //223
0x2DE8, 0x32E8, 0xCEE8, 0xD1E8, 0x08EB, 0x17EB, 0xEBEB, 0xF4EB,
0x67ED, 0x78ED, 0x84ED, 0x9BED, 0x42EE, 0x5DEE, 0xA1EE, 0xBEEE,
0x0BF0, 0x14F0, 0xE8F0, 0xF7F0, 0x2EF3, 0x31F3, 0xCDF3, 0xD2F3,
0x41F5, 0x5EF5, 0xA2F5, 0xBDF5, 0x64F6, 0x7BF6, 0x87F6, 0x98F6 //255
};
//
void ProcessDMR (dsd_opts * opts, dsd_state * state)
{
@ -49,7 +82,23 @@ void ProcessDMR (dsd_opts * opts, dsd_state * state)
//TSVoiceSupFrameR = &state->TS2SuperFrame;
//
if (state->K > 0 && state->dmr_so & 0x40 && state->payload_keyid == 0)
{
fprintf(stderr, " BPK %d", state->K);
for(Frame = 0; Frame < 6; Frame++)
{
for(i = 0; i < 3; i++)
{
for(j = 0; j < 49; j++)
{
k = BP[state->K];
k = ( ((k & 0xFF0F) << 32 ) + (k << 16) + k );
x = ( ((k << j) & 0x800000000000) >> 47 );
TSVoiceSupFrame->TimeSlotAmbeVoiceFrame[Frame].AmbeBit[i][j] ^= x;
}
}
}
}
//
for(Frame = 0; Frame < 6; Frame++)
{

View File

@ -24,6 +24,8 @@
void processdPMRvoice (dsd_opts * opts, dsd_state * state)
{
for (short q = 0; q < 1; q++)
{
// extracts AMBE frames from DMR frame
uint32_t i, j, k, dibit;
uint8_t CCH[NB_OF_DPMR_VOICE_FRAME_TO_DECODE][72] = {0};
@ -35,7 +37,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
//uint8_t TCH[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][72] = {0};
uint8_t CC[NB_OF_DPMR_VOICE_FRAME_TO_DECODE / 2][24] = {0};
char ambe_fr[NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4][4][24] = {0};
char ambe_fr2[4][24];
char ambe_fr2[8][4][24];
const int *w, *x, *y, *z;
uint32_t ScramblerLFSR = 0;
bool correctable = true;
@ -75,6 +77,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
/* First CCH (Control CHannel) - 72 bit */
k = 0;
for (i = 0; i < 36; i++)
{
dibit = getDibit (opts, state);
@ -118,8 +121,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
#endif
ambe_fr[j][*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr[j][*y][*z] = (1 & dibit); // bit 0
ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[*y][*z] = (1 & dibit); // bit 0
ambe_fr2[j][*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[j][*y][*z] = (1 & dibit); // bit 0
//TCH[j][k] = (1 & (dibit >> 1)); // bit 1
//TCH[j][k + 1] = (1 & dibit); // bit 0
state->dPMRVoiceFS2Frame.RawVoiceBit[j][k] = (1 & (dibit >> 1)); // bit 1
@ -131,7 +134,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
z++;
}
//processMbeFrame (opts, state, NULL, ambe_fr[j], NULL); //HERE HERE
processMbeFrame (opts, state, NULL, ambe_fr2[j], NULL); //HERE HERE
#ifdef DPMR_DUMP
fprintf(stderr, " ");
@ -213,8 +216,8 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
#endif
ambe_fr[j + 4][*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr[j + 4][*y][*z] = (1 & dibit); // bit 0
//ambe_fr2[*w][*x] = (1 & (dibit >> 1)); // bit 1
//ambe_fr2[*y][*z] = (1 & dibit); // bit 0
ambe_fr2[j+4][*w][*x] = (1 & (dibit >> 1)); // bit 1
ambe_fr2[j+4][*y][*z] = (1 & dibit); // bit 0
//TCH[j + 4][k] = (1 & (dibit >> 1)); // bit 1
//TCH[j + 4][k + 1] = (1 & dibit); // bit 0
state->dPMRVoiceFS2Frame.RawVoiceBit[j + 4][k] = (1 & (dibit >> 1)); // bit 1
@ -225,7 +228,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
y++;
z++;
}
//processMbeFrame (opts, state, NULL, ambe_fr[j], NULL);
processMbeFrame (opts, state, NULL, ambe_fr2[j+4], NULL);
#ifdef DPMR_DUMP
fprintf(stderr, " ");
@ -631,20 +634,21 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
if(VoiceFrameFlag)
{
/* There is 4 AMBE voice sample per voice frame (= 8 per superframe) */
for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++)
//for(i = 0; i < (8); i++)
//for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++)
for(i = 0; i < (8); i++)
{
/* Apply ECC 1 to the AMBE frames */
state->dPMRVoiceFS2Frame.errs1[i] = (unsigned int)mbe_eccAmbe3600x2450C0(ambe_fr[i]);
state->dPMRVoiceFS2Frame.errs2[i] = state->dPMRVoiceFS2Frame.errs1[i];
//state->dPMRVoiceFS2Frame.errs1[i] = (unsigned int)mbe_eccAmbe3600x2450C0(ambe_fr[i]);
//state->dPMRVoiceFS2Frame.errs1[i] = (unsigned int)mbe_eccAmbe3600x2450C0(ambe_fr[i]);
//state->dPMRVoiceFS2Frame.errs2[i] = state->dPMRVoiceFS2Frame.errs1[i];
/* Demodulate the AMBE frames */
//mbe_demodulateAmbe3600x2450Data(ambe_fr[i]);
mbe_demodulateAmbe3600x2400Data(ambe_fr[i]);
//mbe_demodulateAmbe3600x2450Data(ambe_fr[i]);
/* Apply ECC 2 to the AMBE frames and get the 49 bit of the voice sample */
//state->dPMRVoiceFS2Frame.errs2[i] += (unsigned int)mbe_eccAmbe3600x2450Data(ambe_fr[i], (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]);
state->dPMRVoiceFS2Frame.errs2[i] += (unsigned int)mbe_eccAmbe3600x2400Data(ambe_fr[i], (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]);
//state->dPMRVoiceFS2Frame.errs2[i] += (unsigned int)mbe_eccAmbe3600x2450Data(ambe_fr[i], (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]);
//processMbeFrame (opts, state, NULL, ambe_fr[i], NULL); //HERE HERE
//processMbeFrame (opts, state, NULL, state->dPMRVoiceFS2Frame.AmbeBit[i], NULL); //HERE HERE
}
@ -673,7 +677,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
fprintf(stderr, "Voice frame to play\n");
#endif //dPMR_PRINT_DEBUG_INFO
//There is 4 AMBE voice sample per voice frame (so 2 x 4 = 8 per superframe)
for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++) //is this backwards, shouldn't we run this first, and then voice frame after?
for(i = 0; i < (8); i++) //is this backwards, shouldn't we run this first, and then voice frame after?
{
//errs = (uint32_t*)&(state->dPMRVoiceFS2Frame.errs1[i]);
@ -685,32 +689,32 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
//sounds like choppy shit, but .amb file playback is acceptable, so investigate why this doesn't work properly
//could be related to err states not properly done or something?
mbe_processAmbe2450Dataf (state->audio_out_temp_buf, (int *)errs, (int *)errs2, state->err_str,
(char *)state->dPMRVoiceFS2Frame.AmbeBit[i],
state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
//mbe_processAmbe2450Dataf (state->audio_out_temp_buf, (int *)errs, (int *)errs2, state->err_str,
// (char *)state->dPMRVoiceFS2Frame.AmbeBit[i],
// state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality);
if (opts->mbe_out_f != NULL)
{
saveAmbe2450Data (opts, state, (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]);
//saveAmbe2450Data (opts, state, (char *)state->dPMRVoiceFS2Frame.AmbeBit[i]);
}
if (opts->errorbars == 1)
{
//fprintf(stderr, "%s", state->err_str);
}
//state->debug_audio_errors += *errs2;
state->debug_audio_errors += *errs2;
processAudio(opts, state);
//processAudio(opts, state);
if (opts->wav_out_f != NULL)
{
writeSynthesizedVoice (opts, state);
//writeSynthesizedVoice (opts, state);
}
if (opts->audio_out == 1)
{
//Play the AMBE Frames
playSynthesizedVoice (opts, state);
//playSynthesizedVoice (opts, state);
}
} //End for(i = 0; i < (NB_OF_DPMR_VOICE_FRAME_TO_DECODE * 4); i++)
} //End if(VoiceFrameFlag)
@ -746,7 +750,7 @@ void processdPMRvoice (dsd_opts * opts, dsd_state * state)
//Print sPMR frame (if needed)
//dPMRVoiceFrameProcess(opts, state); //HERE HERE disabled to build
}
} //End processdPMRvoice()

View File

@ -214,6 +214,7 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
{
// determine dibit state
if ((state->synctype == 6) || (state->synctype == 14)|| (state->synctype == 18))
{
// 6 +D-STAR
// 14 +ProVoice
@ -251,8 +252,9 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
return (0); // +1
}
}
else if ((state->synctype == 1) || (state->synctype == 3) || (state->synctype == 5) ||
(state->synctype == 9) || (state->synctype == 11) || (state->synctype == 13) || (state->synctype == 17))
else if ((state->synctype == 1) || (state->synctype == 3) || (state->synctype == 5) ||
(state->synctype == 9) || (state->synctype == 11) || (state->synctype == 13) || (state->synctype == 17))
{
// 1 -P25p1
// 3 -X2-TDMA (inverted signal voice frame)
@ -261,6 +263,7 @@ static int digitize (dsd_opts* opts, dsd_state* state, int symbol)
// 11 -DMR (inverted signal voice frame)
// 13 -DMR (inverted signal data frame)
// 17 -NXDN (inverted data frame)
//
int valid;
int dibit;

View File

@ -178,6 +178,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
// detect frame sync
t = 0;
synctest[24] = 0;
synctest12[12] = 0;
synctest18[18] = 0;
synctest32[32] = 0;
synctest_pos = 0;

View File

@ -464,7 +464,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
attron(COLOR_PAIR(3));
}
//if(state->K > 0 && state->payload_keyid == 0 && state->dmr_so & 0x40)
if(state->K > 0 && state->dmr_so == 0x40)
if(state->K > 0 && state->dmr_so == 0x40 && state->payload_keyid == 0)
{
attron(COLOR_PAIR(5));
printw ("BPK [%3d]", state->K);