| 52 | } |
| 53 | |
| 54 | void GEOSCANDecoderModule::process() |
| 55 | { |
| 56 | if (input_data_type == DATA_FILE) |
| 57 | filesize = getFilesize(d_input_file); |
| 58 | else |
| 59 | filesize = 0; |
| 60 | if (input_data_type == DATA_FILE) |
| 61 | data_in = std::ifstream(d_input_file, std::ios::binary); |
| 62 | |
| 63 | data_out = std::ofstream(d_output_file_hint + ".frm", std::ios::binary); |
| 64 | d_output_files.push_back(d_output_file_hint + ".frm"); |
| 65 | |
| 66 | std::string directory = d_output_file_hint.substr(0, d_output_file_hint.rfind('/')) + "/"; |
| 67 | |
| 68 | logger->info("Using input frames " + d_input_file); |
| 69 | logger->info("Decoding to " + d_output_file_hint + ".frm"); |
| 70 | |
| 71 | time_t lastTime = 0; |
| 72 | const uint8_t* pn9_scrambling = GEOSCANDecoderModule::PN9_MASK_Generator(); |
| 73 | while (input_data_type == DATA_FILE ? !data_in.eof() : input_active.load()) |
| 74 | { |
| 75 | // Read buffer |
| 76 | if (input_data_type == DATA_FILE) |
| 77 | data_in.read((char *)input_buffer, 256); |
| 78 | else |
| 79 | input_fifo->read((uint8_t *)input_buffer, 256); |
| 80 | |
| 81 | auto frames = deframer->work((uint8_t *)input_buffer, 256 / 8); |
| 82 | |
| 83 | for (auto &framebuf : frames) |
| 84 | { |
| 85 | for (int i = 0; i < (int)d_frame_length; i++) |
| 86 | framebuf[4 + i] ^= pn9_scrambling[i]; |
| 87 | |
| 88 | uint16_t crc_frm1 = crc_check.compute(&framebuf[4], (int)(d_frame_length-2)); |
| 89 | uint16_t crc_frm2 = framebuf[4 + (int)(d_frame_length-2) + 0] << 8 | framebuf[4 + (int)(d_frame_length-2) + 1]; |
| 90 | |
| 91 | if (crc_frm1 == crc_frm2) |
| 92 | { |
| 93 | data_out.write((char *)framebuf.data(), framebuf.size()); |
| 94 | frm_cnt++; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | progress = data_in.tellg(); |
| 99 | |
| 100 | if (time(NULL) % 10 == 0 && lastTime != time(NULL)) |
| 101 | { |
| 102 | lastTime = time(NULL); |
| 103 | logger->info("Progress " + std::to_string(round(((double)progress / (double)filesize) * 1000.0) / 10.0) + "%%, Frames " + std::to_string(frm_cnt)); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | logger->info("Decoding finished"); |
| 108 | |
| 109 | data_in.close(); |
| 110 | } |
| 111 |
nothing calls this directly
no test coverage detected