Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp

Issue 1734823002: Get rid of CBC_AutoPtr and use std::unique_ptr instead. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" 23 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h"
24
25 #include <memory>
26 #include <utility>
27
24 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" 28 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
25 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" 29 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
26 30
27 CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) { 31 CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) {
28 m_field = field; 32 m_field = field;
29 } 33 }
30 CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder() {} 34 CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder() {}
31 void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, 35 void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
32 int32_t twoS, 36 int32_t twoS,
33 int32_t& e) { 37 int32_t& e) {
(...skipping 10 matching lines...) Expand all
44 if (eval != 0) { 48 if (eval != 0) {
45 noError = FALSE; 49 noError = FALSE;
46 } 50 }
47 } 51 }
48 if (noError) { 52 if (noError) {
49 return; 53 return;
50 } 54 }
51 CBC_ReedSolomonGF256Poly syndrome; 55 CBC_ReedSolomonGF256Poly syndrome;
52 syndrome.Init(m_field, &syndromeCoefficients, e); 56 syndrome.Init(m_field, &syndromeCoefficients, e);
53 BC_EXCEPTION_CHECK_ReturnVoid(e); 57 BC_EXCEPTION_CHECK_ReturnVoid(e);
54 CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e); 58 std::unique_ptr<CBC_ReedSolomonGF256Poly> temp(
59 m_field->BuildMonomial(twoS, 1, e));
55 BC_EXCEPTION_CHECK_ReturnVoid(e); 60 BC_EXCEPTION_CHECK_ReturnVoid(e);
56 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg); 61 std::unique_ptr<CFX_PtrArray> sigmaOmega(
57 CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e); 62 RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e));
58 BC_EXCEPTION_CHECK_ReturnVoid(e); 63 BC_EXCEPTION_CHECK_ReturnVoid(e);
59 CBC_AutoPtr<CFX_PtrArray> sigmaOmega(pa); 64 std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(
60 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(
61 (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]); 65 (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
62 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega( 66 std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(
63 (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]); 67 (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
64 CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e); 68 std::unique_ptr<CFX_Int32Array> errorLocations(
69 FindErrorLocations(sigma.get(), e));
65 BC_EXCEPTION_CHECK_ReturnVoid(e); 70 BC_EXCEPTION_CHECK_ReturnVoid(e);
66 CBC_AutoPtr<CFX_Int32Array> errorLocations(ia1); 71 std::unique_ptr<CFX_Int32Array> errorMagnitudes(
67 CFX_Int32Array* ia2 = 72 FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e));
68 FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
69 BC_EXCEPTION_CHECK_ReturnVoid(e); 73 BC_EXCEPTION_CHECK_ReturnVoid(e);
70 CBC_AutoPtr<CFX_Int32Array> errorMagnitudes(ia2);
71 for (int32_t k = 0; k < errorLocations->GetSize(); k++) { 74 for (int32_t k = 0; k < errorLocations->GetSize(); k++) {
72 int32_t position = 75 int32_t position =
73 received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e); 76 received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
74 BC_EXCEPTION_CHECK_ReturnVoid(e); 77 BC_EXCEPTION_CHECK_ReturnVoid(e);
75 if (position < 0) { 78 if (position < 0) {
76 e = BCExceptionBadErrorLocation; 79 e = BCExceptionBadErrorLocation;
77 BC_EXCEPTION_CHECK_ReturnVoid(e); 80 BC_EXCEPTION_CHECK_ReturnVoid(e);
78 } 81 }
79 (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract( 82 (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract(
80 (*received)[position], (*errorMagnitudes)[k]); 83 (*received)[position], (*errorMagnitudes)[k]);
81 } 84 }
82 } 85 }
83 CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( 86 CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
84 CBC_ReedSolomonGF256Poly* a, 87 CBC_ReedSolomonGF256Poly* a,
85 CBC_ReedSolomonGF256Poly* b, 88 CBC_ReedSolomonGF256Poly* b,
86 int32_t R, 89 int32_t R,
87 int32_t& e) { 90 int32_t& e) {
88 if (a->GetDegree() < b->GetDegree()) { 91 if (a->GetDegree() < b->GetDegree()) {
89 CBC_ReedSolomonGF256Poly* temp = a; 92 CBC_ReedSolomonGF256Poly* temp = a;
90 a = b; 93 a = b;
91 b = temp; 94 b = temp;
92 } 95 }
93 CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e); 96 std::unique_ptr<CBC_ReedSolomonGF256Poly> rLast(a->Clone(e));
94 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 97 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
95 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLast(rsg1); 98 std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e));
96 CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e);
97 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 99 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
98 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> r(rsg2); 100 std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e));
99 CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e);
100 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
101 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLast(rsg3); 102 std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e));
102 CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e);
103 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 103 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
104 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> s(rsg4); 104 std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e));
105 CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e);
106 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 105 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
107 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLast(rsg5); 106 std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e));
108 CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e);
109 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 107 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
110 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> t(rsg6);
111 while (r->GetDegree() >= R / 2) { 108 while (r->GetDegree() >= R / 2) {
112 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLastLast = rLast; 109 std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast);
113 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLastLast = sLast; 110 std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast);
114 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLastlast = tLast; 111 std::unique_ptr<CBC_ReedSolomonGF256Poly> tLastlast = std::move(tLast);
115 rLast = r; 112 rLast = std::move(r);
116 sLast = s; 113 sLast = std::move(s);
117 tLast = t; 114 tLast = std::move(t);
118 if (rLast->IsZero()) { 115 if (rLast->IsZero()) {
119 e = BCExceptionR_I_1IsZero; 116 e = BCExceptionR_I_1IsZero;
120 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 117 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
121 } 118 }
122 CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e); 119 r.reset(rLastLast->Clone(e));
123 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 120 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
124 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rTemp(rsg7); 121 std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e));
125 r = rTemp;
126 CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e);
127 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 122 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
128 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8);
129 int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree()); 123 int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
130 int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e); 124 int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
131 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 125 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
132 while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) { 126 while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) {
133 int32_t degreeDiff = r->GetDegree() - rLast->GetDegree(); 127 int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
134 int32_t scale = 128 int32_t scale =
135 m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse); 129 m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
136 CBC_ReedSolomonGF256Poly* rsgp1 = 130 std::unique_ptr<CBC_ReedSolomonGF256Poly> build(
137 m_field->BuildMonomial(degreeDiff, scale, e); 131 m_field->BuildMonomial(degreeDiff, scale, e));
138 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 132 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
139 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> build(rsgp1); 133 q.reset(q->AddOrSubtract(build.get(), e));
140 CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e);
141 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 134 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
142 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsgp2); 135 std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply(
143 q = temp; 136 rLast->MultiplyByMonomial(degreeDiff, scale, e));
144 CBC_ReedSolomonGF256Poly* rsgp3 =
145 rLast->MultiplyByMonomial(degreeDiff, scale, e);
146 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 137 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
147 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> multiply(rsgp3); 138 r.reset(r->AddOrSubtract(multiply.get(), e));
148 CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e);
149 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 139 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
150 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp3(rsgp4);
151 r = temp3;
152 } 140 }
153 CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e); 141 std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1(
142 q->Multiply(sLast.get(), e));
154 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 143 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
155 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg9); 144 s.reset(temp1->AddOrSubtract(sLastLast.get(), e));
156 CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e);
157 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 145 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
158 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp2(rsg10); 146 std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5(
159 s = temp2; 147 q->Multiply(tLast.get(), e));
160 CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e);
161 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 148 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
162 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp5(rsg11); 149 t.reset(temp5->AddOrSubtract(tLastlast.get(), e));
163 CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e);
164 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 150 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
165 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12);
166 t = temp6;
167 } 151 }
168 int32_t sigmaTildeAtZero = t->GetCoefficients(0); 152 int32_t sigmaTildeAtZero = t->GetCoefficients(0);
169 if (sigmaTildeAtZero == 0) { 153 if (sigmaTildeAtZero == 0) {
170 e = BCExceptionIsZero; 154 e = BCExceptionIsZero;
171 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 155 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
172 } 156 }
173 int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e); 157 int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
174 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 158 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
175 CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e); 159 std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e));
176 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 160 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
177 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(rsg13); 161 std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e));
178 CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e);
179 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 162 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
180 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(rsg14);
181 CFX_PtrArray* temp = new CFX_PtrArray; 163 CFX_PtrArray* temp = new CFX_PtrArray;
182 temp->Add(sigma.release()); 164 temp->Add(sigma.release());
183 temp->Add(omega.release()); 165 temp->Add(omega.release());
184 return temp; 166 return temp;
185 } 167 }
186 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations( 168 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations(
187 CBC_ReedSolomonGF256Poly* errorLocator, 169 CBC_ReedSolomonGF256Poly* errorLocator,
188 int32_t& e) { 170 int32_t& e) {
189 int32_t numErrors = errorLocator->GetDegree(); 171 int32_t numErrors = errorLocator->GetDegree();
190 if (numErrors == 1) { 172 if (numErrors == 1) {
191 CBC_AutoPtr<CFX_Int32Array> temp(new CFX_Int32Array); 173 std::unique_ptr<CFX_Int32Array> temp(new CFX_Int32Array);
192 temp->Add(errorLocator->GetCoefficients(1)); 174 temp->Add(errorLocator->GetCoefficients(1));
193 return temp.release(); 175 return temp.release();
194 } 176 }
195 CFX_Int32Array* tempT = new CFX_Int32Array; 177 CFX_Int32Array* tempT = new CFX_Int32Array;
196 tempT->SetSize(numErrors); 178 tempT->SetSize(numErrors);
197 CBC_AutoPtr<CFX_Int32Array> result(tempT); 179 std::unique_ptr<CFX_Int32Array> result(tempT);
198 int32_t ie = 0; 180 int32_t ie = 0;
199 for (int32_t i = 1; i < 256 && ie < numErrors; i++) { 181 for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
200 if (errorLocator->EvaluateAt(i) == 0) { 182 if (errorLocator->EvaluateAt(i) == 0) {
201 (*result)[ie] = m_field->Inverse(i, ie); 183 (*result)[ie] = m_field->Inverse(i, ie);
202 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 184 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
203 ie++; 185 ie++;
204 } 186 }
205 } 187 }
206 if (ie != numErrors) { 188 if (ie != numErrors) {
207 e = BCExceptionDegreeNotMatchRoots; 189 e = BCExceptionDegreeNotMatchRoots;
208 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 190 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
209 } 191 }
210 return result.release(); 192 return result.release();
211 } 193 }
212 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( 194 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
213 CBC_ReedSolomonGF256Poly* errorEvaluator, 195 CBC_ReedSolomonGF256Poly* errorEvaluator,
214 CFX_Int32Array* errorLocations, 196 CFX_Int32Array* errorLocations,
215 FX_BOOL dataMatrix, 197 FX_BOOL dataMatrix,
216 int32_t& e) { 198 int32_t& e) {
217 int32_t s = errorLocations->GetSize(); 199 int32_t s = errorLocations->GetSize();
218 CFX_Int32Array* temp = new CFX_Int32Array; 200 CFX_Int32Array* temp = new CFX_Int32Array;
219 temp->SetSize(s); 201 temp->SetSize(s);
220 CBC_AutoPtr<CFX_Int32Array> result(temp); 202 std::unique_ptr<CFX_Int32Array> result(temp);
221 for (int32_t i = 0; i < s; i++) { 203 for (int32_t i = 0; i < s; i++) {
222 int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); 204 int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
223 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 205 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
224 int32_t denominator = 1; 206 int32_t denominator = 1;
225 for (int32_t j = 0; j < s; j++) { 207 for (int32_t j = 0; j < s; j++) {
226 if (i != j) { 208 if (i != j) {
227 denominator = m_field->Multiply( 209 denominator = m_field->Multiply(
228 denominator, CBC_ReedSolomonGF256::AddOrSubtract( 210 denominator, CBC_ReedSolomonGF256::AddOrSubtract(
229 1, m_field->Multiply(errorLocations->operator[](j), 211 1, m_field->Multiply(errorLocations->operator[](j),
230 xiInverse))); 212 xiInverse)));
231 } 213 }
232 } 214 }
233 int32_t temp = m_field->Inverse(denominator, temp); 215 int32_t temp = m_field->Inverse(denominator, temp);
234 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 216 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
235 (*result)[i] = 217 (*result)[i] =
236 m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp); 218 m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp);
237 } 219 }
238 return result.release(); 220 return result.release();
239 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698