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) {}
////////////////////////
////
//// 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 v1_supported_compressions();
static RFC6330_Compress v1_get_compression();
static bool v1_set_compression (const RFC6330_Compress compression);
static size_t v1_local_cache_size (const size_t local_cache);
static size_t v1_get_local_cache_size ();
const void *data_from,
const size_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory);
const RFC6330_OTI_Common_Data common,
const RFC6330_OTI_Scheme_Specific_Data scheme);
static 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);
static uint8_t v1_blocks (const struct RFC6330_ptr *ptr);
static uint16_t v1_symbols (const struct RFC6330_ptr *ptr, const uint8_t sbn);
static size_t v1_symbol_size (const struct RFC6330_ptr *ptr);
static RaptorQ_Error v1_future_state (const struct RFC6330_future *f);
static RaptorQ_Error v1_future_wait_for (const struct RFC6330_future *f,
static void v1_future_wait (const struct RFC6330_future *f);
static void v1_future_free (struct RFC6330_future **f);
static struct RFC6330_Result v1_future_get (struct RFC6330_future *future);
static bool v1_set_thread_pool (const size_t threads,
const uint16_t max_block_concurrency,
const RFC6330_Work exit_type);
static struct RFC6330_future* v1_compute (const struct RFC6330_ptr *ptr,
static void v1_free (struct RFC6330_ptr **ptr);
static void v1_free_block (const struct RFC6330_ptr *ptr, const uint8_t sbn);
static RFC6330_OTI_Common_Data v1_OTI_Common (const struct RFC6330_ptr *enc);
static RFC6330_OTI_Scheme_Specific_Data v1_OTI_Scheme_Specific (
static uint32_t v1_max_repair (const struct RFC6330_ptr *enc,
static size_t v1_precompute_max_memory (const struct RFC6330_ptr *enc);
static size_t v1_encode_id (const struct RFC6330_ptr *enc, void **data,
static size_t v1_encode (const struct RFC6330_ptr *enc, void **data,
const size_t size,
const uint32_t esi,
const uint8_t sbn);
static uint32_t v1_id (const uint32_t esi, const uint8_t sbn);
static void v1_end_of_input (const struct RFC6330_ptr *dec);
static void v1_end_of_block_input (const struct RFC6330_ptr *dec,
static uint64_t v1_bytes (const struct RFC6330_ptr *dec);
static struct RFC6330_Dec_Result v1_decode_aligned (
const struct RFC6330_ptr *dec,
void **data,
const uint64_t size,
const uint8_t skip);
const struct RFC6330_ptr *dec,
void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn);
static uint64_t v1_decode_bytes (const struct RFC6330_ptr *dec, void **data,
static size_t v1_decode_block_bytes (const struct RFC6330_ptr *dec, void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn);
static RFC6330_Error v1_add_symbol_id (const struct RFC6330_ptr *dec,
static RFC6330_Error 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());
168
169
170
171
172
173
174
175
176
177
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
RFC6330_v1::RFC6330_v1()
: base (1),
// precomputation caching
supported_compressions (&v1_supported_compressions),
get_compression (&v1_get_compression),
set_compression (&v1_set_compression),
local_cache_size (&v1_local_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_local_cache_size (const size_t local_cache)
{ return RFC6330__v1::local_cache_size (local_cache); }
static size_t v1_get_local_cache_size ()
{ return RFC6330__v1::get_local_cache_size(); }
/////////////////////
// Constructors
/////////////////////
const void *data_from,
const size_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory)
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
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
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);
const RFC6330_OTI_Common_Data common,
const RFC6330_OTI_Scheme_Specific_Data scheme)
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
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);
static 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)
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
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);
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
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
/////////////////////
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
{
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;
}
static uint16_t v1_symbols (const struct RFC6330_ptr *ptr, const uint8_t sbn)
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
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;
static size_t v1_symbol_size (const struct RFC6330_ptr *ptr)
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
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;
static 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;
}
static 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;
static void v1_future_wait (const struct RFC6330_future *f)
if (f == nullptr || *f == nullptr)
return;
delete *f;
*f = nullptr;
}
static 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};
}
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));
static struct RFC6330_future* v1_compute (const struct RFC6330_ptr *ptr,
std::unique_ptr<RFC6330_future> ret = std::unique_ptr<RFC6330_future> (
new RFC6330_future());
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
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:
static void v1_free_block (const struct RFC6330_ptr *ptr, const uint8_t sbn)
749
750
751
752
753
754
755
756
757
758
759
760
761
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
{
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;
static 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;
static RFC6330_OTI_Scheme_Specific_Data v1_OTI_Scheme_Specific (
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;
static 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;
static size_t v1_precompute_max_memory (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;
static size_t v1_encode_id (const struct RFC6330_ptr *enc, void **data,
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
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
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;
static size_t v1_encode (const struct RFC6330_ptr *enc, void **data,
const size_t size,
return 0;
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
ret = (reinterpret_cast<
RFC6330__v1::Impl::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->encode (
p_8, p_8 + size,
esi, sbn);
*data = p_8;
return ret;
case RFC6330_type::RQ_ENC_16: