-
Notifications
You must be signed in to change notification settings - Fork 31
/
schifra_reed_solomon_file_encoding_example.cpp
67 lines (55 loc) · 2.96 KB
/
schifra_reed_solomon_file_encoding_example.cpp
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
/*
(**************************************************************************)
(* *)
(* Schifra *)
(* Reed-Solomon Error Correcting Code Library *)
(* *)
(* Release Version 0.0.1 *)
(* http://www.schifra.com *)
(* Copyright (c) 2000-2020 Arash Partow, All Rights Reserved. *)
(* *)
(* The Schifra Reed-Solomon error correcting code library and all its *)
(* components are supplied under the terms of the General Schifra License *)
(* agreement. The contents of the Schifra Reed-Solomon error correcting *)
(* code library and all its components may not be copied or disclosed *)
(* except in accordance with the terms of that agreement. *)
(* *)
(* URL: http://www.schifra.com/license.html *)
(* *)
(**************************************************************************)
*/
#include <cstddef>
#include <string>
#include "schifra_galois_field.hpp"
#include "schifra_sequential_root_generator_polynomial_creator.hpp"
#include "schifra_reed_solomon_encoder.hpp"
#include "schifra_reed_solomon_file_encoder.hpp"
int main()
{
const std::size_t field_descriptor = 8;
const std::size_t gen_poly_index = 120;
const std::size_t gen_poly_root_count = 6;
const std::size_t code_length = 255;
const std::size_t fec_length = 6;
const std::string input_file_name = "input.dat";
const std::string output_file_name = "output.schifra";
typedef schifra::reed_solomon::encoder<code_length,fec_length> encoder_t;
typedef schifra::reed_solomon::file_encoder<code_length,fec_length> file_encoder_t;
const schifra::galois::field field(field_descriptor,
schifra::galois::primitive_polynomial_size06,
schifra::galois::primitive_polynomial06);
schifra::galois::field_polynomial generator_polynomial(field);
if (
!schifra::make_sequential_root_generator_polynomial(field,
gen_poly_index,
gen_poly_root_count,
generator_polynomial)
)
{
std::cout << "Error - Failed to create sequential root generator!" << std::endl;
return 1;
}
const encoder_t rs_encoder(field,generator_polynomial);
file_encoder_t(rs_encoder, input_file_name, output_file_name);
return 0;
}