2022-12-22 13:08:09 +01:00
|
|
|
#include "ldpc_decoder.h"
|
2022-12-24 00:35:46 +01:00
|
|
|
#include "core/plugin.h"
|
|
|
|
|
|
|
|
|
|
#include "common/cpu_features.h"
|
|
|
|
|
|
|
|
|
|
#include "ldpc_decoder_generic.h"
|
2022-12-22 13:08:09 +01:00
|
|
|
|
|
|
|
|
namespace codings
|
|
|
|
|
{
|
|
|
|
|
namespace ldpc
|
|
|
|
|
{
|
2022-12-24 00:35:46 +01:00
|
|
|
LDPCDecoder::LDPCDecoder(Sparse_matrix)
|
2022-12-22 13:08:09 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LDPCDecoder::~LDPCDecoder()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-24 00:35:46 +01:00
|
|
|
LDPCDecoder *get_best_ldpc_decoder(Sparse_matrix pcm)
|
2022-12-22 13:08:09 +01:00
|
|
|
{
|
2022-12-24 00:35:46 +01:00
|
|
|
std::map<std::string, std::function<LDPCDecoder *(Sparse_matrix)>> decoder_list;
|
2022-12-22 13:08:09 +01:00
|
|
|
|
2022-12-24 00:35:46 +01:00
|
|
|
satdump::eventBus->fire_event<GetLDPCDecodersEvent>({decoder_list});
|
|
|
|
|
decoder_list.insert({"generic", [](Sparse_matrix pcm)
|
|
|
|
|
{ return new LDPCDecoderGeneric(pcm); }});
|
2022-12-22 13:08:09 +01:00
|
|
|
|
2022-12-24 00:35:46 +01:00
|
|
|
cpu_features::cpu_features_t cpu_caps = cpu_features::get_cpu_features();
|
2022-12-22 13:08:09 +01:00
|
|
|
|
2022-12-24 00:35:46 +01:00
|
|
|
if (cpu_caps.CPU_X86_AVX2 && decoder_list.count("avx2") > 0)
|
|
|
|
|
return decoder_list["avx2"](pcm);
|
2022-12-25 14:14:25 +01:00
|
|
|
else if (cpu_caps.CPU_X86_SSE41 && decoder_list.count("sse41") > 0)
|
2022-12-24 00:35:46 +01:00
|
|
|
return decoder_list["sse41"](pcm);
|
2022-12-25 14:14:25 +01:00
|
|
|
else if (cpu_caps.CPU_ARM_NEON && decoder_list.count("neon") > 0)
|
2022-12-24 13:17:13 +01:00
|
|
|
return decoder_list["neon"](pcm);
|
2022-12-24 00:35:46 +01:00
|
|
|
else
|
|
|
|
|
return decoder_list["generic"](pcm);
|
2022-12-22 13:08:09 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|