The decoder calculates the syndrome over the given data length and the received parity symbols and corrects errors in the data.
If a syndrome is available from a hardware decoder then the syndrome calculation is skipped.
The correction of the data buffer can be suppressed by providing a correction pattern buffer and an error location buffer to the decoder. The decoder stores the calculated error location and the correction bitmask in the given buffers. This is useful for hardware decoders which use a weird bit ordering scheme.
The databytes are expanded to the given symbol size on the fly. There is no support for decoding continuous bitstreams with a symbolsize != 8 at the moment. If it is necessary it should be not a big deal to implement such functionality.
/* Parity buffer. Size = number of roots */ uint16_t par[6]; uint8_t data[512]; int numerr; /* Receive data */ ..... /* Receive parity */ ..... /* Decode 512 byte in data8.*/ numerr = decode_rs8 (rs_decoder, data8, par, 512, NULL, 0, NULL, 0, NULL);
/* Parity buffer. Size = number of roots */ uint16_t par[6], syn[6]; uint8_t data[512]; int numerr; /* Receive data */ ..... /* Receive parity */ ..... /* Get syndrome from hardware decoder */ ..... /* Decode 512 byte in data8.*/ numerr = decode_rs8 (rs_decoder, data8, par, 512, syn, 0, NULL, 0, NULL);
Note: It's not necessary to give data and received parity to the decoder.
/* Parity buffer. Size = number of roots */ uint16_t par[6], syn[6], corr[8]; uint8_t data[512]; int numerr, errpos[8]; /* Receive data */ ..... /* Receive parity */ ..... /* Get syndrome from hardware decoder */ ..... /* Decode 512 byte in data8.*/ numerr = decode_rs8 (rs_decoder, NULL, NULL, 512, syn, 0, errpos, 0, corr); for (i = 0; i < numerr; i++) { do_error_correction_in_your_buffer(errpos[i], corr[i]); }