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/wrapper/C_RFC_API.h"
#include "RaptorQ/v1/wrapper/CPP_RFC_API.hpp"
#include "RaptorQ/v1/caches.hpp"
RaptorQ_ptr (const RaptorQ_type _type) : ptr (nullptr), type (_type) {}
struct RAPTORQ_LOCAL RaptorQ_future
{
void RAPTORQ_LOCAL RFC6330_test_del (struct RaptorQ_ptr **ptr);
void RAPTORQ_LOCAL RFC6330_test_del (struct RaptorQ_ptr **ptr)
{
if (ptr == nullptr || *ptr == nullptr ||
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
|| (*ptr)->ptr == nullptr) {
if (ptr != nullptr) {
delete *ptr;
*ptr = nullptr;
return;
}
return;
}
switch ((*ptr)->type) {
case RaptorQ_type::RQ_ENC_8:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_16:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint16_t, uint16_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_32:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_ENC_64:
if(!(reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_8:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_16:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_32:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_DEC_64:
if(!(reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
(*ptr)->ptr))) {
RaptorQ_free (ptr);
return;
}
break;
case RaptorQ_type::RQ_NONE:
assert(false && "RaptorQ: C Wrapper: should not have gotten here");
break;
}
return;
}
struct RaptorQ_ptr *RaptorQ_Enc (const RaptorQ_type type, void *data,
const uint64_t size,
const uint16_t min_subsymbol_size,
const uint16_t symbol_size,
const size_t max_memory)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
switch (type) {
case RaptorQ_type::RQ_ENC_8:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint8_t*, uint8_t*> (
reinterpret_cast<uint8_t*> (data),
reinterpret_cast<uint8_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_16:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint16_t*, uint16_t*> (
reinterpret_cast<uint16_t*> (data),
reinterpret_cast<uint16_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_32:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint32_t*, uint32_t*> (
reinterpret_cast<uint32_t*> (data),
reinterpret_cast<uint32_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_ENC_64:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Encoder<uint64_t*, uint64_t*> (
reinterpret_cast<uint64_t*> (data),
reinterpret_cast<uint64_t*> (data) + size,
min_subsymbol_size,
symbol_size,
max_memory));
break;
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return new RaptorQ_ptr (RaptorQ_type::RQ_NONE);
}
auto raw_ptr = ret.release();
RFC6330_test_del (&raw_ptr);
return raw_ptr;
const RaptorQ_OTI_Common_Data common,
const RaptorQ_OTI_Scheme_Specific_Data scheme)
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
switch (type) {
case RaptorQ_type::RQ_DEC_8:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint8_t*, uint8_t*> (common, scheme));
break;
case RaptorQ_type::RQ_DEC_16:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint16_t*, uint16_t*> (common,scheme));
break;
case RaptorQ_type::RQ_DEC_32:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint32_t*, uint32_t*> (common,scheme));
break;
case RaptorQ_type::RQ_DEC_64:
ret->ptr = reinterpret_cast<void *> (
new RFC6330__v1::Decoder<uint64_t*, uint64_t*> (common,scheme));
break;
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
return new RaptorQ_ptr (RaptorQ_type::RQ_NONE);
}
auto raw_ptr = ret.release();
RFC6330_test_del (&raw_ptr);
return raw_ptr;
///////////////////////////
// Precomputation caching
///////////////////////////
RaptorQ_Compress RaptorQ_supported_compressions()
return static_cast<RaptorQ_Compress>(RaptorQ__v1::supported_compressions());
RaptorQ_Compress RaptorQ_get_compression()
{
return static_cast<RaptorQ_Compress>(RaptorQ__v1::get_compression());
}
bool RaptorQ_set_compression (const RaptorQ_Compress compression)
{
return static_cast<RaptorQ_Compress> (RaptorQ__v1::set_compression (
static_cast<RaptorQ__v1::Compress> (compression)));
size_t RaptorQ_shared_cache_size (const size_t shared_cache)
RaptorQ_Error RaptorQ_local_cache_size (const size_t local_cache)
return static_cast<RaptorQ_Error> (RaptorQ__v1::local_cache_size (
local_cache));
/////////////////////
// Common functions
/////////////////////
bool RaptorQ_set_thread_pool (const size_t threads,
const uint16_t max_block_concurrency,
const RaptorQ_Work exit_type)
return RFC6330__v1::set_thread_pool (threads, max_block_concurrency,
static_cast<RaptorQ__v1::Work_State> (exit_type));
}
RaptorQ_Error RaptorQ_future_valid (struct RaptorQ_future *future)
{
if (future == nullptr)
return RQ_ERR_WRONG_INPUT;
if (future->f.valid())
return static_cast<RaptorQ_Error> (future->f.get().first);
return RQ_ERR_WORKING;
}
RaptorQ_Error RaptorQ_future_wait_for (struct RaptorQ_future *future,
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
if (future == nullptr)
return RQ_ERR_WRONG_INPUT;
std::future_status status = std::future_status::timeout;
switch (unit) {
case RQ_TIME_NANOSEC:
status = future->f.wait_for (std::chrono::nanoseconds (time));
break;
case RQ_TIME_MICROSEC:
status = future->f.wait_for (std::chrono::microseconds (time));
break;
case RQ_TIME_MILLISEC:
status = future->f.wait_for (std::chrono::milliseconds (time));
break;
case RQ_TIME_SEC:
status = future->f.wait_for (std::chrono::seconds (time));
break;
case RQ_TIME_MIN:
status = future->f.wait_for (std::chrono::minutes (time));
break;
case RQ_TIME_HOUR:
status = future->f.wait_for (std::chrono::hours (time));
break;
}
if (status == std::future_status::ready)
return static_cast<RaptorQ_Error> (future->f.get().first);
return RQ_ERR_WORKING;
}
void RaptorQ_future_wait (struct RaptorQ_future *future)
{
}
struct RaptorQ_Result RaptorQ_future_get (struct RaptorQ_future *future)
{
RaptorQ_Result res = {RQ_ERR_WRONG_INPUT, 0};
if (future == nullptr)
return res;
RFC6330__v1::Error err;
std::tie (err, res.sbn) = future->f.get(); // already calls wait();
res.error = static_cast<RaptorQ_Error> (err);
return res;
}
void RaptorQ_future_free (struct RaptorQ_future **future)
{
if (future == nullptr || *future == nullptr)
return;
delete *future;
*future = nullptr;
RaptorQ_future* RaptorQ_compute (RaptorQ_ptr *ptr, const RaptorQ_Compute flags)
{
335
336
337
338
339
340
341
342
343
344
345
346
347
348
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
if (ptr == nullptr || ptr->type == RaptorQ_type::RQ_NONE ||
ptr->ptr == nullptr)
return nullptr;
const RFC6330__v1::Compute cpp_flags =
static_cast<RFC6330__v1::Compute> (flags);
std::future<std::pair<RaptorQ__v1::Error, uint8_t>> f;
switch (ptr->type) {
case RaptorQ_type::RQ_ENC_8:
f = (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_ENC_16:
f = (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_ENC_32:
f = (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_ENC_64:
f = (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_DEC_8:
f = (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_DEC_16:
f = (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_DEC_32:
f = (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_DEC_64:
f = (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->compute (cpp_flags);
break;
case RaptorQ_type::RQ_NONE:
return nullptr;
}
RaptorQ_future *ret = new RaptorQ_future();
ret->f = std::move(f);
return ret;
///////////
// Encoding
///////////
RaptorQ_OTI_Common_Data RaptorQ_OTI_Common (struct RaptorQ_ptr *enc)
{
if (enc == nullptr || enc->type == RaptorQ_type::RQ_NONE ||
enc->ptr == nullptr)
return 0;
switch (enc->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->OTI_Common();
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->OTI_Common();
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->OTI_Common();
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->OTI_Common();
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
}
RaptorQ_OTI_Scheme_Specific_Data RaptorQ_OTI_Scheme (struct RaptorQ_ptr *enc)
{
if (enc == nullptr || enc->type == RaptorQ_type::RQ_NONE ||
enc->ptr == nullptr)
return 0;
switch (enc->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->OTI_Scheme_Specific();
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->OTI_Scheme_Specific();
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->OTI_Scheme_Specific();
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->OTI_Scheme_Specific();
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
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
482
483
484
485
if (ptr == nullptr || ptr->type == RaptorQ_type::RQ_NONE ||
ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbol_size();
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
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
524
525
526
if (ptr == nullptr || ptr->type == RaptorQ_type::RQ_NONE ||
ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t, uint16_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->blocks();
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
}
uint32_t RaptorQ_block_size (RaptorQ_ptr *ptr, const uint8_t sbn)
{
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
567
if (ptr == nullptr || ptr->type == RaptorQ_type::RQ_NONE ||
ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->block_size(sbn);
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
}
uint16_t RaptorQ_symbols (RaptorQ_ptr *ptr, const uint8_t sbn)
{
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
if (ptr == nullptr || ptr->type == RaptorQ_type::RQ_NONE ||
ptr->ptr == nullptr)
return 0;
switch (ptr->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
ptr->ptr))->symbols(sbn);
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
}
uint32_t RaptorQ_max_repair (RaptorQ_ptr *enc, const uint8_t sbn)
{
if (enc == nullptr || enc->type == RaptorQ_type::RQ_NONE ||
enc->ptr == nullptr)
return 0;
switch (enc->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->max_repair (sbn);
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->max_repair (sbn);
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->max_repair (sbn);
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->max_repair (sbn);
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
}
size_t RaptorQ_precompute_max_memory (RaptorQ_ptr *enc)
{
if (enc == nullptr || enc->type == RaptorQ_type::RQ_NONE ||
enc->ptr == nullptr)
return 0;
switch (enc->type) {
case RaptorQ_type::RQ_ENC_8:
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->precompute_max_memory();
case RaptorQ_type::RQ_ENC_16:
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->precompute_max_memory();
case RaptorQ_type::RQ_ENC_32:
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->precompute_max_memory();
case RaptorQ_type::RQ_ENC_64:
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->precompute_max_memory();
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
size_t RaptorQ_encode_id (RaptorQ_ptr *enc, void **data, const size_t size,
uint8_t sbn = id >> 24;
uint32_t esi = (id << 8) >> 8;
return RaptorQ_encode (enc, data, size, esi, sbn);
size_t RaptorQ_encode (RaptorQ_ptr *enc, void **data, const size_t size,
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
if (enc == nullptr || enc->type == RaptorQ_type::RQ_NONE ||
enc->ptr == nullptr || data == nullptr || *data == nullptr) {
return 0;
}
// uhm... better ideas?
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
switch (enc->type) {
case RaptorQ_type::RQ_ENC_8:
p_8 = reinterpret_cast<uint8_t*> (*data);
return (reinterpret_cast<RFC6330__v1::Encoder<uint8_t*, uint8_t*>*> (
enc->ptr))->encode (p_8, p_8 + size,esi, sbn);
case RaptorQ_type::RQ_ENC_16:
p_16 = reinterpret_cast<uint16_t*> (*data);
return (reinterpret_cast<RFC6330__v1::Encoder<uint16_t*, uint16_t*>*> (
enc->ptr))->encode (p_16, p_16 + size,esi, sbn);
case RaptorQ_type::RQ_ENC_32:
p_32 = reinterpret_cast<uint32_t*> (*data);
return (reinterpret_cast<RFC6330__v1::Encoder<uint32_t*, uint32_t*>*> (
enc->ptr))->encode (p_32, p_32 + size,esi, sbn);
case RaptorQ_type::RQ_ENC_64:
p_64 = reinterpret_cast<uint64_t*> (*data);
return (reinterpret_cast<RFC6330__v1::Encoder<uint64_t*, uint64_t*>*> (
enc->ptr))->encode (p_64, p_64 + size,esi, sbn);
case RaptorQ_type::RQ_DEC_8:
case RaptorQ_type::RQ_DEC_16:
case RaptorQ_type::RQ_DEC_32:
case RaptorQ_type::RQ_DEC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
uint32_t RaptorQ_id (const uint32_t esi, const uint8_t sbn)
{
uint32_t ret = static_cast<uint32_t> (sbn) << 24;
ret += esi % static_cast<uint32_t> (std::pow (2, 24));
return ret;
void RAPTORQ_API RaptorQ_end_of_input (struct RaptorQ_ptr *dec)
{
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE)
return;
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
return;
}
}
void RAPTORQ_API RaptorQ_end_of_block_input (struct RaptorQ_ptr *dec,
const uint8_t block)
{
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE)
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
return;
}
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE)
return 0;
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
return (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
dec->ptr))->bytes ();
case RaptorQ_type::RQ_DEC_16:
return (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
dec->ptr))->bytes ();
case RaptorQ_type::RQ_DEC_32:
return (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
dec->ptr))->bytes ();
case RaptorQ_type::RQ_DEC_64:
return (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
dec->ptr))->bytes ();
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
return 0;
}
// uncomment the return and:
// clang: WARN: will never be executed (exaustive switch)
// if commented, GCC: warn: control reaches end of non-void
// ...make up your mind, guys?
return 0;
uint64_t RaptorQ_decode_bytes (RaptorQ_ptr *dec, void **data,
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
uint64_t written = 0;
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE ||
dec->ptr == nullptr || data == nullptr || size <= skip){
return written;
}
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
p_8 = reinterpret_cast<uint8_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
dec->ptr))->decode_bytes (p_8, p_8 + size, skip);
*data = p_8;
break;
case RaptorQ_type::RQ_DEC_16:
p_16 = reinterpret_cast<uint16_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
dec->ptr))->decode_bytes (p_16, p_16 + size, skip);
*data = p_16;
break;
case RaptorQ_type::RQ_DEC_32:
p_32 = reinterpret_cast<uint32_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
dec->ptr))->decode_bytes (p_32, p_32 + size, skip);
*data = p_32;
break;
case RaptorQ_type::RQ_DEC_64:
p_64 = reinterpret_cast<uint64_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
dec->ptr))->decode_bytes (p_64, p_64 + size, skip);
*data = p_64;
break;
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
break;
}
return written;
size_t RaptorQ_decode_block_bytes (RaptorQ_ptr *dec, void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn)
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
size_t written = 0;
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE ||
dec->ptr == nullptr || data == nullptr) {
return written;
}
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
p_8 = reinterpret_cast<uint8_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
dec->ptr))->decode_block_bytes (p_8, p_8 + size,
skip, sbn);
*data = p_8;
break;
case RaptorQ_type::RQ_DEC_16:
p_16 = reinterpret_cast<uint16_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
dec->ptr))->decode_block_bytes (p_16, p_16 + size,
skip, sbn);
*data = p_16;
break;
case RaptorQ_type::RQ_DEC_32:
p_32 = reinterpret_cast<uint32_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
dec->ptr))->decode_block_bytes (p_32, p_32 + size,
skip, sbn);
*data = p_32;
break;
case RaptorQ_type::RQ_DEC_64:
p_64 = reinterpret_cast<uint64_t*> (*data);
written = (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
dec->ptr))->decode_block_bytes (p_64, p_64 + size,
skip, sbn);
*data = p_64;
break;
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
break;
}
return written;
}
RaptorQ_Dec_Result RaptorQ_decode_aligned (RaptorQ_ptr *dec, void **data,
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
992
993
994
RaptorQ_Dec_Result c_ret = {0, 0};
if (dec == nullptr || dec->type == RaptorQ_type::RQ_NONE ||
dec->ptr == nullptr || data == nullptr || size <= skip){
return c_ret;
}
uint8_t *p_8;
uint16_t *p_16;
uint32_t *p_32;
uint64_t *p_64;
std::pair<size_t, uint8_t> ret = {0, 0};
switch (dec->type) {
case RaptorQ_type::RQ_DEC_8:
p_8 = reinterpret_cast<uint8_t*> (*data);
ret = (reinterpret_cast<RFC6330__v1::Decoder<uint8_t*, uint8_t*>*> (
dec->ptr))->decode_aligned (
p_8, p_8 + size, skip);
*data = p_8;
break;
case RaptorQ_type::RQ_DEC_16:
p_16 = reinterpret_cast<uint16_t*> (*data);
ret = (reinterpret_cast<RFC6330__v1::Decoder<uint16_t*, uint16_t*>*> (
dec->ptr))->decode_aligned (
p_16, p_16 + size, skip);
*data = p_16;
break;
case RaptorQ_type::RQ_DEC_32:
p_32 = reinterpret_cast<uint32_t*> (*data);
ret = (reinterpret_cast<RFC6330__v1::Decoder<uint32_t*, uint32_t*>*> (
dec->ptr))->decode_aligned (
p_32, p_32 + size, skip);
*data = p_32;
break;
case RaptorQ_type::RQ_DEC_64:
p_64 = reinterpret_cast<uint64_t*> (*data);
ret = (reinterpret_cast<RFC6330__v1::Decoder<uint64_t*, uint64_t*>*> (
dec->ptr))->decode_aligned (
p_64, p_64 + size, skip);
*data = p_64;
break;
case RaptorQ_type::RQ_ENC_8:
case RaptorQ_type::RQ_ENC_16:
case RaptorQ_type::RQ_ENC_32:
case RaptorQ_type::RQ_ENC_64:
case RaptorQ_type::RQ_NONE:
break;
}
c_ret.written = std::get<0> (ret);
c_ret.skip = std::get<1> (ret);
return c_ret;
RaptorQ_Dec_Result RaptorQ_decode_block_aligned (RaptorQ_ptr *dec, void **data,
const size_t size,
const uint8_t skip,
const uint8_t sbn)