diff --git a/plugins/channelrx/demoddatv/datvdemodgui.cpp b/plugins/channelrx/demoddatv/datvdemodgui.cpp index 75a37a79e..e728ea7cc 100644 --- a/plugins/channelrx/demoddatv/datvdemodgui.cpp +++ b/plugins/channelrx/demoddatv/datvdemodgui.cpp @@ -108,6 +108,7 @@ bool DATVDemodGUI::handleMessage(const Message& message) m_settings.m_modulation = notif.getModulation(); m_settings.validateSystemConfiguration(); displaySystemConfiguration(); + return true; } else { diff --git a/plugins/channelrx/demoddatv/leansdr/bch.h b/plugins/channelrx/demoddatv/leansdr/bch.h index aab86547a..6315e47e5 100644 --- a/plugins/channelrx/demoddatv/leansdr/bch.h +++ b/plugins/channelrx/demoddatv/leansdr/bch.h @@ -88,13 +88,13 @@ struct bch_engine : bch_interface bool corrupted = false; // Divide by individual polynomials. // TBD Maybe do in parallel, scanning cw only once. - bitvect rem[npolys]; + bitvect *rem = new bitvect[npolys]; // npolys is not static hence 'bitvect rem[npolys]' does not compile in all compilers for (int j = 0; j < npolys; ++j) { rem[j] = divmod(cw, cwbytes, truncpolys[j]); } // Compute syndromes. - TGF S[2 * npolys]; + TGF *S = new TGF[2 * npolys]; // npolys is not static hence 'TGF S[2 * npolys]' does not compile in all compilers for (int i = 0; i < 2 * npolys; ++i) { // Compute R(alpha^(1+i)), exploiting the fact that @@ -105,6 +105,7 @@ struct bch_engine : bch_interface if (S[i]) corrupted = true; } + delete[] rem; if (!corrupted) return 0; #if 0 @@ -122,12 +123,16 @@ struct bch_engine : bch_interface // TBD More efficient to work with logs of syndromes ? int NN = 2 * npolys; - TGF C[NN] = { - 1, - }, - B[NN] = { - 1, - }; + TGF *C = new TGF[NN]; + std::fill(C, C+NN, 1); + TGF *B = new TGF[NN]; + std::fill(C, C+NN, 1); + // TGF C[NN] = { crap code + // 1, + // }, + // B[NN] = { + // 1, + // }; int L = 0, m = 1; TGF b = 1; for (int n = 0; n < NN; ++n) @@ -142,7 +147,7 @@ struct bch_engine : bch_interface TGF d_div_b = GF.mul(d, GF.inv(b)); if (2 * L <= n) { - TGF tmp[NN]; + TGF *tmp = new TGF[NN]; // replaced crap code memcpy(tmp, C, sizeof(tmp)); for (int i = 0; i < NN - m; ++i) C[m + i] = GF.sub(C[m + i], GF.mul(d_div_b, B[i])); @@ -150,6 +155,7 @@ struct bch_engine : bch_interface memcpy(B, tmp, sizeof(B)); b = d; m = 1; + delete[] tmp; } else { @@ -159,6 +165,7 @@ struct bch_engine : bch_interface } } } + delete[] S; // L is the number of errors. // C of degree L is the error locator polynomial (Lambda). // C(X) = sum(l=1..L)(1-X_l*X). @@ -188,6 +195,8 @@ struct bch_engine : bch_interface if (rloc < 0) { // This may happen if the code is used truncated. + delete[] C; + delete[] B; return -1; } cw[rloc / 8] ^= 128 >> (rloc & 7); @@ -196,6 +205,10 @@ struct bch_engine : bch_interface break; } } + + delete[] C; + delete[] B; + if (roots_found != L) return -1; return L; diff --git a/plugins/channelrx/demoddatv/leansdr/dvbs2.h b/plugins/channelrx/demoddatv/leansdr/dvbs2.h index e8fcaeda8..f9dcae651 100644 --- a/plugins/channelrx/demoddatv/leansdr/dvbs2.h +++ b/plugins/channelrx/demoddatv/leansdr/dvbs2.h @@ -1878,36 +1878,36 @@ static const struct fec_info const s2_ldpc_table *ldpc; } fec_infos[2][FEC_COUNT] = { { - // Normal frames - [FEC12] = {32208, 32400, 12, &ldpc_nf_fec12}, - [FEC23] = {43040, 43200, 10, &ldpc_nf_fec23}, - [FEC46] = {0}, - [FEC34] = {48408, 48600, 12, &ldpc_nf_fec34}, - [FEC56] = {53840, 54000, 10, &ldpc_nf_fec56}, - [FEC78] = {0}, - [FEC45] = {51648, 51840, 12, &ldpc_nf_fec45}, - [FEC89] = {57472, 57600, 8, &ldpc_nf_fec89}, - [FEC910] = {58192, 58320, 8, &ldpc_nf_fec910}, - [FEC14] = {16008, 16200, 12, &ldpc_nf_fec14}, - [FEC13] = {21408, 21600, 12, &ldpc_nf_fec13}, - [FEC25] = {25728, 25920, 12, &ldpc_nf_fec25}, - [FEC35] = {38688, 38880, 12, &ldpc_nf_fec35}, + // Normal frames - must respect enum code_rate order + {32208, 32400, 12, &ldpc_nf_fec12}, // FEC12 (was [FEC12] = {...} and so on. Does not compile with MSVC) + {43040, 43200, 10, &ldpc_nf_fec23}, // FEC23 + {0}, // FEC46 + {48408, 48600, 12, &ldpc_nf_fec34}, // FEC34 + {53840, 54000, 10, &ldpc_nf_fec56}, // FEC56 + {0}, // FEC78 + {51648, 51840, 12, &ldpc_nf_fec45}, // FEC45 + {57472, 57600, 8, &ldpc_nf_fec89}, // FEC89 + {58192, 58320, 8, &ldpc_nf_fec910}, // FEC910 + {16008, 16200, 12, &ldpc_nf_fec14}, // FEC14 + {21408, 21600, 12, &ldpc_nf_fec13}, // FEC13 + {25728, 25920, 12, &ldpc_nf_fec25}, // FEC25 + {38688, 38880, 12, &ldpc_nf_fec35}, // FEC35 }, { - // Short frames - [FEC12] = {7032, 7200, 12, &ldpc_sf_fec12}, - [FEC23] = {10632, 10800, 12, &ldpc_sf_fec23}, - [FEC46] = {}, - [FEC34] = {11712, 11880, 12, &ldpc_sf_fec34}, - [FEC56] = {13152, 13320, 12, &ldpc_sf_fec56}, - [FEC78] = {}, - [FEC45] = {12432, 12600, 12, &ldpc_sf_fec45}, - [FEC89] = {14232, 14400, 12, &ldpc_sf_fec89}, - [FEC910] = {}, - [FEC14] = {3072, 3240, 12, &ldpc_sf_fec14}, - [FEC13] = {5232, 5400, 12, &ldpc_sf_fec13}, - [FEC25] = {6312, 6480, 12, &ldpc_sf_fec25}, - [FEC35] = {9552, 9720, 12, &ldpc_sf_fec35}, + // Short frames - must respect enum code_rate order + {7032, 7200, 12, &ldpc_sf_fec12}, // FEC12 (was [FEC12] = {...} and so on. Does not compile with MSVC) + {10632, 10800, 12, &ldpc_sf_fec23}, // FEC23 + {}, // FEC46 + {11712, 11880, 12, &ldpc_sf_fec34}, // FEC34 + {13152, 13320, 12, &ldpc_sf_fec56}, // FEC56 + {}, // FEC78 + {12432, 12600, 12, &ldpc_sf_fec45}, // FEC45 + {14232, 14400, 12, &ldpc_sf_fec89}, // FEC89 + {}, // FEC910 + {3072, 3240, 12, &ldpc_sf_fec14}, // FEC14 + {5232, 5400, 12, &ldpc_sf_fec13}, // FEC13 + {6312, 6480, 12, &ldpc_sf_fec25}, // FEC25 + {9552, 9720, 12, &ldpc_sf_fec35}, // FEC35 }, }; diff --git a/plugins/channelrx/demoddatv/leansdr/ldpc.h b/plugins/channelrx/demoddatv/leansdr/ldpc.h index 39bf25a73..7cb6891f8 100644 --- a/plugins/channelrx/demoddatv/leansdr/ldpc.h +++ b/plugins/channelrx/demoddatv/leansdr/ldpc.h @@ -291,14 +291,14 @@ struct ldpc_engine int n_k = n - k; // Compute the expected check bits (without the final mixing) - SOFTWORD expected[n_k / SWSIZE]; + SOFTWORD *expected = new SOFTWORD[n_k / SWSIZE]; // Forbidden to statically allocate with non constant size encode(table, cw, k, n, expected, false); // Reverse the integrator mixing from the received check bits - SOFTWORD received[n_k / SWSIZE]; + SOFTWORD *received = new SOFTWORD[n_k / SWSIZE]; // Forbidden to statically allocate with non constant size diff_bits(cw + k / SWSIZE, received, n_k / SWSIZE); // Compute initial scores - score_t score[k]; + score_t *score = new score_t[k]; // Forbidden to statically allocate with non constant size score_t tots = compute_scores(cw, expected, received, n_k, score, k); lfprintf(stderr, "Initial score %d\n", (int)tots); @@ -438,6 +438,11 @@ struct ldpc_engine if ( tots2 != tots ) fail("bad tots update"); #endif } + + delete[] score; + delete[] received; + delete[] expected; + return nflipped; }