From af5160efd3d6e1ece1eab0fa5169b83c6107619b Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Wed, 8 Jul 2020 11:15:29 +0200 Subject: [PATCH] return -1 for more than T errors --- short_bch_code_decoder.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/short_bch_code_decoder.hh b/short_bch_code_decoder.hh index 1c90614..e275f33 100644 --- a/short_bch_code_decoder.hh +++ b/short_bch_code_decoder.hh @@ -29,6 +29,8 @@ class ShortBCHCodeDecoder } static int metric(const int8_t *soft, int hard) { + if (hard < 0) + return -1; int lol = 8 * sizeof(hard) - 1; int sum = 0; for (int i = 0; i < N; ++i) @@ -40,6 +42,8 @@ public: { for (int i = 0; i < W; ++i) par[i] = modgen(i << P); + for (int i = 0; i < R; ++i) + err[i] = -1; err[0] = 0; for (int a = 1<<(N-1); T >= 1 && a; a >>= 1) { err[modgen(a)] = a; @@ -53,7 +57,8 @@ public: } int operator()(int inp) { - return inp ^ err[(par[inp>>P] ^ inp) & (R-1)]; + int tmp = err[(par[inp>>P] ^ inp) & (R-1)]; + return tmp >= 0 ? inp ^ tmp : -1; } int operator()(const int8_t *code) { @@ -66,7 +71,7 @@ public: return word; // metric of hard decision int best = metric(code, word); - int next = -1; + int next = -2; auto update = [code, &word, &best, &next](int hard) { if (hard == word) return;