Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
BC_ReedSolomonGF256.cpp
Go to the documentation of this file.
1
// Copyright 2014 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
// Original code is licensed as follows:
7
/*
8
* Copyright 2007 ZXing authors
9
*
10
* Licensed under the Apache License, Version 2.0 (the "License");
11
* you may not use this file except in compliance with the License.
12
* You may obtain a copy of the License at
13
*
14
* http://www.apache.org/licenses/LICENSE-2.0
15
*
16
* Unless required by applicable law or agreed to in writing, software
17
* distributed under the License is distributed on an "AS IS" BASIS,
18
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
* See the License for the specific language governing permissions and
20
* limitations under the License.
21
*/
22
23
#
include
"fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
24
25
#
include
<
vector
>
26
27
#
include
"fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
28
29
CBC_ReedSolomonGF256
::
CBC_ReedSolomonGF256
(int32_t primitive) {
30
int32_t x = 1;
31
for
(int32_t j = 0; j < 256; j++) {
32
m_expTable[j] = x;
33
x <<= 1;
34
if
(x >= 0x100) {
35
x ^= primitive;
36
}
37
}
38
for
(int32_t i = 0; i < 255; i++) {
39
m_logTable[m_expTable[i]] = i;
40
}
41
m_logTable[0] = 0;
42
}
43
44
void
CBC_ReedSolomonGF256
::
Init
() {
45
m_zero =
46
std::make_unique<CBC_ReedSolomonGF256Poly>(
this
, std::vector<int32_t>{0});
47
m_one =
48
std::make_unique<CBC_ReedSolomonGF256Poly>(
this
, std::vector<int32_t>{1});
49
}
50
51
CBC_ReedSolomonGF256
::~
CBC_ReedSolomonGF256
() =
default
;
52
53
std
::
unique_ptr
<
CBC_ReedSolomonGF256Poly
>
CBC_ReedSolomonGF256
::
BuildMonomial
(
54
int32_t degree,
55
int32_t coefficient) {
56
if
(degree < 0)
57
return
nullptr
;
58
59
if
(coefficient == 0)
60
return
m_zero->Clone();
61
62
std::vector<int32_t> coefficients(degree + 1);
63
coefficients[0] = coefficient;
64
return
std
::make_unique<CBC_ReedSolomonGF256Poly>(
this
, coefficients);
65
}
66
67
// static
68
int32_t
CBC_ReedSolomonGF256
::
AddOrSubtract
(int32_t a, int32_t b) {
69
return
a ^ b;
70
}
71
72
int32_t
CBC_ReedSolomonGF256
::
Exp
(int32_t a) {
73
return
m_expTable[a];
74
}
75
76
absl
::
optional
<
int32_t
>
CBC_ReedSolomonGF256
::
Inverse
(int32_t a) {
77
if
(a == 0)
78
return
absl::nullopt;
79
return
m_expTable[255 - m_logTable[a]];
80
}
81
82
int32_t
CBC_ReedSolomonGF256
::
Multiply
(int32_t a, int32_t b) {
83
if
(a == 0 || b == 0) {
84
return
0;
85
}
86
if
(a == 1) {
87
return
b;
88
}
89
if
(b == 1) {
90
return
a;
91
}
92
return
m_expTable[(m_logTable[a] + m_logTable[b]) % 255];
93
}
CBC_ReedSolomonGF256
Definition
BC_ReedSolomonGF256.h:16
CBC_ReedSolomonGF256::Multiply
int32_t Multiply(int32_t a, int32_t b)
Definition
BC_ReedSolomonGF256.cpp:82
CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256
~CBC_ReedSolomonGF256()
CBC_ReedSolomonGF256::Inverse
absl::optional< int32_t > Inverse(int32_t a)
Definition
BC_ReedSolomonGF256.cpp:76
CBC_ReedSolomonGF256::Exp
int32_t Exp(int32_t a)
Definition
BC_ReedSolomonGF256.cpp:72
CBC_ReedSolomonGF256::Init
void Init()
Definition
BC_ReedSolomonGF256.cpp:44
CBC_ReedSolomonGF256::BuildMonomial
std::unique_ptr< CBC_ReedSolomonGF256Poly > BuildMonomial(int32_t degree, int32_t coefficient)
Definition
BC_ReedSolomonGF256.cpp:53
CBC_ReedSolomonGF256::CBC_ReedSolomonGF256
CBC_ReedSolomonGF256(int32_t primitive)
Definition
BC_ReedSolomonGF256.cpp:29
CBC_ReedSolomonGF256::AddOrSubtract
static int32_t AddOrSubtract(int32_t a, int32_t b)
Definition
BC_ReedSolomonGF256.cpp:68
std
Definition
qfloat16.h:492
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
common
reedsolomon
BC_ReedSolomonGF256.cpp
Generated on Sat Sep 21 2024 00:58:12 for Qt by
1.12.0