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());
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),
Loading full blame...