Newer
Older
* Copyright (c) 2015-2017, 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
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),
Loading full blame...