OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2007 ZXing authors | 8 * Copyright 2007 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
11 * you may not use this file except in compliance with 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 | 12 * You may obtain a copy of the License at |
13 * | 13 * |
14 * http://www.apache.org/licenses/LICENSE-2.0 | 14 * http://www.apache.org/licenses/LICENSE-2.0 |
15 * | 15 * |
16 * Unless required by applicable law or agreed to in writing, software | 16 * Unless required by applicable law or agreed to in writing, software |
17 * distributed under the License is distributed on an "AS IS" BASIS, | 17 * distributed under the License is distributed on an "AS IS" BASIS, |
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 * See the License for the specific language governing permissions and | 19 * See the License for the specific language governing permissions and |
20 * limitations under the License. | 20 * limitations under the License. |
21 */ | 21 */ |
22 | 22 |
23 #include "../../barcode.h" | 23 #include "../../barcode.h" |
24 #include "BC_ReedSolomonGF256.h" | 24 #include "BC_ReedSolomonGF256.h" |
25 #include "BC_ReedSolomonGF256Poly.h" | 25 #include "BC_ReedSolomonGF256Poly.h" |
26 CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
FX_INT32 coefficients) | 26 CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
int32_t coefficients) |
27 { | 27 { |
28 if(field == NULL) { | 28 if(field == NULL) { |
29 return; | 29 return; |
30 } | 30 } |
31 m_field = field; | 31 m_field = field; |
32 m_coefficients.Add(coefficients); | 32 m_coefficients.Add(coefficients); |
33 } | 33 } |
34 CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() | 34 CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() |
35 { | 35 { |
36 m_field = NULL; | 36 m_field = NULL; |
37 } | 37 } |
38 void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, CFX_Int32Array*
coefficients, FX_INT32 &e) | 38 void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, CFX_Int32Array*
coefficients, int32_t &e) |
39 { | 39 { |
40 if(coefficients == NULL || coefficients->GetSize() == 0) { | 40 if(coefficients == NULL || coefficients->GetSize() == 0) { |
41 e = BCExceptionCoefficientsSizeIsNull; | 41 e = BCExceptionCoefficientsSizeIsNull; |
42 BC_EXCEPTION_CHECK_ReturnVoid(e); | 42 BC_EXCEPTION_CHECK_ReturnVoid(e); |
43 } | 43 } |
44 m_field = field; | 44 m_field = field; |
45 FX_INT32 coefficientsLength = coefficients->GetSize(); | 45 int32_t coefficientsLength = coefficients->GetSize(); |
46 if((coefficientsLength > 1 && (*coefficients)[0] == 0)) { | 46 if((coefficientsLength > 1 && (*coefficients)[0] == 0)) { |
47 FX_INT32 firstNonZero = 1; | 47 int32_t firstNonZero = 1; |
48 while((firstNonZero < coefficientsLength) && ((*coefficients)[firstNonZe
ro] == 0)) { | 48 while((firstNonZero < coefficientsLength) && ((*coefficients)[firstNonZe
ro] == 0)) { |
49 firstNonZero++; | 49 firstNonZero++; |
50 } | 50 } |
51 if(firstNonZero == coefficientsLength) { | 51 if(firstNonZero == coefficientsLength) { |
52 m_coefficients.Copy( *(m_field->GetZero()->GetCoefficients())); | 52 m_coefficients.Copy( *(m_field->GetZero()->GetCoefficients())); |
53 } else { | 53 } else { |
54 m_coefficients.SetSize(coefficientsLength - firstNonZero); | 54 m_coefficients.SetSize(coefficientsLength - firstNonZero); |
55 for(FX_INT32 i = firstNonZero, j = 0; i < coefficientsLength; i++, j
++) { | 55 for(int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j+
+) { |
56 m_coefficients[j] = coefficients->operator [](i); | 56 m_coefficients[j] = coefficients->operator [](i); |
57 } | 57 } |
58 } | 58 } |
59 } else { | 59 } else { |
60 m_coefficients.Copy(*coefficients); | 60 m_coefficients.Copy(*coefficients); |
61 } | 61 } |
62 } | 62 } |
63 CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() | 63 CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() |
64 { | 64 { |
65 return &m_coefficients; | 65 return &m_coefficients; |
66 } | 66 } |
67 FX_INT32 CBC_ReedSolomonGF256Poly::GetDegree() | 67 int32_t CBC_ReedSolomonGF256Poly::GetDegree() |
68 { | 68 { |
69 return m_coefficients.GetSize() - 1; | 69 return m_coefficients.GetSize() - 1; |
70 } | 70 } |
71 FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() | 71 FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() |
72 { | 72 { |
73 return m_coefficients[0] == 0; | 73 return m_coefficients[0] == 0; |
74 } | 74 } |
75 FX_INT32 CBC_ReedSolomonGF256Poly::GetCoefficients(FX_INT32 degree) | 75 int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) |
76 { | 76 { |
77 return m_coefficients[m_coefficients.GetSize() - 1 - degree]; | 77 return m_coefficients[m_coefficients.GetSize() - 1 - degree]; |
78 } | 78 } |
79 FX_INT32 CBC_ReedSolomonGF256Poly::EvaluateAt(FX_INT32 a) | 79 int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) |
80 { | 80 { |
81 if(a == 0) { | 81 if(a == 0) { |
82 return GetCoefficients(0); | 82 return GetCoefficients(0); |
83 } | 83 } |
84 FX_INT32 size = m_coefficients.GetSize(); | 84 int32_t size = m_coefficients.GetSize(); |
85 if(a == 1) { | 85 if(a == 1) { |
86 FX_INT32 result = 0; | 86 int32_t result = 0; |
87 for(FX_INT32 i = 0; i < size; i++) { | 87 for(int32_t i = 0; i < size; i++) { |
88 result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[
i]); | 88 result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[
i]); |
89 } | 89 } |
90 return result; | 90 return result; |
91 } | 91 } |
92 FX_INT32 result = m_coefficients[0]; | 92 int32_t result = m_coefficients[0]; |
93 for(FX_INT32 j = 1; j < size; j++) { | 93 for(int32_t j = 1; j < size; j++) { |
94 result = CBC_ReedSolomonGF256::AddOrSubtract( | 94 result = CBC_ReedSolomonGF256::AddOrSubtract( |
95 m_field->Multiply(a, result), | 95 m_field->Multiply(a, result), |
96 m_coefficients[j]); | 96 m_coefficients[j]); |
97 } | 97 } |
98 return result; | 98 return result; |
99 } | 99 } |
100 CBC_ReedSolomonGF256Poly *CBC_ReedSolomonGF256Poly::Clone(FX_INT32 &e) | 100 CBC_ReedSolomonGF256Poly *CBC_ReedSolomonGF256Poly::Clone(int32_t &e) |
101 { | 101 { |
102 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 102 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
103 temp->Init(m_field, &m_coefficients, e); | 103 temp->Init(m_field, &m_coefficients, e); |
104 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 104 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
105 return temp; | 105 return temp; |
106 } | 106 } |
107 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomo
nGF256Poly* other, FX_INT32 &e) | 107 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomo
nGF256Poly* other, int32_t &e) |
108 { | 108 { |
109 if(IsZero()) { | 109 if(IsZero()) { |
110 return other->Clone(e); | 110 return other->Clone(e); |
111 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 111 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
112 } | 112 } |
113 if(other->IsZero()) { | 113 if(other->IsZero()) { |
114 return this->Clone(e); | 114 return this->Clone(e); |
115 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 115 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
116 } | 116 } |
117 CFX_Int32Array smallerCoefficients; | 117 CFX_Int32Array smallerCoefficients; |
118 smallerCoefficients.Copy(m_coefficients); | 118 smallerCoefficients.Copy(m_coefficients); |
119 CFX_Int32Array largerCoefficients; | 119 CFX_Int32Array largerCoefficients; |
120 largerCoefficients.Copy( *(other->GetCoefficients())); | 120 largerCoefficients.Copy( *(other->GetCoefficients())); |
121 if(smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { | 121 if(smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { |
122 CFX_Int32Array temp; | 122 CFX_Int32Array temp; |
123 temp.Copy(smallerCoefficients); | 123 temp.Copy(smallerCoefficients); |
124 smallerCoefficients.Copy(largerCoefficients); | 124 smallerCoefficients.Copy(largerCoefficients); |
125 largerCoefficients.Copy(temp); | 125 largerCoefficients.Copy(temp); |
126 } | 126 } |
127 CFX_Int32Array sumDiff; | 127 CFX_Int32Array sumDiff; |
128 sumDiff.SetSize(largerCoefficients.GetSize() ); | 128 sumDiff.SetSize(largerCoefficients.GetSize() ); |
129 FX_INT32 lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.Get
Size(); | 129 int32_t lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.GetS
ize(); |
130 for(FX_INT32 i = 0; i < lengthDiff; i++) { | 130 for(int32_t i = 0; i < lengthDiff; i++) { |
131 sumDiff[i] = largerCoefficients[i]; | 131 sumDiff[i] = largerCoefficients[i]; |
132 } | 132 } |
133 for(FX_INT32 j = lengthDiff; j < largerCoefficients.GetSize(); j++) { | 133 for(int32_t j = lengthDiff; j < largerCoefficients.GetSize(); j++) { |
134 sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract(smallerCoefficients[j
- lengthDiff], | 134 sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract(smallerCoefficients[j
- lengthDiff], |
135 largerCoefficients[j])); | 135 largerCoefficients[j])); |
136 } | 136 } |
137 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 137 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
138 temp->Init(m_field, &sumDiff, e); | 138 temp->Init(m_field, &sumDiff, e); |
139 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 139 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
140 return temp; | 140 return temp; |
141 } | 141 } |
142 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF25
6Poly* other, FX_INT32 &e) | 142 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF25
6Poly* other, int32_t &e) |
143 { | 143 { |
144 if(IsZero() || other->IsZero()) { | 144 if(IsZero() || other->IsZero()) { |
145 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); | 145 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); |
146 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 146 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
147 return temp; | 147 return temp; |
148 } | 148 } |
149 CFX_Int32Array aCoefficients ; | 149 CFX_Int32Array aCoefficients ; |
150 aCoefficients.Copy(m_coefficients); | 150 aCoefficients.Copy(m_coefficients); |
151 FX_INT32 aLength = m_coefficients.GetSize(); | 151 int32_t aLength = m_coefficients.GetSize(); |
152 CFX_Int32Array bCoefficients; | 152 CFX_Int32Array bCoefficients; |
153 bCoefficients.Copy(*(other->GetCoefficients())); | 153 bCoefficients.Copy(*(other->GetCoefficients())); |
154 FX_INT32 bLength = other->GetCoefficients()->GetSize(); | 154 int32_t bLength = other->GetCoefficients()->GetSize(); |
155 CFX_Int32Array product; | 155 CFX_Int32Array product; |
156 product.SetSize(aLength + bLength - 1); | 156 product.SetSize(aLength + bLength - 1); |
157 for(FX_INT32 i = 0; i < aLength; i++) { | 157 for(int32_t i = 0; i < aLength; i++) { |
158 FX_INT32 aCoeff = m_coefficients[i]; | 158 int32_t aCoeff = m_coefficients[i]; |
159 for(FX_INT32 j = 0; j < bLength; j++) { | 159 for(int32_t j = 0; j < bLength; j++) { |
160 product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract( | 160 product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract( |
161 product[i + j], | 161 product[i + j], |
162 m_field->Multiply(aCoeff, other->GetCoefficient
s()->operator [](j))); | 162 m_field->Multiply(aCoeff, other->GetCoefficient
s()->operator [](j))); |
163 } | 163 } |
164 } | 164 } |
165 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 165 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
166 temp->Init(m_field, &product, e); | 166 temp->Init(m_field, &product, e); |
167 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 167 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
168 return temp; | 168 return temp; |
169 } | 169 } |
170 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(FX_INT32 scalar, FX
_INT32 &e) | 170 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, int
32_t &e) |
171 { | 171 { |
172 if(scalar == 0) { | 172 if(scalar == 0) { |
173 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); | 173 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); |
174 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 174 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
175 return temp; | 175 return temp; |
176 } | 176 } |
177 if(scalar == 1) { | 177 if(scalar == 1) { |
178 return this->Clone(e); | 178 return this->Clone(e); |
179 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 179 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
180 } | 180 } |
181 FX_INT32 size = m_coefficients.GetSize(); | 181 int32_t size = m_coefficients.GetSize(); |
182 CFX_Int32Array product; | 182 CFX_Int32Array product; |
183 product.SetSize(size); | 183 product.SetSize(size); |
184 for(FX_INT32 i = 0; i < size; i++) { | 184 for(int32_t i = 0; i < size; i++) { |
185 product[i] = m_field->Multiply(m_coefficients[i], scalar); | 185 product[i] = m_field->Multiply(m_coefficients[i], scalar); |
186 } | 186 } |
187 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 187 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
188 temp->Init(m_field, &product, e); | 188 temp->Init(m_field, &product, e); |
189 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 189 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
190 return temp; | 190 return temp; |
191 } | 191 } |
192 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(FX_INT32
degree, FX_INT32 coefficient, FX_INT32 &e) | 192 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(int32_t d
egree, int32_t coefficient, int32_t &e) |
193 { | 193 { |
194 if(degree < 0) { | 194 if(degree < 0) { |
195 e = BCExceptionDegreeIsNegative; | 195 e = BCExceptionDegreeIsNegative; |
196 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 196 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
197 } | 197 } |
198 if(coefficient == 0) { | 198 if(coefficient == 0) { |
199 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); | 199 CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e); |
200 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 200 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
201 return temp; | 201 return temp; |
202 } | 202 } |
203 FX_INT32 size = m_coefficients.GetSize(); | 203 int32_t size = m_coefficients.GetSize(); |
204 CFX_Int32Array product; | 204 CFX_Int32Array product; |
205 product.SetSize(size + degree); | 205 product.SetSize(size + degree); |
206 for(FX_INT32 i = 0; i < size; i++) { | 206 for(int32_t i = 0; i < size; i++) { |
207 product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); | 207 product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); |
208 } | 208 } |
209 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); | 209 CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly(); |
210 temp->Init(m_field, &product, e); | 210 temp->Init(m_field, &product, e); |
211 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 211 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
212 return temp; | 212 return temp; |
213 } | 213 } |
214 CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other,
FX_INT32 &e) | 214 CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other,
int32_t &e) |
215 { | 215 { |
216 if(other->IsZero()) { | 216 if(other->IsZero()) { |
217 e = BCExceptionDivideByZero; | 217 e = BCExceptionDivideByZero; |
218 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 218 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
219 } | 219 } |
220 CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e); | 220 CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e); |
221 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 221 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
222 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1); | 222 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1); |
223 CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e); | 223 CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e); |
224 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 224 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
225 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2); | 225 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2); |
226 FX_INT32 denominatorLeadingTerm = other->GetCoefficients(other->GetDegree())
; | 226 int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); |
227 FX_INT32 inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeading
Term, e); | 227 int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingT
erm, e); |
228 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 228 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
229 FX_BOOL bFirst = TRUE; | 229 FX_BOOL bFirst = TRUE; |
230 while(remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero())
{ | 230 while(remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero())
{ |
231 FX_INT32 degreeDifference = remainder->GetDegree() - other->GetDegree(); | 231 int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); |
232 FX_INT32 scale = m_field->Multiply(remainder->GetCoefficients((remainder
->GetDegree())), | 232 int32_t scale = m_field->Multiply(remainder->GetCoefficients((remainder-
>GetDegree())), |
233 inverseDenominatorLeadingTeam); | 233 inverseDenominatorLeadingTeam); |
234 CBC_ReedSolomonGF256Poly* rsg3 = other->MultiplyByMonomial(degreeDiffere
nce, scale, e); | 234 CBC_ReedSolomonGF256Poly* rsg3 = other->MultiplyByMonomial(degreeDiffere
nce, scale, e); |
235 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 235 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
236 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3); | 236 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3); |
237 CBC_ReedSolomonGF256Poly* rsg4 = m_field->BuildMonomial(degreeDifference
, scale, e); | 237 CBC_ReedSolomonGF256Poly* rsg4 = m_field->BuildMonomial(degreeDifference
, scale, e); |
238 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 238 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
239 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4); | 239 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4); |
240 CBC_ReedSolomonGF256Poly* rsg5 = quotient->AddOrSubtract(iteratorQuotien
t.get(), e); | 240 CBC_ReedSolomonGF256Poly* rsg5 = quotient->AddOrSubtract(iteratorQuotien
t.get(), e); |
241 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 241 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
242 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5); | 242 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5); |
243 quotient = temp; | 243 quotient = temp; |
244 CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e)
; | 244 CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e)
; |
245 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 245 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
246 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6); | 246 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6); |
247 remainder = temp1; | 247 remainder = temp1; |
248 } | 248 } |
249 CFX_PtrArray* tempPtrA = FX_NEW CFX_PtrArray; | 249 CFX_PtrArray* tempPtrA = FX_NEW CFX_PtrArray; |
250 tempPtrA->Add(quotient.release()); | 250 tempPtrA->Add(quotient.release()); |
251 tempPtrA->Add(remainder.release()); | 251 tempPtrA->Add(remainder.release()); |
252 return tempPtrA; | 252 return tempPtrA; |
253 } | 253 } |
254 CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() | 254 CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() |
255 { | 255 { |
256 m_coefficients.RemoveAll(); | 256 m_coefficients.RemoveAll(); |
257 } | 257 } |
OLD | NEW |