From 64541a1958385d71e1b6ab7a9d8c8a4607eff6ae Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Fri, 11 Aug 2023 10:56:26 -0400 Subject: [PATCH] M17 Misc Cleanup; --- src/dsd_frame.c | 2 +- src/m17.c | 44 ++++++++++++++++++-------------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/dsd_frame.c b/src/dsd_frame.c index 461ea63..bdce893 100644 --- a/src/dsd_frame.c +++ b/src/dsd_frame.c @@ -298,7 +298,7 @@ processFrame (dsd_opts * opts, dsd_state * state) else if ((state->synctype == 16) || (state->synctype == 9) || (state->synctype == 17) || (state->synctype == 8) || (state->synctype == 99) || (state->synctype == 98)) { if (state->synctype == 98 || state->synctype == 99) //preamble only - skipDibit(opts, state, 184); //skip dibits to prime the demodulator + skipDibit(opts, state, 8); //skip dibits to prime the demodulator else if (state->synctype == 16 || state->synctype == 17) processM17STR(opts, state); else diff --git a/src/m17.c b/src/m17.c index 6a7a23c..522791c 100644 --- a/src/m17.c +++ b/src/m17.c @@ -40,9 +40,10 @@ uint8_t m17_scramble[369] = { char b40[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/."; uint8_t p1[62] = { -1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, -0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 +1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, +1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, +1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, +1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }; //produce 6 short samples (48k) for every 1 short sample (8k) @@ -216,7 +217,7 @@ void M17decodeLSF(dsd_state * state) } -int M17processLICH(dsd_state * state, dsd_opts * opts, uint8_t lich_bits[96]) +int M17processLICH(dsd_state * state, dsd_opts * opts, uint8_t * lich_bits) { int i, j, err; err = 0; @@ -313,7 +314,7 @@ int M17processLICH(dsd_state * state, dsd_opts * opts, uint8_t lich_bits[96]) return err; } -void M17processCodec2_1600(dsd_opts * opts, dsd_state * state, uint8_t payload[128]) +void M17processCodec2_1600(dsd_opts * opts, dsd_state * state, uint8_t * payload) { int i; unsigned char voice1[8]; @@ -403,7 +404,7 @@ void M17processCodec2_1600(dsd_opts * opts, dsd_state * state, uint8_t payload[1 } -void M17processCodec2_3200(dsd_opts * opts, dsd_state * state, uint8_t payload[128]) +void M17processCodec2_3200(dsd_opts * opts, dsd_state * state, uint8_t * payload) { int i; unsigned char voice1[8]; @@ -513,17 +514,17 @@ void M17processCodec2_3200(dsd_opts * opts, dsd_state * state, uint8_t payload[1 } -void M17prepareStream(dsd_opts * opts, dsd_state * state, uint8_t m17_bits[368]) +void M17prepareStream(dsd_opts * opts, dsd_state * state, uint8_t * m17_bits) { - int i, j, k, x; - uint8_t m17_punc[310]; //25 * 11 = 275 + int i, k, x; + uint8_t m17_punc[275]; //25 * 11 = 275 memset (m17_punc, 0, sizeof(m17_punc)); for (i = 0; i < 272; i++) m17_punc[i] = m17_bits[i+96]; //depuncture the bits - uint8_t m17_depunc[310]; //25 * 12 = 300 + uint8_t m17_depunc[300]; //25 * 12 = 300 memset (m17_depunc, 0, sizeof(m17_depunc)); k = 0; x = 0; for (i = 0; i < 25; i++) @@ -547,7 +548,7 @@ void M17prepareStream(dsd_opts * opts, dsd_state * state, uint8_t m17_bits[368]) uint8_t s0; uint8_t s1; uint8_t m_data[28]; - uint8_t trellis_buf[400]; + uint8_t trellis_buf[144]; memset (trellis_buf, 0, sizeof(trellis_buf)); memset (temp, 0, sizeof (temp)); memset (m_data, 0, sizeof (m_data)); @@ -619,13 +620,7 @@ void processM17STR(dsd_opts * opts, dsd_state * state) int i, x; - //NOTE: adding more space for dbuf seems to fix the memory issue, but I don't think this is - //the culprit, not entirely sure what is going on here, but the issue with Cygwin (32-bit) - //not working at all with this also is fixed by this and I can't seem to figure out why - //its probably something really dumb that I am completely blind on seeing here for some reason - - - uint8_t dbuf[384]; //384-bit frame - 16-bit (8 symbol) sync pattern (184 dibits) + uint8_t dbuf[184]; //384-bit frame - 16-bit (8 symbol) sync pattern (184 dibits) uint8_t m17_rnd_bits[368]; //368 bits that are still scrambled (randomized) uint8_t m17_int_bits[368]; //368 bits that are still interleaved uint8_t m17_bits[368]; //368 bits that have been de-interleaved and de-scramble @@ -680,12 +675,9 @@ void processM17STR(dsd_opts * opts, dsd_state * state) void processM17LSF(dsd_opts * opts, dsd_state * state) { - //NOTE1: Pretty sure the flow here is all correct, but the initial (and only) - //LSF frame is demodulated incorrectly, so more than likely, this frame will - //always be bad since there is only one sent before STR - - //NOTE2: Even with the preamble detection and LSF sync, we still get bad decode on this - + //NOTE: Have not been able to get this to work successfully, but considering + //there is only one LSF frame at the beginning of TX, its probably just as easy to + //use and rely on the STR frame and embedded LSF chunk, which does work properly int i, j, k, x; uint8_t dbuf[384]; //384-bit frame - 16-bit (8 symbol) sync pattern (184 dibits) uint8_t m17_rnd_bits[500]; //368 bits that are still scrambled (randomized) @@ -741,8 +733,8 @@ void processM17LSF(dsd_opts * opts, dsd_state * state) uint8_t temp[500]; uint8_t s0; uint8_t s1; - uint8_t m_data[32]; - uint8_t trellis_buf[400]; + uint8_t m_data[30]; + uint8_t trellis_buf[240]; //30*8 = 240 memset (trellis_buf, 0, sizeof(trellis_buf)); memset (temp, 0, sizeof (temp)); memset (m_data, 0, sizeof (m_data));