satdump/src-testing/main.cpp

44 lines
1.3 KiB
C++
Raw Normal View History

/**********************************************************************
2022-03-20 20:56:32 +01:00
* This file is used for testing random stuff without running the
* whole of SatDump, which comes in handy for debugging individual
* elements before putting them all together in modules...
2022-03-20 20:56:32 +01:00
*
* If you are an user, ignore this file which will not be built by
* default, and if you're a developper in need of doing stuff here...
* Go ahead!
2022-03-20 20:56:32 +01:00
*
* Don't judge the code you might see in there! :)
**********************************************************************/
2022-03-28 11:51:13 +02:00
#include "logger.h"
2023-09-07 08:37:08 +02:00
2023-09-29 17:19:21 +02:00
#include "common/dsp/utils/random.h"
#include <fstream>
2023-09-08 22:47:06 +02:00
int main(int argc, char *argv[])
{
initLogger();
2023-09-29 17:19:21 +02:00
std::ifstream data_in(argv[1], std::ios::binary);
std::ofstream data_out(argv[2], std::ios::binary);
2023-09-29 17:19:21 +02:00
uint8_t buffer1[1024];
int8_t buffer2[8192];
2023-09-29 17:19:21 +02:00
dsp::Random gaussian;
while (!data_in.eof()) //&& lines_img < 500)
{
data_in.read((char *)buffer1, 1024);
int bit2pos = 0;
for (int i = 0; i < 1024; i++)
for (int x = 6; x >= 0; x -= 2)
{
buffer2[bit2pos++] = (((buffer1[i] >> (x + 0)) & 1) ? 70 : -70) + gaussian.gasdev() * 10;
buffer2[bit2pos++] = (((buffer1[i] >> (x + 1)) & 1) ? 70 : -70) + gaussian.gasdev() * 10;
}
data_out.write((char *)buffer2, bit2pos);
}
2023-07-23 23:13:13 +02:00
}