From 10ec9bd5442556cd16887820101f35fd563c9ba9 Mon Sep 17 00:00:00 2001 From: Alex Ernst Date: Sun, 17 Sep 2023 22:16:41 +0200 Subject: [PATCH] Fix trellis enocder/decoder bit order: invert bit order --- DMRTrellis.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/DMRTrellis.cpp b/DMRTrellis.cpp index f0a73cb..cdf30ed 100644 --- a/DMRTrellis.cpp +++ b/DMRTrellis.cpp @@ -280,12 +280,12 @@ void CDMRTrellis::pointsToDibits(const unsigned char* points, signed char* dibit void CDMRTrellis::bitsToTribits(const unsigned char* payload, unsigned char* tribits) const { for (unsigned int i = 0U; i < 48U; i++) { - unsigned int n = 143U - i * 3U; + unsigned int n = i * 3U; bool b1 = READ_BIT(payload, n) != 0x00U; - n--; + n++; bool b2 = READ_BIT(payload, n) != 0x00U; - n--; + n++; bool b3 = READ_BIT(payload, n) != 0x00U; unsigned char tribit = 0U; @@ -308,12 +308,12 @@ void CDMRTrellis::tribitsToBits(const unsigned char* tribits, unsigned char* pay bool b2 = (tribit & 0x02U) == 0x02U; bool b3 = (tribit & 0x01U) == 0x01U; - unsigned int n = 143U - i * 3U; + unsigned int n = i * 3U; WRITE_BIT(payload, n, b1); - n--; + n++; WRITE_BIT(payload, n, b2); - n--; + n++; WRITE_BIT(payload, n, b3); } }