61 if (toEncode->size() <= ecBytes)
64 CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes);
68 size_t dataBytes = toEncode->size() - ecBytes;
69 std::vector<int32_t> infoCoefficients(dataBytes);
70 for (size_t x = 0; x < dataBytes; x++)
71 infoCoefficients[x] = (*toEncode)[x];
73 CBC_ReedSolomonGF256Poly info(m_field, infoCoefficients);
74 auto infoTemp = info.MultiplyByMonomial(ecBytes, 1);
78 auto remainder = infoTemp->Divide(generator);
82 const auto& coefficients = remainder->GetCoefficients();
83 size_t numZeroCoefficients =
84 ecBytes > coefficients.size() ? ecBytes - coefficients.size() : 0;
85 for (size_t i = 0; i < numZeroCoefficients; i++)
86 (*toEncode)[dataBytes + i] = 0;
87 for (size_t y = 0; y < coefficients.size(); y++)
88 (*toEncode)[dataBytes + numZeroCoefficients + y] = coefficients[y];