Newer
Older
* Copyright (c) 2015-2016, Luca Fulchir<luca@fulchir.it>, All rights reserved.
*
* This file is part of "libRaptorQ".
*
* libRaptorQ is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* libRaptorQ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* and a copy of the GNU Lesser General Public License
* along with libRaptorQ. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RaptorQ/v1/caches.hpp"
RFC6330_ptr ()
: ptr (nullptr), type (RFC6330_type::RQ_NONE) {}
RFC6330_ptr (const RFC6330_type _type, void *const _ptr)
: ptr (_ptr), type (_type) {}
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
////////////////////////
////
//// For ease of development please keep the function declaration
//// and implementation in the same orders as defined in the structs!
////
////////////////////////
// precomputation caching
static RFC6330_Compress RAPTORQ_LOCAL v1_supported_compressions();
static RFC6330_Compress RAPTORQ_LOCAL v1_get_compression();
static bool RAPTORQ_LOCAL v1_set_compression (
const RFC6330_Compress compression);
static size_t RAPTORQ_LOCAL v1_shared_cache_size (const size_t shared_cache);
static size_t RAPTORQ_LOCAL v1_local_cache_size (const size_t local_cache);
static size_t RAPTORQ_LOCAL v1_get_shared_cache_size ();
static size_t RAPTORQ_LOCAL v1_get_local_cache_size ();
// constructors
struct RFC6330_ptr* RAPTORQ_LOCAL v1_Encoder (RFC6330_type type,
const void *data_from,
const size_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory);
struct RFC6330_ptr* RAPTORQ_LOCAL v1_Decoder (RFC6330_type type,
const RFC6330_OTI_Common_Data common,
const RFC6330_OTI_Scheme_Specific_Data scheme);
struct RFC6330_ptr* RAPTORQ_LOCAL v1_Decoder_raw (RFC6330_type type,
const uint64_t size,
const uint16_t symbol_size,
const uint16_t sub_blocks,
const uint8_t blocks,
const uint8_t alignment);
static bool RAPTORQ_LOCAL v1_initialized (const struct RFC6330_ptr *ptr);
// common functions
uint8_t RAPTORQ_LOCAL v1_blocks (const struct RFC6330_ptr *ptr);
uint16_t RAPTORQ_LOCAL v1_symbols (const struct RFC6330_ptr *ptr,
const uint8_t sbn);
size_t RAPTORQ_LOCAL v1_symbol_size (const struct RFC6330_ptr *ptr);
RaptorQ_Error RAPTORQ_LOCAL v1_future_state (const struct RFC6330_future *f);
RaptorQ_Error RAPTORQ_LOCAL v1_future_wait_for (const struct RFC6330_future *f,
const uint64_t time,
const RFC6330_Unit_Time unit);
void RAPTORQ_LOCAL v1_future_wait (const struct RFC6330_future *f);
void RAPTORQ_LOCAL v1_future_free (struct RFC6330_future **f);
struct RFC6330_Result RAPTORQ_LOCAL v1_future_get (
struct RFC6330_future *future);
bool RAPTORQ_LOCAL v1_set_thread_pool (const size_t threads,
const uint16_t max_block_concurrency,
const RFC6330_Work exit_type);
struct RFC6330_future* RAPTORQ_LOCAL v1_compute (const struct RFC6330_ptr *ptr,
const RFC6330_Compute flags);
void RAPTORQ_LOCAL v1_free (struct RFC6330_ptr **ptr);
void RAPTORQ_LOCAL v1_free_block (const struct RFC6330_ptr *ptr,
const uint8_t sbn);
// encoder-specific
RFC6330_OTI_Common_Data RAPTORQ_LOCAL v1_OTI_Common (
const struct RFC6330_ptr *enc);
RFC6330_OTI_Scheme_Specific_Data RAPTORQ_LOCAL v1_OTI_Scheme_Specific (
const struct RFC6330_ptr *enc);
uint32_t RAPTORQ_LOCAL v1_max_repair (const struct RFC6330_ptr *enc,
const uint8_t sbn);
size_t RAPTORQ_LOCAL v1_precompute_max_memory (const struct RFC6330_ptr *enc);
size_t RAPTORQ_LOCAL v1_encode_id (const struct RFC6330_ptr *enc, void **data,
const size_t size,
const uint32_t id);
size_t RAPTORQ_LOCAL v1_encode (const struct RFC6330_ptr *enc, void **data,
const size_t size,
const uint32_t esi,
const uint8_t sbn);
uint32_t RAPTORQ_LOCAL v1_id (const uint32_t esi, const uint8_t sbn);
// decoder-specific
void RAPTORQ_LOCAL v1_end_of_input (const struct RFC6330_ptr *dec);
void RAPTORQ_LOCAL v1_end_of_block_input (const struct RFC6330_ptr *dec,
const uint8_t block);
uint64_t RAPTORQ_LOCAL v1_bytes (const struct RFC6330_ptr *dec);
struct RFC6330_Dec_Result RAPTORQ_LOCAL v1_decode_aligned (
const struct RFC6330_ptr *dec,
void **data,
const uint64_t size,
const uint8_t skip);
struct RFC6330_Dec_Result RAPTORQ_LOCAL v1_decode_block_aligned (
const struct RFC6330_ptr *dec,
void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn);
uint64_t RAPTORQ_LOCAL v1_decode_bytes (const struct RFC6330_ptr *dec,
void **data,
const uint64_t size,
const uint8_t skip);
size_t RAPTORQ_LOCAL v1_decode_block_bytes (const struct RFC6330_ptr *dec,
void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn);
RFC6330_Error RAPTORQ_LOCAL v1_add_symbol_id (const struct RFC6330_ptr *dec,
void **data,
const uint32_t size,
const uint32_t id);
RFC6330_Error RAPTORQ_LOCAL v1_add_symbol (const struct RFC6330_ptr *dec,
void **data,
const uint32_t size,
const uint32_t esi,
const uint8_t sbn);
void RFC6330_free_api (struct RFC6330_base_api **api)
if ((*api)->version == 1) {
delete reinterpret_cast<struct RFC6330_v1*> (*api);
} // else it's all your fault anway
*api = nullptr;
if (version != 1)
return nullptr;
return reinterpret_cast<RFC6330_base_api *> (new RFC6330_v1());
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
RFC6330_v1::RFC6330_v1()
: base (1),
// precomputation caching
supported_compressions (&v1_supported_compressions),
get_compression (&v1_get_compression),
set_compression (&v1_set_compression),
shared_cache_size (&v1_shared_cache_size),
local_cache_size (&v1_local_cache_size),
get_shared_cache_size (&v1_get_shared_cache_size),
get_local_cache_size (&v1_get_local_cache_size),
// constructors
Encoder (&v1_Encoder),
Decoder (&v1_Decoder),
Decoder_raw (&v1_Decoder_raw),
initialized (&v1_initialized),
// common functions
blocks (&v1_blocks),
symbols (&v1_symbols),
symbol_size (&v1_symbol_size),
future_state (&v1_future_state),
future_wait_for (&v1_future_wait_for),
future_wait (&v1_future_wait),
future_free (&v1_future_free),
future_get (&v1_future_get),
set_thread_pool (&v1_set_thread_pool),
compute (&v1_compute),
free (&v1_free),
free_block (&v1_free_block),
// encoder-specific functions
OTI_Common (&v1_OTI_Common),
OTI_Scheme_Specific (&v1_OTI_Scheme_Specific),
max_repair (&v1_max_repair),
precompute_max_memory (&v1_precompute_max_memory),
encode_id (&v1_encode_id),
encode (&v1_encode),
id (&v1_id),
// decoder-specific functions
end_of_input (&v1_end_of_input),
end_of_block_input (&v1_end_of_block_input),
bytes (&v1_bytes),
decode_aligned (&v1_decode_aligned),
decode_block_aligned (&v1_decode_block_aligned),
decode_bytes (&v1_decode_bytes),
decode_block_bytes (&v1_decode_block_bytes),
add_symbol_id (&v1_add_symbol_id),
add_symbol (&v1_add_symbol)
{}
///////////////////////////
// Precomputation caching
///////////////////////////
return static_cast<RFC6330_Compress>(RaptorQ__v1::supported_compressions());
static RFC6330_Compress v1_get_compression()
{ return static_cast<RFC6330_Compress>(RaptorQ__v1::get_compression()); }
static bool v1_set_compression (const RFC6330_Compress compression)
return static_cast<RFC6330_Compress> (RaptorQ__v1::set_compression (
static size_t v1_shared_cache_size (const size_t shared_cache)
{ return RFC6330__v1::shared_cache_size (shared_cache); }
static size_t v1_local_cache_size (const size_t local_cache)
{ return RFC6330__v1::local_cache_size (local_cache); }
static size_t v1_get_shared_cache_size ()
{ return RFC6330__v1::get_shared_cache_size(); }
static size_t v1_get_local_cache_size ()
{ return RFC6330__v1::get_local_cache_size(); }
/////////////////////
// Constructors
/////////////////////
struct RFC6330_ptr* v1_Encoder (RFC6330_type type,
const void *data_from,
const size_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory)
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
void *raw_ptr = nullptr;
switch (type) {
case RFC6330_type::RQ_ENC_8:
p_8 = reinterpret_cast<uint8_t*> (const_cast<void*> (data_from));
raw_ptr = reinterpret_cast<void *> (
new RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*> (
p_8, p_8 + size,
min_subsymbol_size, symbol_size,
max_memory));
break;
case RFC6330_type::RQ_ENC_16:
p_16 = reinterpret_cast<uint16_t*> (const_cast<void*> (data_from));
raw_ptr = reinterpret_cast<void *> (
new RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*> (
p_16, p_16 + size,
min_subsymbol_size, symbol_size,
max_memory));
break;
case RFC6330_type::RQ_ENC_32:
p_32 = reinterpret_cast<uint32_t*> (const_cast<void*> (data_from));
raw_ptr = reinterpret_cast<void *> (
new RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*> (
p_32, p_32 + size,
min_subsymbol_size, symbol_size,
max_memory));
break;
case RFC6330_type::RQ_ENC_64:
p_64 = reinterpret_cast<uint64_t*> (const_cast<void*> (data_from));
raw_ptr = reinterpret_cast<void *> (
new RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*> (
p_64, p_64 + size,
min_subsymbol_size, symbol_size,
max_memory));
break;
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
return nullptr;
}
if (raw_ptr == nullptr)
return nullptr;
return new RFC6330_ptr (type, raw_ptr);
struct RFC6330_ptr* v1_Decoder (RFC6330_type type,
const RFC6330_OTI_Common_Data common,
const RFC6330_OTI_Scheme_Specific_Data scheme)
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
void *raw_ptr = nullptr;
namespace RQ = RFC6330__v1::Impl;
switch (type) {
case RFC6330_type::RQ_DEC_8:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint8_t*, uint8_t*> (common, scheme));
break;
case RFC6330_type::RQ_DEC_16:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint16_t*, uint16_t*> (common, scheme));
break;
case RFC6330_type::RQ_DEC_32:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint32_t*, uint32_t*> (common, scheme));
break;
case RFC6330_type::RQ_DEC_64:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint64_t*, uint64_t*> (common, scheme));
break;
case RFC6330_type::RQ_ENC_8:
case RFC6330_type::RQ_ENC_16:
case RFC6330_type::RQ_ENC_32:
case RFC6330_type::RQ_ENC_64:
case RFC6330_type::RQ_NONE:
return nullptr;
}
if (raw_ptr == nullptr)
return nullptr;
return new RFC6330_ptr (type, raw_ptr);
struct RFC6330_ptr* v1_Decoder_raw (RFC6330_type type,
const uint64_t size,
const uint16_t symbol_size,
const uint16_t sub_blocks,
const uint8_t blocks,
const uint8_t alignment)
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
void *raw_ptr = nullptr;
namespace RQ = RFC6330__v1::Impl;
switch (type) {
case RFC6330_type::RQ_DEC_8:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint8_t*, uint8_t*> (size, symbol_size,
sub_blocks,
blocks,
alignment));
break;
case RFC6330_type::RQ_DEC_16:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint16_t*, uint16_t*> (size,symbol_size,
sub_blocks,
blocks,
alignment));
break;
case RFC6330_type::RQ_DEC_32:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint32_t*, uint32_t*> (size,symbol_size,
sub_blocks,
blocks,
alignment));
break;
case RFC6330_type::RQ_DEC_64:
raw_ptr = reinterpret_cast<void *> (
new RQ::Decoder<uint64_t*, uint64_t*> (size,symbol_size,
sub_blocks,
blocks,
alignment));
break;
case RFC6330_type::RQ_ENC_8:
case RFC6330_type::RQ_ENC_16:
case RFC6330_type::RQ_ENC_32:
case RFC6330_type::RQ_ENC_64:
case RFC6330_type::RQ_NONE:
return nullptr;
}
if (raw_ptr == nullptr)
return nullptr;
return new RFC6330_ptr (type, raw_ptr);
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
if (ptr == nullptr || ptr->ptr == nullptr)
return false;
switch (ptr->type) {
case RFC6330_type::RQ_ENC_8:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_ENC_16:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_ENC_32:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_ENC_64:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_DEC_8:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_DEC_16:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_DEC_32:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_DEC_64:
return (*reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr));
case RFC6330_type::RQ_NONE:
break;
}
return false;
/////////////////////
// Common functions
/////////////////////
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
uint8_t v1_blocks (const struct RFC6330_ptr *ptr)
{
if (ptr == nullptr || ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_DEC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_DEC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_DEC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_DEC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->blocks();
case RFC6330_type::RQ_NONE:
break;
}
return 0;
}
uint16_t v1_symbols (const struct RFC6330_ptr *ptr, const uint8_t sbn)
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
if (ptr == nullptr || ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_DEC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_DEC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_DEC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_DEC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbols (sbn);
case RFC6330_type::RQ_NONE:
break;
}
return 0;
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
if (ptr == nullptr || ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_DEC_8:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_DEC_16:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_DEC_32:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_DEC_64:
return (reinterpret_cast<const
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbol_size();
case RFC6330_type::RQ_NONE:
break;
}
return 0;
RaptorQ_Error v1_future_state (const struct RFC6330_future *f)
{
if (f == nullptr)
return RFC6330_Error::RQ_ERR_WRONG_INPUT;
if (f->f.valid())
return RFC6330_Error::RQ_ERR_WORKING;
return RaptorQ_Error::RQ_ERR_NOT_NEEDED;
}
RaptorQ_Error v1_future_wait_for (const struct RFC6330_future *f,
return RQ_ERR_WRONG_INPUT;
std::future_status status = std::future_status::timeout;
switch (unit) {
case RQ_TIME_NANOSEC:
return RaptorQ_Error::RQ_ERR_NONE;
return RaptorQ_Error::RQ_ERR_WORKING;
if (f == nullptr || *f == nullptr)
return;
delete *f;
*f = nullptr;
}
struct RFC6330_Result v1_future_get (struct RFC6330_future *const future)
{
RFC6330_Result res = {RQ_ERR_WRONG_INPUT, 0 };
if (future != nullptr && future->f.valid()) {
const auto cpp_res = future->f.get();
return RFC6330_Result {static_cast<RFC6330_Error> (cpp_res.first),
cpp_res.second};
}
bool v1_set_thread_pool (const size_t threads,
const uint16_t max_block_concurrency,
const RFC6330_Work exit_type)
return RFC6330__v1::set_thread_pool(threads, max_block_concurrency,
static_cast<RaptorQ__v1::Work_State> (exit_type));
struct RFC6330_future* v1_compute (const struct RFC6330_ptr *ptr,
const RFC6330_Compute flags)
std::unique_ptr<RFC6330_future> ret = std::unique_ptr<RFC6330_future> (
new RFC6330_future());
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
case RFC6330_type::RQ_ENC_8:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_ENC_16:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_ENC_32:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_ENC_64:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_DEC_8:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_DEC_16:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_DEC_32:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_DEC_64:
ret->f = (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->compute(static_cast<RFC6330__v1::Compute> (flags));
return ret.release();
case RFC6330_type::RQ_NONE:
}
return nullptr;
}
void v1_free (struct RFC6330_ptr **ptr)
{
if (ptr == nullptr || *ptr == nullptr)
return;
if ((*ptr)->ptr == nullptr) {
delete *ptr;
return;
}
switch ((*ptr)->type) {
case RFC6330_type::RQ_ENC_8:
delete reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> ((*ptr)->ptr);
case RFC6330_type::RQ_ENC_16:
delete reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*>((*ptr)->ptr);
case RFC6330_type::RQ_ENC_32:
delete reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*>((*ptr)->ptr);
case RFC6330_type::RQ_ENC_64:
delete reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*>((*ptr)->ptr);
case RFC6330_type::RQ_DEC_8:
delete reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> ((*ptr)->ptr);
case RFC6330_type::RQ_DEC_16:
delete reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*>((*ptr)->ptr);
case RFC6330_type::RQ_DEC_32:
delete reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*>((*ptr)->ptr);
break;
case RFC6330_type::RQ_DEC_64:
delete reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*>((*ptr)->ptr);
break;
case RFC6330_type::RQ_NONE:
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
delete *ptr;
*ptr = nullptr;
}
void v1_free_block (const struct RFC6330_ptr *ptr, const uint8_t sbn)
{
if (ptr == nullptr || ptr->ptr == nullptr)
return;
switch (ptr->type) {
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_DEC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_DEC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_DEC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_DEC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->free (sbn);
case RFC6330_type::RQ_NONE:
break;
}
return;
RFC6330_OTI_Common_Data v1_OTI_Common (const struct RFC6330_ptr *enc)
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
break;
RFC6330_OTI_Scheme_Specific_Data v1_OTI_Scheme_Specific (
const struct RFC6330_ptr *enc)
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
break;
uint32_t v1_max_repair (const struct RFC6330_ptr *enc, const uint8_t sbn)
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
break;
case RFC6330_type::RQ_ENC_8:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
case RFC6330_type::RQ_ENC_16:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
case RFC6330_type::RQ_ENC_32:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
case RFC6330_type::RQ_ENC_64:
return (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
break;
size_t v1_encode_id (const struct RFC6330_ptr *enc, void **data,
const size_t size,
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
if (enc == nullptr || enc->ptr == nullptr || data == nullptr)
return 0;
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
size_t ret;
switch (enc->type) {
case RFC6330_type::RQ_ENC_8:
p_8 = reinterpret_cast<uint8_t*> (*data);
ret = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->encode (
p_8, p_8 + size,id);
*data = p_8;
return ret;
case RFC6330_type::RQ_ENC_16:
p_16 = reinterpret_cast<uint16_t*> (*data);
ret = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->encode (
p_16, p_16 + size,id);
*data = p_16;
return ret;
case RFC6330_type::RQ_ENC_32:
p_32 = reinterpret_cast<uint32_t*> (*data);
ret = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->encode (
p_32, p_32 + size,id);
*data = p_32;
return ret;
case RFC6330_type::RQ_ENC_64:
p_64 = reinterpret_cast<uint64_t*> (*data);
ret = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->encode (
p_64, p_64 + size,id);
*data = p_64;
return ret;
case RFC6330_type::RQ_DEC_8:
case RFC6330_type::RQ_DEC_16:
case RFC6330_type::RQ_DEC_32:
case RFC6330_type::RQ_DEC_64:
case RFC6330_type::RQ_NONE:
break;
}
return 0;
size_t v1_encode (const struct RFC6330_ptr *enc, void **data, const size_t size,