| 319 | } |
| 320 | |
| 321 | uint64_t decode (uint32_t mysize, std::mt19937_64 &rnd, float drop_prob, |
| 322 | uint8_t overhead) |
| 323 | { |
| 324 | // returns average number of microseconds for encoding and decoding |
| 325 | Timer t; |
| 326 | const uint16_t symbol_size = 1280; |
| 327 | // const uint16_t subsymbol = 1280 / 4; // small interleaving |
| 328 | const uint16_t subsymbol = 1280; // small interleaving |
| 329 | const size_t max_sub_block = std::numeric_limits<uint32_t>::max(); |
| 330 | std::vector<uint8_t> myvec; |
| 331 | |
| 332 | // initialize vector |
| 333 | std::uniform_int_distribution<uint8_t> distr (0, |
| 334 | std::numeric_limits<uint8_t>::max()); |
| 335 | myvec.reserve (mysize * symbol_size); |
| 336 | for (uint32_t i = 0; i < mysize * symbol_size; ++i) |
| 337 | myvec.push_back (distr(rnd)); |
| 338 | |
| 339 | std::vector<std::pair<uint32_t, std::vector<uint8_t>>> encoded; |
| 340 | |
| 341 | auto enc_it = myvec.begin(); |
| 342 | RaptorQ::Encoder<std::vector<uint8_t>::iterator, |
| 343 | std::vector<uint8_t>::iterator> enc ( |
| 344 | enc_it, myvec.end(), subsymbol, symbol_size, max_sub_block); |
| 345 | |
| 346 | t.start(); |
| 347 | enc.precompute(1, false); |
| 348 | uint64_t micro1 = t.stop(); |
| 349 | |
| 350 | if (micro1 == 0) |
| 351 | return 0; |
| 352 | |
| 353 | if (drop_prob > static_cast<float>(100.0)) |
| 354 | drop_prob = 90.0; // this is still too high probably. |
| 355 | std::uniform_real_distribution<float> drop (0.0, 100.0); |
| 356 | |
| 357 | int32_t repair = overhead; |
| 358 | |
| 359 | for (auto block : enc) { |
| 360 | for (auto sym_it = block.begin_source(); sym_it != block.end_source(); |
| 361 | ++sym_it) { |
| 362 | float dropped = drop (rnd); |
| 363 | if (dropped <= drop_prob) { |
| 364 | ++repair; |
| 365 | continue; |
| 366 | } |
| 367 | std::vector<uint8_t> source_sym (symbol_size, 0); |
| 368 | auto it = source_sym.begin(); |
| 369 | (*sym_it) (it, source_sym.end()); |
| 370 | encoded.emplace_back ((*sym_it).id(), std::move(source_sym)); |
| 371 | } |
| 372 | auto sym_it = block.begin_repair(); |
| 373 | for (; repair >= 0 && sym_it != block.end_repair (block.max_repair()); |
| 374 | ++sym_it) { |
| 375 | // repair symbols can be lost, too |
| 376 | float dropped = drop (rnd); |
| 377 | if (dropped <= drop_prob) { |
| 378 | continue; |
no test coverage detected