2018-11-07 21:50:55 +08:00
|
|
|
#pragma once
|
|
|
|
|
2019-11-22 19:45:42 +08:00
|
|
|
#include "constants.h"
|
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
namespace ft8 {
|
2018-11-14 23:06:32 +08:00
|
|
|
|
2019-11-22 19:45:42 +08:00
|
|
|
class BPDecoderState {
|
|
|
|
public:
|
|
|
|
void reset();
|
|
|
|
int iterate(const float codeword[], uint8_t plain[]);
|
|
|
|
|
|
|
|
private:
|
|
|
|
float tov[ft8::N][3];
|
|
|
|
float toc[ft8::M][7];
|
|
|
|
};
|
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
// codeword is 174 log-likelihoods.
|
|
|
|
// plain is a return value, 174 ints, to be 0 or 1.
|
|
|
|
// iters is how hard to try.
|
2019-11-22 19:45:42 +08:00
|
|
|
// n_errors == 0 means success.
|
|
|
|
void ldpc_decode(const float codeword[], int max_iters, uint8_t plain[], int *n_errors);
|
2018-12-28 04:33:07 +08:00
|
|
|
|
2019-11-22 19:45:42 +08:00
|
|
|
void bp_decode(const float codeword[], int max_iters, uint8_t plain[], int *n_errors);
|
2019-01-03 02:54:18 +08:00
|
|
|
|
|
|
|
// Packs a string of bits each represented as a zero/non-zero byte in plain[],
|
|
|
|
// as a string of packed bits starting from the MSB of the first byte of packed[]
|
|
|
|
void pack_bits(const uint8_t plain[], int num_bits, uint8_t packed[]);
|
|
|
|
|
2019-11-22 19:45:42 +08:00
|
|
|
}
|