]> git.sesse.net Git - greproxy/blobdiff - rsencoder.cpp
Switch to a different RS encoding.
[greproxy] / rsencoder.cpp
index 3026dd4d2373fdc552fbe1660ab88dbf37ce818e..d98a13caf16cb9612965915a501f833a820cc96a 100644 (file)
@@ -16,6 +16,12 @@ extern "C" {
 #include <algorithm>
 
 using namespace std;
+       
+RSEncoder::RSEncoder(Sender *sender) 
+       : sender(sender)
+{
+       rs = init_rs_char(RS_SYM_SIZE, RS_GF_POLY, 1, 1, RS_PARITY_SIZE, RS_PAD);
+}
 
 void RSEncoder::send_packet(uint16_t proto, const std::string &data, int incoming_seq)
 {
@@ -73,9 +79,9 @@ void RSEncoder::finish_group()
                for (int j = 0; j < packet_history.size(); ++j) {
                        data[j] = packet_history[j].data[i];
                }
-               encode_rs_8(reinterpret_cast<unsigned char *>(&data[0]),
-                           reinterpret_cast<unsigned char *>(&parity[0]),
-                           RS_PAD);
+               encode_rs_char(rs,
+                              reinterpret_cast<unsigned char *>(&data[0]),
+                              reinterpret_cast<unsigned char *>(&parity[0]));
                for (int j = 0; j < RS_PARITY_SIZE; ++j) {
                        rs_packets[j][i] = parity[j];
                }