diff options
author | Ron Economos <w6rz@comcast.net> | 2018-12-17 20:57:41 -0800 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-12-23 22:16:11 +0100 |
commit | 31a58a71cf4c89b4b8c2e809b90cb549c5db5917 (patch) | |
tree | 5cd285c86d5da9d85000994f62cefe297def1391 /gr-dtv | |
parent | 018658c786b1c178e3fa0113c761641c81a83c0a (diff) |
dtv: Fix optimized BCH encoder for N=8 codes.
Diffstat (limited to 'gr-dtv')
-rw-r--r-- | gr-dtv/lib/dvb/dvb_bch_bb_impl.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gr-dtv/lib/dvb/dvb_bch_bb_impl.cc b/gr-dtv/lib/dvb/dvb_bch_bb_impl.cc index 0ec9c2f784..8337728afa 100644 --- a/gr-dtv/lib/dvb/dvb_bch_bb_impl.cc +++ b/gr-dtv/lib/dvb/dvb_bch_bb_impl.cc @@ -579,14 +579,14 @@ for (unsigned int i = 0; i < num_parity_bits; i ++) {\ { const unsigned char *in = (const unsigned char *) input_items[0]; unsigned char *out = (unsigned char *) output_items[0]; - unsigned char b, temp; + unsigned char b, temp, msb; // We can use a 192 bits long bitset, all higher bits not used by the bch will just be ignored std::bitset<MAX_BCH_PARITY_BITS> parity_bits; int consumed = 0; for (int i = 0; i < noutput_items; i += nbch) { - for (int j = 0; j < (int)kbch/8; j++) { + for (int j = 0; j < (int)kbch / 8; j++) { b = 0; // calculate the crc using the lookup table, cf. http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html @@ -598,9 +598,13 @@ for (unsigned int i = 0; i < num_parity_bits; i ++) {\ b |= temp << (7 - e); } - unsigned long msB_CRC = (parity_bits >> (num_parity_bits - 8)).to_ulong(); + msb = 0; + for (int n = 1; n <= 8; n++) { + temp = parity_bits[num_parity_bits - n]; + msb |= temp << (8 - n); + } /* XOR-in next input byte into MSB of crc and get this MSB, that's our new intermediate divident */ - unsigned char pos = (unsigned char)(msB_CRC ^ b); + unsigned char pos = (msb ^ b); /* Shift out the MSB used for division per lookuptable and XOR with the remainder */ parity_bits = (parity_bits << 8) ^ crc_table[pos]; } |