I am currently trying to get the schifra library running for making some tests to implement it later in my code.
I am currently looking at the schifra_reed_solomon_example02.cpp and try to understand how I have to set the values to suite my needs.
/* Finite Field Parameters */
const std::size_t field_descriptor = 8; // GF(2^8) ok
const std::size_t generator_polynommial_index = 120; // what is this?
const std::size_t generator_polynommial_root_count = 32; // polynomial up to x^32
/* Reed Solomon Code Parameters */
const std::size_t code_length = 255; // amount of symbols in codeword
const std::size_t fec_length = 32; // minimal distance d ?
const std::size_t data_length = code_length - fec_length; // amount of symbols my message has
So what I try to have is an RS-Code for n, k , d = (128, 16, 113)
And I would proceed the following:
/* Finite Field Parameters */
const std::size_t field_descriptor = 8; // I want GF(2^8)
const std::size_t generator_polynommial_index = 120; // still not knowing
const std::size_t generator_polynommial_root_count = 16; // because polynomial up to 16
/* Reed Solomon Code Parameters */
const std::size_t code_length = 128; // 128 byte codewords
const std::size_t fec_length = 113; // minimal distance, 113 because d = n - k +1
const std::size_t data_length = 16;
I then receive at encoding a mesage an error.
schifra::galois::field_polynomial generator_polynomial(field);
schifra::sequential_root_generator_polynomial_creator(field,
generator_polynommial_index,
generator_polynommial_root_count,
generator_polynomial);
/* Instantiate Encoder and Decoder (Codec) */
schifra::reed_solomon::encoder<code_length,fec_length> encoder(field,generator_polynomial);
schifra::reed_solomon::decoder<code_length,fec_length> decoder(field,generator_polynommial_index);
std::string message = "A professional i"; // its 16 bytes
std::cout << "Original Message: [" << message << "]" << std::endl;
message = message + std::string(data_length - message.length(),static_cast<unsigned char>(0x00)); // this one is also done in example
std::cout << "Original Message: [" << message << "]" << std::endl;
std::cout << "Message length: " << message.length() << std::endl; // still 16 bytes
/* Instantiate RS Block For Codec */
schifra::reed_solomon::block<code_length,fec_length> block;
/* Transform message into Reed-Solomon encoded codeword */
if (!encoder.encode(message,block))
{
std::cout << "Error - Critical encoding failure!" << std::endl;
return 1;
}
The Error - Critical encoding failure!
is then given.
I think what I do wrong is setting up the polynommial correct - maybe someone can help me?