Commit 61e44fca authored by Stefan Westerfeld's avatar Stefan Westerfeld

Add conv code api to get the number of coded bits for a fixed message size.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent ae67a40c
......@@ -36,6 +36,12 @@ constexpr auto generators = std::array<unsigned,3> { 0552137, 0614671,
constexpr unsigned int state_count = (1 << order);
constexpr unsigned int state_mask = (1 << order) - 1;
size_t
conv_code_size (size_t msg_size)
{
return (msg_size + order) * rate;
}
vector<int>
conv_encode (const vector<int>& in_bits)
{
......
......@@ -4,6 +4,7 @@
#include <vector>
#include <string>
size_t conv_code_size (size_t msg_size);
std::vector<int> conv_encode (const std::vector<int>& in_bits);
std::vector<int> conv_decode_hard (const std::vector<int>& coded_bits);
std::vector<int> conv_decode_soft (const std::vector<float>& coded_bits);
......
......@@ -43,6 +43,8 @@ main (int argc, char **argv)
printf ("\n");
printf ("coded hex: %s\n", bit_vec_to_str (coded_bits).c_str());
assert (coded_bits.size() == conv_code_size (in_bits.size()));
vector<int> decoded_bits = conv_decode_hard (coded_bits);
printf ("output vector (k=%zd): ", decoded_bits.size());
for (auto b : decoded_bits)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment