mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
CCSDS Turbo Encoder / Decoder stuff
This commit is contained in:
parent
9d7c72d972
commit
bcd52ddbb8
9 changed files with 1170 additions and 0 deletions
|
|
@ -11,8 +11,45 @@
|
|||
**********************************************************************/
|
||||
|
||||
#include "logger.h"
|
||||
#include "common/codings/turbo/ccsds_turbo.h"
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
initLogger();
|
||||
|
||||
codings::turbo::CCSDSTurbo ccsds_turbo(codings::turbo::BASE_223, codings::turbo::RATE_1_2);
|
||||
|
||||
logger->critical("Frame length {:d}", ccsds_turbo.frame_length());
|
||||
logger->critical("Codeword length {:d}", ccsds_turbo.codeword_length());
|
||||
|
||||
uint8_t turbo_frame[223];
|
||||
uint8_t turbo_codeword[3576 / 8];
|
||||
std::ifstream ts_in("/home/alan/Downloads/sk8.ts");
|
||||
std::ofstream encoded_in("/home/alan/encoded_turbo.ts");
|
||||
|
||||
float turbo_soft_frame[3576];
|
||||
|
||||
while (!ts_in.eof())
|
||||
{
|
||||
ts_in.read((char *)turbo_frame, 188);
|
||||
|
||||
ccsds_turbo.encode(turbo_frame, turbo_codeword);
|
||||
|
||||
for (int i = 0; i < 3576; i++)
|
||||
{
|
||||
uint8_t bit = (turbo_codeword[i / 8] >> (7 - (i % 8))) & 1;
|
||||
turbo_soft_frame[i] = bit ? 1 : -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
int pos = rand() % 3576;
|
||||
turbo_soft_frame[pos] = -turbo_soft_frame[pos];
|
||||
}
|
||||
|
||||
ccsds_turbo.decode(turbo_soft_frame, turbo_frame, 5);
|
||||
|
||||
encoded_in.write((char *)turbo_frame, 188);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue