| Index: xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp
|
| diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp
|
| index 8d1a86ec925287744edd74d19545f5e0f09498c5..726e0ec94f2d8686e40b454e6f4a020c69638cf2 100644
|
| --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp
|
| +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp
|
| @@ -28,26 +28,26 @@
|
| #include "BC_PDF417DetectorResult.h"
|
| #include "BC_PDF417Detector.h"
|
| #define INTERGER_MAX 2147483647
|
| -FX_INT32 CBC_Detector::INDEXES_START_PATTERN[] = {0, 4, 1, 5};
|
| -FX_INT32 CBC_Detector::INDEXES_STOP_PATTERN[] = {6, 2, 7, 3};
|
| -FX_INT32 CBC_Detector::INTEGER_MATH_SHIFT = 8;
|
| -FX_INT32 CBC_Detector::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
|
| -FX_INT32 CBC_Detector::MAX_AVG_VARIANCE = (FX_INT32) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
|
| -FX_INT32 CBC_Detector::MAX_INDIVIDUAL_VARIANCE = (FX_INT32) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f);
|
| -FX_INT32 CBC_Detector::START_PATTERN[] = {8, 1, 1, 1, 1, 1, 1, 3};
|
| -FX_INT32 CBC_Detector::STOP_PATTERN[] = {7, 1, 1, 3, 1, 1, 1, 2, 1};
|
| -FX_INT32 CBC_Detector::MAX_PIXEL_DRIFT = 3;
|
| -FX_INT32 CBC_Detector::MAX_PATTERN_DRIFT = 5;
|
| -FX_INT32 CBC_Detector::SKIPPED_ROW_COUNT_MAX = 25;
|
| -FX_INT32 CBC_Detector::ROW_STEP = 5;
|
| -FX_INT32 CBC_Detector::BARCODE_MIN_HEIGHT = 10;
|
| +int32_t CBC_Detector::INDEXES_START_PATTERN[] = {0, 4, 1, 5};
|
| +int32_t CBC_Detector::INDEXES_STOP_PATTERN[] = {6, 2, 7, 3};
|
| +int32_t CBC_Detector::INTEGER_MATH_SHIFT = 8;
|
| +int32_t CBC_Detector::PATTERN_MATCH_RESULT_SCALE_FACTOR = 1 << INTEGER_MATH_SHIFT;
|
| +int32_t CBC_Detector::MAX_AVG_VARIANCE = (int32_t) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f);
|
| +int32_t CBC_Detector::MAX_INDIVIDUAL_VARIANCE = (int32_t) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f);
|
| +int32_t CBC_Detector::START_PATTERN[] = {8, 1, 1, 1, 1, 1, 1, 3};
|
| +int32_t CBC_Detector::STOP_PATTERN[] = {7, 1, 1, 3, 1, 1, 1, 2, 1};
|
| +int32_t CBC_Detector::MAX_PIXEL_DRIFT = 3;
|
| +int32_t CBC_Detector::MAX_PATTERN_DRIFT = 5;
|
| +int32_t CBC_Detector::SKIPPED_ROW_COUNT_MAX = 25;
|
| +int32_t CBC_Detector::ROW_STEP = 5;
|
| +int32_t CBC_Detector::BARCODE_MIN_HEIGHT = 10;
|
| CBC_Detector::CBC_Detector()
|
| {
|
| }
|
| CBC_Detector::~CBC_Detector()
|
| {
|
| }
|
| -CBC_PDF417DetectorResult* CBC_Detector::detect(CBC_BinaryBitmap* image, FX_INT32 hints, FX_BOOL multiple, FX_INT32 &e)
|
| +CBC_PDF417DetectorResult* CBC_Detector::detect(CBC_BinaryBitmap* image, int32_t hints, FX_BOOL multiple, int32_t &e)
|
| {
|
| CBC_CommonBitMatrix* bitMatrix = image->GetBlackMatrix(e);
|
| BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
|
| @@ -65,12 +65,12 @@ CBC_PDF417DetectorResult* CBC_Detector::detect(CBC_BinaryBitmap* image, FX_INT32
|
| }
|
| void CBC_Detector::rotate180(CBC_CommonBitMatrix* bitMatrix)
|
| {
|
| - FX_INT32 width = bitMatrix->GetWidth();
|
| - FX_INT32 height = bitMatrix->GetHeight();
|
| + int32_t width = bitMatrix->GetWidth();
|
| + int32_t height = bitMatrix->GetHeight();
|
| CBC_CommonBitArray* firstRowBitArray = FX_NEW CBC_CommonBitArray(width);
|
| CBC_CommonBitArray* secondRowBitArray = FX_NEW CBC_CommonBitArray(width);
|
| CBC_CommonBitArray* tmpBitArray = FX_NEW CBC_CommonBitArray(width);
|
| - for (FX_INT32 y = 0; y < (height + 1) >> 1; y++) {
|
| + for (int32_t y = 0; y < (height + 1) >> 1; y++) {
|
| CBC_CommonBitArray* temp = bitMatrix->GetRow(height - 1 - y, secondRowBitArray);
|
| CBC_CommonBitArray* tempfirstRow = firstRowBitArray;
|
| firstRowBitArray = bitMatrix->GetRow(y, tempfirstRow);
|
| @@ -91,8 +91,8 @@ CBC_CommonBitArray* CBC_Detector::mirror(CBC_CommonBitArray* input, CBC_CommonBi
|
| {
|
| CBC_CommonBitArray* array = FX_NEW CBC_CommonBitArray(result->GetSize());
|
| array->Clear();
|
| - FX_INT32 size = input->GetSize();
|
| - for (FX_INT32 i = 0; i < size; i++) {
|
| + int32_t size = input->GetSize();
|
| + for (int32_t i = 0; i < size; i++) {
|
| if (input->Get(i)) {
|
| array->Set(size - 1 - i);
|
| }
|
| @@ -102,8 +102,8 @@ CBC_CommonBitArray* CBC_Detector::mirror(CBC_CommonBitArray* input, CBC_CommonBi
|
| CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMatrix)
|
| {
|
| CFX_PtrArray* barcodeCoordinates = FX_NEW CFX_PtrArray;
|
| - FX_INT32 row = 0;
|
| - FX_INT32 column = 0;
|
| + int32_t row = 0;
|
| + int32_t column = 0;
|
| FX_BOOL foundBarcodeInRow = FALSE;
|
| while (row < bitMatrix->GetHeight()) {
|
| CFX_PtrArray* vertices = findVertices(bitMatrix, row, column);
|
| @@ -116,7 +116,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMat
|
| }
|
| foundBarcodeInRow = FALSE;
|
| column = 0;
|
| - for (FX_INT32 i = 0; i < barcodeCoordinates->GetSize(); i++) {
|
| + for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) {
|
| CFX_PtrArray* barcodeCoordinate = (CFX_PtrArray*)barcodeCoordinates->GetAt(i);
|
| if (barcodeCoordinate->GetAt(1) != NULL) {
|
| row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY();
|
| @@ -137,19 +137,19 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, CBC_CommonBitMatrix* bitMat
|
| break;
|
| }
|
| if (vertices->GetAt(2) != NULL) {
|
| - column = (FX_INT32) ((CBC_ResultPoint*)vertices->GetAt(2))->GetX();
|
| - row = (FX_INT32) ((CBC_ResultPoint*)vertices->GetAt(2))->GetY();
|
| + column = (int32_t) ((CBC_ResultPoint*)vertices->GetAt(2))->GetX();
|
| + row = (int32_t) ((CBC_ResultPoint*)vertices->GetAt(2))->GetY();
|
| } else {
|
| - column = (FX_INT32) ((CBC_ResultPoint*)vertices->GetAt(4))->GetX();
|
| - row = (FX_INT32) ((CBC_ResultPoint*)vertices->GetAt(4))->GetY();
|
| + column = (int32_t) ((CBC_ResultPoint*)vertices->GetAt(4))->GetX();
|
| + row = (int32_t) ((CBC_ResultPoint*)vertices->GetAt(4))->GetY();
|
| }
|
| }
|
| return barcodeCoordinates;
|
| }
|
| -CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, FX_INT32 startRow, FX_INT32 startColumn)
|
| +CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, int32_t startRow, int32_t startColumn)
|
| {
|
| - FX_INT32 height = matrix->GetHeight();
|
| - FX_INT32 width = matrix->GetWidth();
|
| + int32_t height = matrix->GetHeight();
|
| + int32_t width = matrix->GetWidth();
|
| CFX_PtrArray* result = FX_NEW CFX_PtrArray;
|
| result->SetSize(8);
|
| CFX_PtrArray* startptr = findRowsWithPattern(matrix, height, width, startRow, startColumn, START_PATTERN, sizeof(START_PATTERN) / sizeof(START_PATTERN[0]));
|
| @@ -157,8 +157,8 @@ CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, FX_INT32 s
|
| startptr->RemoveAll();
|
| delete startptr;
|
| if (result->GetAt(4) != NULL) {
|
| - startColumn = (FX_INT32) ((CBC_ResultPoint*)result->GetAt(4))->GetX();
|
| - startRow = (FX_INT32) ((CBC_ResultPoint*)result->GetAt(4))->GetY();
|
| + startColumn = (int32_t) ((CBC_ResultPoint*)result->GetAt(4))->GetX();
|
| + startRow = (int32_t) ((CBC_ResultPoint*)result->GetAt(4))->GetY();
|
| }
|
| CFX_PtrArray* stopptr = findRowsWithPattern(matrix, height, width, startRow, startColumn, STOP_PATTERN, sizeof(STOP_PATTERN) / sizeof(STOP_PATTERN[0]));
|
| copyToResult(result, stopptr, INDEXES_STOP_PATTERN, sizeof(INDEXES_STOP_PATTERN) / sizeof(INDEXES_STOP_PATTERN[0]));
|
| @@ -166,13 +166,13 @@ CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, FX_INT32 s
|
| delete stopptr;
|
| return result;
|
| }
|
| -void CBC_Detector::copyToResult(CFX_PtrArray *result, CFX_PtrArray* tmpResult, FX_INT32* destinationIndexes, FX_INT32 destinationLength)
|
| +void CBC_Detector::copyToResult(CFX_PtrArray *result, CFX_PtrArray* tmpResult, int32_t* destinationIndexes, int32_t destinationLength)
|
| {
|
| - for (FX_INT32 i = 0; i < destinationLength; i++) {
|
| + for (int32_t i = 0; i < destinationLength; i++) {
|
| result->SetAt(destinationIndexes[i], tmpResult->GetAt(i));
|
| }
|
| }
|
| -CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, FX_INT32 height, FX_INT32 width, FX_INT32 startRow, FX_INT32 startColumn, FX_INT32* pattern, FX_INT32 patternLength)
|
| +CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, int32_t height, int32_t width, int32_t startRow, int32_t startColumn, int32_t* pattern, int32_t patternLength)
|
| {
|
| CFX_PtrArray* result = FX_NEW CFX_PtrArray;
|
| result->SetSize(4);
|
| @@ -199,12 +199,12 @@ CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, FX_
|
| break;
|
| }
|
| }
|
| - FX_INT32 stopRow = startRow + 1;
|
| + int32_t stopRow = startRow + 1;
|
| if (found) {
|
| - FX_INT32 skippedRowCount = 0;
|
| + int32_t skippedRowCount = 0;
|
| CFX_Int32Array previousRowLoc;
|
| - previousRowLoc.Add((FX_INT32)((CBC_ResultPoint*)result->GetAt(0))->GetX());
|
| - previousRowLoc.Add((FX_INT32)((CBC_ResultPoint*)result->GetAt(1))->GetX());
|
| + previousRowLoc.Add((int32_t)((CBC_ResultPoint*)result->GetAt(0))->GetX());
|
| + previousRowLoc.Add((int32_t)((CBC_ResultPoint*)result->GetAt(1))->GetX());
|
| for (; stopRow < height; stopRow++) {
|
| CFX_Int32Array* loc = findGuardPattern(matrix, previousRowLoc[0], stopRow, width, FALSE, pattern, patternLength, counters);
|
| if (loc != NULL &&
|
| @@ -227,26 +227,26 @@ CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, FX_
|
| result->SetAt(3, FX_NEW CBC_ResultPoint((FX_FLOAT)previousRowLoc.GetAt(1), (FX_FLOAT)stopRow));
|
| }
|
| if (stopRow - startRow < BARCODE_MIN_HEIGHT) {
|
| - for (FX_INT32 i = 0; i < result->GetSize(); i++) {
|
| + for (int32_t i = 0; i < result->GetSize(); i++) {
|
| result->SetAt(i, NULL);
|
| }
|
| }
|
| return result;
|
| }
|
| -CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, FX_INT32 column, FX_INT32 row, FX_INT32 width, FX_BOOL whiteFirst, FX_INT32* pattern, FX_INT32 patternLength, CFX_Int32Array &counters)
|
| +CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, int32_t column, int32_t row, int32_t width, FX_BOOL whiteFirst, int32_t* pattern, int32_t patternLength, CFX_Int32Array &counters)
|
| {
|
| - for (FX_INT32 i = 0; i < counters.GetSize(); i++) {
|
| + for (int32_t i = 0; i < counters.GetSize(); i++) {
|
| counters.SetAt(i, 0);
|
| }
|
| FX_BOOL isWhite = whiteFirst;
|
| - FX_INT32 patternStart = column;
|
| - FX_INT32 pixelDrift = 0;
|
| + int32_t patternStart = column;
|
| + int32_t pixelDrift = 0;
|
| CFX_Int32Array* intarray = FX_NEW CFX_Int32Array;
|
| while (matrix->Get(patternStart, row) && patternStart > 0 && pixelDrift++ < MAX_PIXEL_DRIFT) {
|
| patternStart--;
|
| }
|
| - FX_INT32 x = patternStart;
|
| - FX_INT32 counterPosition = 0;
|
| + int32_t x = patternStart;
|
| + int32_t counterPosition = 0;
|
| for (; x < width; x++) {
|
| FX_BOOL pixel = matrix->Get(x, row);
|
| if (pixel ^ isWhite) {
|
| @@ -259,7 +259,7 @@ CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, FX_I
|
| return intarray;
|
| }
|
| patternStart += counters[0] + counters[1];
|
| - for (FX_INT32 l = 2, k = 0; l < patternLength; l++, k++) {
|
| + for (int32_t l = 2, k = 0; l < patternLength; l++, k++) {
|
| counters.SetAt(k, counters.GetAt(l));
|
| }
|
| counters.SetAt(patternLength - 2, 0);
|
| @@ -282,25 +282,25 @@ CFX_Int32Array* CBC_Detector::findGuardPattern(CBC_CommonBitMatrix* matrix, FX_I
|
| delete intarray;
|
| return NULL;
|
| }
|
| -FX_INT32 CBC_Detector::patternMatchVariance(CFX_Int32Array &counters, FX_INT32* pattern, FX_INT32 maxIndividualVariance)
|
| +int32_t CBC_Detector::patternMatchVariance(CFX_Int32Array &counters, int32_t* pattern, int32_t maxIndividualVariance)
|
| {
|
| - FX_INT32 numCounters = counters.GetSize();
|
| - FX_INT32 total = 0;
|
| - FX_INT32 patternLength = 0;
|
| - for (FX_INT32 i = 0; i < numCounters; i++) {
|
| + int32_t numCounters = counters.GetSize();
|
| + int32_t total = 0;
|
| + int32_t patternLength = 0;
|
| + for (int32_t i = 0; i < numCounters; i++) {
|
| total += counters[i];
|
| patternLength += pattern[i];
|
| }
|
| if (total < patternLength) {
|
| return INTERGER_MAX;
|
| }
|
| - FX_INT32 unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
|
| + int32_t unitBarWidth = (total << INTEGER_MATH_SHIFT) / patternLength;
|
| maxIndividualVariance = (maxIndividualVariance * unitBarWidth) >> INTEGER_MATH_SHIFT;
|
| - FX_INT32 totalVariance = 0;
|
| - for (FX_INT32 x = 0; x < numCounters; x++) {
|
| - FX_INT32 counter = counters[x] << INTEGER_MATH_SHIFT;
|
| - FX_INT32 scaledPattern = pattern[x] * unitBarWidth;
|
| - FX_INT32 variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
|
| + int32_t totalVariance = 0;
|
| + for (int32_t x = 0; x < numCounters; x++) {
|
| + int32_t counter = counters[x] << INTEGER_MATH_SHIFT;
|
| + int32_t scaledPattern = pattern[x] * unitBarWidth;
|
| + int32_t variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
|
| if (variance > maxIndividualVariance) {
|
| return INTERGER_MAX;
|
| }
|
|
|