Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
/*
* Copyright (c) 2015, 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/>.
*/
#ifndef RAPTORQ_C_H
#define RAPTORQ_C_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
typedef uint64_t RaptorQ_OTI_Common_Data;
typedef uint32_t RaptorQ_OTI_Scheme_Specific_Data;
typedef enum { NONE = 0, ENC_8 = 1, ENC_16 = 2, ENC_32 = 3, ENC_64 = 4,
DEC_8 = 5, DEC_16 = 6, DEC_32 = 7, DEC_64 = 8}
RaptorQ_type;
struct RaptorQ_ptr
{
#ifdef __cplusplus
RaptorQ_ptr (const RaptorQ_type _type) :type (_type) {}
#endif
void *ptr;
const RaptorQ_type type;
};
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);
struct RaptorQ_ptr *RaptorQ_Dec (const RaptorQ_type type,
const RaptorQ_OTI_Common_Data common,
const RaptorQ_OTI_Scheme_Specific_Data scheme);
///////////
// Encoding
///////////
RaptorQ_OTI_Common_Data RaptorQ_OTI_Common (struct RaptorQ_ptr *enc);
RaptorQ_OTI_Scheme_Specific_Data RaptorQ_OTI_Scheme (struct RaptorQ_ptr *enc);
uint16_t RaptorQ_symbol_size (struct RaptorQ_ptr *ptr);
uint8_t RaptorQ_blocks (struct RaptorQ_ptr *ptr);
uint32_t RaptorQ_block_size (struct RaptorQ_ptr *ptr, const uint8_t sbn);
uint16_t RaptorQ_symbols (struct RaptorQ_ptr *ptr, const uint8_t sbn);
uint32_t RaptorQ_max_repair (RaptorQ_ptr *enc, const uint8_t sbn);
size_t RaptorQ_precompute_max_memory (struct RaptorQ_ptr *enc);
void RaptorQ_precompute (struct RaptorQ_ptr *enc, const uint8_t threads,
const bool background);
uint64_t RaptorQ_encode_id (struct RaptorQ_ptr *enc, void **data,
const uint64_t size,
const uint32_t id);
uint64_t RaptorQ_encode (struct RaptorQ_ptr *enc, void **data,
const uint64_t size,
const uint32_t esi,
const uint8_t sbn);
///////////
// Decoding
///////////
uint32_t RaptorQ_decode (struct RaptorQ_ptr *dec, void **data,
const size_t size);
uint32_t RaptorQ_decode_sbn (struct RaptorQ_ptr *dec, void **data,
const size_t size,
const uint8_t sbn);
bool RaptorQ_add_symbol_id (struct RaptorQ_ptr *dec, void **data,
const uint32_t size,
const uint32_t id);
bool RaptorQ_add_symbol (struct RaptorQ_ptr *dec, void **data,
const uint32_t size,
const uint32_t esi,
const uint8_t sbn);
///////////////////////
// General: free memory
///////////////////////
void RaptorQ_free (struct RaptorQ_ptr **ptr);
void RaptorQ_free_block (struct RaptorQ_ptr *ptr, const uint8_t sbn);
#ifdef __cplusplus
} // extern "C"
#endif
#endif