summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-02-24 18:20:51 -0800
committerLei Zhang <thestig@chromium.org>2016-02-24 18:20:51 -0800
commit2e6864282e65c55ff6809f5aaae011b31c3a361a (patch)
tree98daecaf078529986a4efc2c43a3f43c0dcc01dd /xfa/src/fxbarcode/common
parent969ea09df096b987662b9658e3ffa023ca4ebf70 (diff)
downloadpdfium-2e6864282e65c55ff6809f5aaae011b31c3a361a.tar.xz
Get rid of CBC_AutoPtr and use std::unique_ptr instead.
Also fix IWYU in various fxbarcode headers. R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1734823002 .
Diffstat (limited to 'xfa/src/fxbarcode/common')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp11
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp14
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h1
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp45
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp10
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp108
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp31
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h3
8 files changed, 103 insertions, 120 deletions
diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
index c0e982cb63..897d9537fd 100644
--- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
@@ -20,8 +20,11 @@
* limitations under the License.
*/
-#include "core/include/fxcrt/fx_basic.h"
#include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h"
+
+#include <memory>
+
+#include "core/include/fxcrt/fx_basic.h"
#include "xfa/src/fxbarcode/utils.h"
CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11,
@@ -61,9 +64,9 @@ CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0,
FX_FLOAT y2p,
FX_FLOAT x3p,
FX_FLOAT y3p) {
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> qToS(
+ std::unique_ptr<CBC_CommonPerspectiveTransform> qToS(
QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3));
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> sToQ(
+ std::unique_ptr<CBC_CommonPerspectiveTransform> sToQ(
SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p));
return sToQ->Times(*(qToS.get()));
}
@@ -123,7 +126,7 @@ CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0,
FX_FLOAT y2,
FX_FLOAT x3,
FX_FLOAT y3) {
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> temp1(
+ std::unique_ptr<CBC_CommonPerspectiveTransform> temp1(
SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3));
return temp1->BuildAdjoint();
}
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
index 6c3920483c..8babc9c78f 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
@@ -20,11 +20,14 @@
* limitations under the License.
*/
+#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h"
+
+#include <memory>
+
#include "xfa/src/fxbarcode/BC_Binarizer.h"
#include "xfa/src/fxbarcode/BC_LuminanceSource.h"
#include "xfa/src/fxbarcode/common/BC_CommonBitArray.h"
#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h"
#include "xfa/src/fxbarcode/utils.h"
const int32_t LUMINANCE_BITS = 5;
@@ -41,7 +44,7 @@ CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow(
int32_t& e) {
CBC_LuminanceSource* source = GetLuminanceSource();
int32_t width = source->GetWidth();
- CBC_AutoPtr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width));
+ std::unique_ptr<CBC_CommonBitArray> result(new CBC_CommonBitArray(width));
InitArrays(width);
CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e);
if (e != BCExceptionNO) {
@@ -75,9 +78,8 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) {
CBC_LuminanceSource* source = GetLuminanceSource();
int32_t width = source->GetWidth();
int32_t height = source->GetHeight();
- CBC_CommonBitMatrix* BitMatrixTemp = new CBC_CommonBitMatrix();
- BitMatrixTemp->Init(width, height);
- CBC_AutoPtr<CBC_CommonBitMatrix> matrix(BitMatrixTemp);
+ std::unique_ptr<CBC_CommonBitMatrix> matrix(new CBC_CommonBitMatrix());
+ matrix->Init(width, height);
InitArrays(width);
CFX_Int32Array localBuckets;
localBuckets.Copy(m_buckets);
@@ -95,7 +97,7 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) {
}
int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CFX_ByteArray> localLuminances(source->GetMatrix());
+ std::unique_ptr<CFX_ByteArray> localLuminances(source->GetMatrix());
for (y = 0; y < height; y++) {
int32_t offset = y * width;
for (int32_t x = 0; x < width; x++) {
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
index a74187e767..c0ffaaa28d 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
@@ -8,6 +8,7 @@
#define XFA_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_
#include "core/include/fxcrt/fx_basic.h"
+#include "xfa/src/fxbarcode/BC_Binarizer.h"
class CBC_CommonBinarizer;
class CBC_CommonBitArray;
diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index ed5899da37..cc1b435f00 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -20,9 +20,12 @@
* limitations under the License.
*/
+#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h"
+
+#include <memory>
+
#include "xfa/src/fxbarcode/BC_ResultPoint.h"
#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h"
#include "xfa/src/fxbarcode/utils.h"
const int32_t CBC_WhiteRectangleDetector::INIT_SIZE = 30;
@@ -124,53 +127,45 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
}
if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
int32_t maxSize = right - left;
- CBC_AutoPtr<CBC_ResultPoint> z(NULL);
+ std::unique_ptr<CBC_ResultPoint> z;
for (int32_t i = 1; i < maxSize; i++) {
- z = CBC_AutoPtr<CBC_ResultPoint>(
- GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i),
- (FX_FLOAT)(left + i), (FX_FLOAT)(down)));
- if (z.get()) {
+ z.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i),
+ (FX_FLOAT)(left + i), (FX_FLOAT)(down)));
+ if (z)
break;
- }
}
if (z.get() == NULL) {
e = BCExceptionNotFound;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_AutoPtr<CBC_ResultPoint> t(NULL);
+ std::unique_ptr<CBC_ResultPoint> t;
for (int32_t j = 1; j < maxSize; j++) {
- t = CBC_AutoPtr<CBC_ResultPoint>(
- GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j),
- (FX_FLOAT)(left + j), (FX_FLOAT)up));
- if (t.get()) {
+ t.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j),
+ (FX_FLOAT)(left + j), (FX_FLOAT)up));
+ if (t)
break;
- }
}
if (t.get() == NULL) {
e = BCExceptionNotFound;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_AutoPtr<CBC_ResultPoint> x(NULL);
+ std::unique_ptr<CBC_ResultPoint> x;
for (int32_t k = 1; k < maxSize; k++) {
- x = CBC_AutoPtr<CBC_ResultPoint>(
- GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k),
- (FX_FLOAT)(right - k), (FX_FLOAT)up));
- if (x.get()) {
+ x.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k),
+ (FX_FLOAT)(right - k), (FX_FLOAT)up));
+ if (x)
break;
- }
}
if (x.get() == NULL) {
e = BCExceptionNotFound;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_AutoPtr<CBC_ResultPoint> y(NULL);
+ std::unique_ptr<CBC_ResultPoint> y;
for (int32_t m = 1; m < maxSize; m++) {
- y = CBC_AutoPtr<CBC_ResultPoint>(
- GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m),
- (FX_FLOAT)(right - m), (FX_FLOAT)down));
- if (y.get()) {
+ y.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m),
+ (FX_FLOAT)(right - m), (FX_FLOAT)down));
+ if (y)
break;
- }
}
if (y.get() == NULL) {
e = BCExceptionNotFound;
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 78c5bdc5e2..3e6de6ef06 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -21,6 +21,9 @@
*/
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h"
+
+#include <memory>
+
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
@@ -74,12 +77,11 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
CBC_ReedSolomonGF256Poly info;
info.Init(m_field, &infoCoefficients, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* rsg = info.MultiplyByMonomial(ecBytes, 1, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp(
+ info.MultiplyByMonomial(ecBytes, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> infoTemp(rsg);
- CFX_PtrArray* pa = infoTemp->Divide(generator, e);
+ std::unique_ptr<CFX_PtrArray> temp(infoTemp->Divide(generator, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_PtrArray> temp(pa);
CBC_ReedSolomonGF256Poly* remainder =
(CBC_ReedSolomonGF256Poly*)(temp->operator[](1));
CFX_Int32Array* coefficients = remainder->GetCoefficients();
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index 86c8a60c39..abdcaf0c88 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -21,6 +21,10 @@
*/
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h"
+
+#include <memory>
+#include <utility>
+
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
@@ -51,23 +55,22 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
CBC_ReedSolomonGF256Poly syndrome;
syndrome.Init(m_field, &syndromeCoefficients, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> temp(
+ m_field->BuildMonomial(twoS, 1, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg);
- CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e);
+ std::unique_ptr<CFX_PtrArray> sigmaOmega(
+ RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_PtrArray> sigmaOmega(pa);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(
(CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(
(CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
- CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e);
+ std::unique_ptr<CFX_Int32Array> errorLocations(
+ FindErrorLocations(sigma.get(), e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_Int32Array> errorLocations(ia1);
- CFX_Int32Array* ia2 =
- FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
+ std::unique_ptr<CFX_Int32Array> errorMagnitudes(
+ FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e));
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_Int32Array> errorMagnitudes(ia2);
for (int32_t k = 0; k < errorLocations->GetSize(); k++) {
int32_t position =
received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
@@ -90,42 +93,33 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
a = b;
b = temp;
}
- CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> rLast(a->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLast(rsg1);
- CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> r(b->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> r(rsg2);
- CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sLast(m_field->GetOne()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLast(rsg3);
- CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> s(m_field->GetZero()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> s(rsg4);
- CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> tLast(m_field->GetZero()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLast(rsg5);
- CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> t(m_field->GetOne()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> t(rsg6);
while (r->GetDegree() >= R / 2) {
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLastLast = rLast;
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLastLast = sLast;
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLastlast = tLast;
- rLast = r;
- sLast = s;
- tLast = t;
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> rLastLast = std::move(rLast);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sLastLast = std::move(sLast);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> tLastlast = std::move(tLast);
+ rLast = std::move(r);
+ sLast = std::move(s);
+ tLast = std::move(t);
if (rLast->IsZero()) {
e = BCExceptionR_I_1IsZero;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e);
+ r.reset(rLastLast->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rTemp(rsg7);
- r = rTemp;
- CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> q(m_field->GetZero()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8);
int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
@@ -133,37 +127,27 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
int32_t scale =
m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
- CBC_ReedSolomonGF256Poly* rsgp1 =
- m_field->BuildMonomial(degreeDiff, scale, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> build(
+ m_field->BuildMonomial(degreeDiff, scale, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> build(rsgp1);
- CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e);
+ q.reset(q->AddOrSubtract(build.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsgp2);
- q = temp;
- CBC_ReedSolomonGF256Poly* rsgp3 =
- rLast->MultiplyByMonomial(degreeDiff, scale, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> multiply(
+ rLast->MultiplyByMonomial(degreeDiff, scale, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> multiply(rsgp3);
- CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e);
+ r.reset(r->AddOrSubtract(multiply.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp3(rsgp4);
- r = temp3;
}
- CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> temp1(
+ q->Multiply(sLast.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg9);
- CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e);
+ s.reset(temp1->AddOrSubtract(sLastLast.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp2(rsg10);
- s = temp2;
- CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> temp5(
+ q->Multiply(tLast.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp5(rsg11);
- CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e);
+ t.reset(temp5->AddOrSubtract(tLastlast.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12);
- t = temp6;
}
int32_t sigmaTildeAtZero = t->GetCoefficients(0);
if (sigmaTildeAtZero == 0) {
@@ -172,12 +156,10 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
}
int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> sigma(t->Multiply(inverse, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(rsg13);
- CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> omega(r->Multiply(inverse, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(rsg14);
CFX_PtrArray* temp = new CFX_PtrArray;
temp->Add(sigma.release());
temp->Add(omega.release());
@@ -188,13 +170,13 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations(
int32_t& e) {
int32_t numErrors = errorLocator->GetDegree();
if (numErrors == 1) {
- CBC_AutoPtr<CFX_Int32Array> temp(new CFX_Int32Array);
+ std::unique_ptr<CFX_Int32Array> temp(new CFX_Int32Array);
temp->Add(errorLocator->GetCoefficients(1));
return temp.release();
}
CFX_Int32Array* tempT = new CFX_Int32Array;
tempT->SetSize(numErrors);
- CBC_AutoPtr<CFX_Int32Array> result(tempT);
+ std::unique_ptr<CFX_Int32Array> result(tempT);
int32_t ie = 0;
for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
if (errorLocator->EvaluateAt(i) == 0) {
@@ -217,7 +199,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
int32_t s = errorLocations->GetSize();
CFX_Int32Array* temp = new CFX_Int32Array;
temp->SetSize(s);
- CBC_AutoPtr<CFX_Int32Array> result(temp);
+ std::unique_ptr<CFX_Int32Array> result(temp);
for (int32_t i = 0; i < s; i++) {
int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index baafde023a..f138009ffa 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -20,9 +20,12 @@
* limitations under the License.
*/
-#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
+#include <memory>
+
+#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
+
CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
int32_t coefficients) {
if (field == NULL) {
@@ -216,12 +219,11 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
e = BCExceptionDivideByZero;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient(
+ m_field->GetZero()->Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1);
- CBC_ReedSolomonGF256Poly* rsg2 = Clone(e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2);
int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
int32_t inverseDenominatorLeadingTeam =
m_field->Inverse(denominatorLeadingTerm, e);
@@ -231,23 +233,16 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
int32_t scale =
m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())),
inverseDenominatorLeadingTeam);
- CBC_ReedSolomonGF256Poly* rsg3 =
- other->MultiplyByMonomial(degreeDifference, scale, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> term(
+ other->MultiplyByMonomial(degreeDifference, scale, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3);
- CBC_ReedSolomonGF256Poly* rsg4 =
- m_field->BuildMonomial(degreeDifference, scale, e);
+ std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient(
+ m_field->BuildMonomial(degreeDifference, scale, e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4);
- CBC_ReedSolomonGF256Poly* rsg5 =
- quotient->AddOrSubtract(iteratorQuotient.get(), e);
+ quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5);
- quotient = temp;
- CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e);
+ remainder.reset(remainder->AddOrSubtract(term.get(), e));
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6);
- remainder = temp1;
}
CFX_PtrArray* tempPtrA = new CFX_PtrArray;
tempPtrA->Add(quotient.release());
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index 8f2642dd87..71e4a09dd3 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -7,7 +7,10 @@
#ifndef XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_
#define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_
+#include "core/include/fxcrt/fx_basic.h"
+
class CBC_ReedSolomonGF256;
+
class CBC_ReedSolomonGF256Poly {
public:
CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);