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

Unified Diff: xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h ('k') | xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
index bc01eff442987cf3c640c34f4a58c0ec43d0e9cf..f0e777c6eb4a6a50e4d8d8f5d974be9435653da6 100644
--- a/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
+++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.cpp
@@ -31,20 +31,20 @@ CBC_QRCoderMaskUtil::CBC_QRCoderMaskUtil()
CBC_QRCoderMaskUtil::~CBC_QRCoderMaskUtil()
{
}
-FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1(CBC_CommonByteMatrix* matrix)
+int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1(CBC_CommonByteMatrix* matrix)
{
return ApplyMaskPenaltyRule1Internal(matrix, TRUE) +
ApplyMaskPenaltyRule1Internal(matrix, FALSE);
}
-FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2(CBC_CommonByteMatrix* matrix)
+int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2(CBC_CommonByteMatrix* matrix)
{
- FX_INT32 penalty = 0;
- FX_BYTE* array = matrix->GetArray();
- FX_INT32 width = matrix->GetWidth();
- FX_INT32 height = matrix->GetHeight();
- for(FX_INT32 y = 0; y < height - 1; y++) {
- for(FX_INT32 x = 0; x < width - 1; x++) {
- FX_INT32 value = array[y * width + x];
+ int32_t penalty = 0;
+ uint8_t* array = matrix->GetArray();
+ int32_t width = matrix->GetWidth();
+ int32_t height = matrix->GetHeight();
+ for(int32_t y = 0; y < height - 1; y++) {
+ for(int32_t x = 0; x < width - 1; x++) {
+ int32_t value = array[y * width + x];
if(value == array[y * width + x + 1] &&
value == array[(y + 1) * width + x] &&
value == array[(y + 1) * width + x + 1]) {
@@ -54,14 +54,14 @@ FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule2(CBC_CommonByteMatrix* matrix
}
return 3 * penalty;
}
-FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(CBC_CommonByteMatrix* matrix)
+int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(CBC_CommonByteMatrix* matrix)
{
- FX_INT32 penalty = 0;
- FX_BYTE* array = matrix->GetArray();
- FX_INT32 width = matrix->GetWidth();
- FX_INT32 height = matrix->GetHeight();
- for (FX_INT32 y = 0; y < height; ++y) {
- for (FX_INT32 x = 0; x < width; ++x) {
+ int32_t penalty = 0;
+ uint8_t* array = matrix->GetArray();
+ int32_t width = matrix->GetWidth();
+ int32_t height = matrix->GetHeight();
+ for (int32_t y = 0; y < height; ++y) {
+ for (int32_t x = 0; x < width; ++x) {
if (x == 0 && ((y >= 0 && y <= 6) || (y >= height - 7 && y <= height - 1))) {
continue;
}
@@ -118,30 +118,30 @@ FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule3(CBC_CommonByteMatrix* matrix
}
return penalty;
}
-FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(CBC_CommonByteMatrix* matrix)
+int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule4(CBC_CommonByteMatrix* matrix)
{
- FX_INT32 numDarkCells = 0;
- FX_BYTE* array = matrix->GetArray();
- FX_INT32 width = matrix->GetWidth();
- FX_INT32 height = matrix->GetHeight();
- for (FX_INT32 y = 0; y < height; ++y) {
- for (FX_INT32 x = 0; x < width; ++x) {
+ int32_t numDarkCells = 0;
+ uint8_t* array = matrix->GetArray();
+ int32_t width = matrix->GetWidth();
+ int32_t height = matrix->GetHeight();
+ for (int32_t y = 0; y < height; ++y) {
+ for (int32_t x = 0; x < width; ++x) {
if (array[y * width + x] == 1) {
numDarkCells += 1;
}
}
}
- FX_INT32 numTotalCells = matrix->GetHeight() * matrix->GetWidth();
+ int32_t numTotalCells = matrix->GetHeight() * matrix->GetWidth();
double darkRatio = (double) numDarkCells / numTotalCells;
- return abs( (FX_INT32) (darkRatio * 100 - 50) / 5 ) * 5 * 10;
+ return abs( (int32_t) (darkRatio * 100 - 50) / 5 ) * 5 * 10;
}
-FX_BOOL CBC_QRCoderMaskUtil::GetDataMaskBit(FX_INT32 maskPattern, FX_INT32 x, FX_INT32 y, FX_INT32 &e)
+FX_BOOL CBC_QRCoderMaskUtil::GetDataMaskBit(int32_t maskPattern, int32_t x, int32_t y, int32_t &e)
{
if(!CBC_QRCoder::IsValidMaskPattern(maskPattern)) {
e = (BCExceptionInvalidateMaskPattern);
BC_EXCEPTION_CHECK_ReturnValue(e, FALSE);
}
- FX_INT32 intermediate = 0, temp = 0;
+ int32_t intermediate = 0, temp = 0;
switch(maskPattern) {
case 0:
intermediate = (y + x) & 0x1;
@@ -177,19 +177,19 @@ FX_BOOL CBC_QRCoderMaskUtil::GetDataMaskBit(FX_INT32 maskPattern, FX_INT32 x, FX
}
return intermediate == 0;
}
-FX_INT32 CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal(CBC_CommonByteMatrix* matrix, FX_BOOL isHorizontal)
+int32_t CBC_QRCoderMaskUtil::ApplyMaskPenaltyRule1Internal(CBC_CommonByteMatrix* matrix, FX_BOOL isHorizontal)
{
- FX_INT32 penalty = 0;
- FX_INT32 numSameBitCells = 0;
- FX_INT32 prevBit = -1;
- FX_INT32 width = matrix->GetWidth();
- FX_INT32 height = matrix->GetHeight();
- FX_INT32 iLimit = isHorizontal ? height : width;
- FX_INT32 jLimit = isHorizontal ? width : height;
- FX_BYTE* array = matrix->GetArray();
- for (FX_INT32 i = 0; i < iLimit; ++i) {
- for (FX_INT32 j = 0; j < jLimit; ++j) {
- FX_INT32 bit = isHorizontal ? array[i * width + j] : array[j * width + i];
+ int32_t penalty = 0;
+ int32_t numSameBitCells = 0;
+ int32_t prevBit = -1;
+ int32_t width = matrix->GetWidth();
+ int32_t height = matrix->GetHeight();
+ int32_t iLimit = isHorizontal ? height : width;
+ int32_t jLimit = isHorizontal ? width : height;
+ uint8_t* array = matrix->GetArray();
+ for (int32_t i = 0; i < iLimit; ++i) {
+ for (int32_t j = 0; j < jLimit; ++j) {
+ int32_t bit = isHorizontal ? array[i * width + j] : array[j * width + i];
if (bit == prevBit) {
numSameBitCells += 1;
if (numSameBitCells == 5) {
« no previous file with comments | « xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h ('k') | xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698