| 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 2013 ZXing authors | 8 * Copyright 2013 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"); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "../barcode.h" | 23 #include "../barcode.h" |
| 24 #include "BC_PDF417Codeword.h" | 24 #include "BC_PDF417Codeword.h" |
| 25 #include "BC_PDF417BarcodeMetadata.h" | 25 #include "BC_PDF417BarcodeMetadata.h" |
| 26 #include "BC_PDF417BoundingBox.h" | 26 #include "BC_PDF417BoundingBox.h" |
| 27 #include "BC_PDF417DetectionResultColumn.h" | 27 #include "BC_PDF417DetectionResultColumn.h" |
| 28 #include "BC_PDF417Common.h" | 28 #include "BC_PDF417Common.h" |
| 29 #include "BC_PDF417DetectionResultRowIndicatorColumn.h" | 29 #include "BC_PDF417DetectionResultRowIndicatorColumn.h" |
| 30 #include "BC_PDF417DetectionResult.h" | 30 #include "BC_PDF417DetectionResult.h" |
| 31 FX_INT32 CBC_DetectionResult::ADJUST_ROW_NUMBER_SKIP = 2; | 31 int32_t CBC_DetectionResult::ADJUST_ROW_NUMBER_SKIP = 2; |
| 32 CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, C
BC_BoundingBox* boundingBox) | 32 CBC_DetectionResult::CBC_DetectionResult(CBC_BarcodeMetadata* barcodeMetadata, C
BC_BoundingBox* boundingBox) |
| 33 { | 33 { |
| 34 m_barcodeMetadata = barcodeMetadata; | 34 m_barcodeMetadata = barcodeMetadata; |
| 35 m_barcodeColumnCount = barcodeMetadata->getColumnCount(); | 35 m_barcodeColumnCount = barcodeMetadata->getColumnCount(); |
| 36 m_boundingBox = boundingBox; | 36 m_boundingBox = boundingBox; |
| 37 m_detectionResultColumns.SetSize(m_barcodeColumnCount + 2); | 37 m_detectionResultColumns.SetSize(m_barcodeColumnCount + 2); |
| 38 for (FX_INT32 i = 0; i < m_barcodeColumnCount + 2; i++) { | 38 for (int32_t i = 0; i < m_barcodeColumnCount + 2; i++) { |
| 39 m_detectionResultColumns[i] = NULL; | 39 m_detectionResultColumns[i] = NULL; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 CBC_DetectionResult::~CBC_DetectionResult() | 42 CBC_DetectionResult::~CBC_DetectionResult() |
| 43 { | 43 { |
| 44 delete m_boundingBox; | 44 delete m_boundingBox; |
| 45 delete m_barcodeMetadata; | 45 delete m_barcodeMetadata; |
| 46 m_detectionResultColumns.RemoveAll(); | 46 m_detectionResultColumns.RemoveAll(); |
| 47 } | 47 } |
| 48 CFX_PtrArray& CBC_DetectionResult::getDetectionResultColumns() | 48 CFX_PtrArray& CBC_DetectionResult::getDetectionResultColumns() |
| 49 { | 49 { |
| 50 adjustIndicatorColumnRowNumbers((CBC_DetectionResultColumn*)m_detectionResul
tColumns.GetAt(0)); | 50 adjustIndicatorColumnRowNumbers((CBC_DetectionResultColumn*)m_detectionResul
tColumns.GetAt(0)); |
| 51 adjustIndicatorColumnRowNumbers((CBC_DetectionResultColumn*)m_detectionResul
tColumns.GetAt(m_barcodeColumnCount + 1)); | 51 adjustIndicatorColumnRowNumbers((CBC_DetectionResultColumn*)m_detectionResul
tColumns.GetAt(m_barcodeColumnCount + 1)); |
| 52 FX_INT32 unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCOD
E; | 52 int32_t unadjustedCodewordCount = CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE
; |
| 53 FX_INT32 previousUnadjustedCount; | 53 int32_t previousUnadjustedCount; |
| 54 do { | 54 do { |
| 55 previousUnadjustedCount = unadjustedCodewordCount; | 55 previousUnadjustedCount = unadjustedCodewordCount; |
| 56 unadjustedCodewordCount = adjustRowNumbers(); | 56 unadjustedCodewordCount = adjustRowNumbers(); |
| 57 } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUn
adjustedCount); | 57 } while (unadjustedCodewordCount > 0 && unadjustedCodewordCount < previousUn
adjustedCount); |
| 58 return m_detectionResultColumns; | 58 return m_detectionResultColumns; |
| 59 } | 59 } |
| 60 void CBC_DetectionResult::setBoundingBox(CBC_BoundingBox* boundingBox) | 60 void CBC_DetectionResult::setBoundingBox(CBC_BoundingBox* boundingBox) |
| 61 { | 61 { |
| 62 m_boundingBox = boundingBox; | 62 m_boundingBox = boundingBox; |
| 63 } | 63 } |
| 64 CBC_BoundingBox* CBC_DetectionResult::getBoundingBox() | 64 CBC_BoundingBox* CBC_DetectionResult::getBoundingBox() |
| 65 { | 65 { |
| 66 return m_boundingBox; | 66 return m_boundingBox; |
| 67 } | 67 } |
| 68 void CBC_DetectionResult::setDetectionResultColumn(FX_INT32 barcodeColumn, CBC_D
etectionResultColumn* detectionResultColumn) | 68 void CBC_DetectionResult::setDetectionResultColumn(int32_t barcodeColumn, CBC_De
tectionResultColumn* detectionResultColumn) |
| 69 { | 69 { |
| 70 m_detectionResultColumns[barcodeColumn] = detectionResultColumn; | 70 m_detectionResultColumns[barcodeColumn] = detectionResultColumn; |
| 71 } | 71 } |
| 72 CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn(FX_INT3
2 barcodeColumn) | 72 CBC_DetectionResultColumn* CBC_DetectionResult::getDetectionResultColumn(int32_t
barcodeColumn) |
| 73 { | 73 { |
| 74 return (CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]; | 74 return (CBC_DetectionResultColumn*)m_detectionResultColumns[barcodeColumn]; |
| 75 } | 75 } |
| 76 CFX_ByteString CBC_DetectionResult::toString() | 76 CFX_ByteString CBC_DetectionResult::toString() |
| 77 { | 77 { |
| 78 CBC_DetectionResultColumn* rowIndicatorColumn = (CBC_DetectionResultColumn*)
m_detectionResultColumns[0]; | 78 CBC_DetectionResultColumn* rowIndicatorColumn = (CBC_DetectionResultColumn*)
m_detectionResultColumns[0]; |
| 79 if (rowIndicatorColumn == NULL) { | 79 if (rowIndicatorColumn == NULL) { |
| 80 rowIndicatorColumn = (CBC_DetectionResultColumn*)m_detectionResultColumn
s[m_barcodeColumnCount + 1]; | 80 rowIndicatorColumn = (CBC_DetectionResultColumn*)m_detectionResultColumn
s[m_barcodeColumnCount + 1]; |
| 81 } | 81 } |
| 82 CFX_ByteString result; | 82 CFX_ByteString result; |
| 83 for (FX_INT32 codewordsRow = 0; codewordsRow < rowIndicatorColumn->getCodewo
rds()->GetSize(); codewordsRow++) { | 83 for (int32_t codewordsRow = 0; codewordsRow < rowIndicatorColumn->getCodewor
ds()->GetSize(); codewordsRow++) { |
| 84 result += (FX_CHAR) codewordsRow; | 84 result += (FX_CHAR) codewordsRow; |
| 85 for (FX_INT32 barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount +
2; barcodeColumn++) { | 85 for (int32_t barcodeColumn = 0; barcodeColumn < m_barcodeColumnCount + 2
; barcodeColumn++) { |
| 86 if (m_detectionResultColumns[barcodeColumn] == NULL) { | 86 if (m_detectionResultColumns[barcodeColumn] == NULL) { |
| 87 result += " | "; | 87 result += " | "; |
| 88 continue; | 88 continue; |
| 89 } | 89 } |
| 90 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRow); | 90 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRow); |
| 91 if (codeword == NULL) { | 91 if (codeword == NULL) { |
| 92 result += " | "; | 92 result += " | "; |
| 93 continue; | 93 continue; |
| 94 } | 94 } |
| 95 result += codeword->getRowNumber(); | 95 result += codeword->getRowNumber(); |
| 96 result += codeword->getValue(); | 96 result += codeword->getValue(); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 return result; | 99 return result; |
| 100 } | 100 } |
| 101 void CBC_DetectionResult::adjustIndicatorColumnRowNumbers(CBC_DetectionResultCol
umn* detectionResultColumn) | 101 void CBC_DetectionResult::adjustIndicatorColumnRowNumbers(CBC_DetectionResultCol
umn* detectionResultColumn) |
| 102 { | 102 { |
| 103 if (detectionResultColumn != NULL) { | 103 if (detectionResultColumn != NULL) { |
| 104 ((CBC_DetectionResultRowIndicatorColumn*)detectionResultColumn)->adjustC
ompleteIndicatorColumnRowNumbers(*m_barcodeMetadata); | 104 ((CBC_DetectionResultRowIndicatorColumn*)detectionResultColumn)->adjustC
ompleteIndicatorColumnRowNumbers(*m_barcodeMetadata); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 FX_INT32 CBC_DetectionResult::adjustRowNumbers() | 107 int32_t CBC_DetectionResult::adjustRowNumbers() |
| 108 { | 108 { |
| 109 FX_INT32 unadjustedCount = adjustRowNumbersByRow(); | 109 int32_t unadjustedCount = adjustRowNumbersByRow(); |
| 110 if (unadjustedCount == 0) { | 110 if (unadjustedCount == 0) { |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| 113 for (FX_INT32 barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; b
arcodeColumn++) { | 113 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1; ba
rcodeColumn++) { |
| 114 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResult
Columns[barcodeColumn])->getCodewords(); | 114 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResult
Columns[barcodeColumn])->getCodewords(); |
| 115 for (FX_INT32 codewordsRow = 0; codewordsRow < codewords->GetSize(); cod
ewordsRow++) { | 115 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); code
wordsRow++) { |
| 116 if (codewords->GetAt(codewordsRow) == NULL) { | 116 if (codewords->GetAt(codewordsRow) == NULL) { |
| 117 continue; | 117 continue; |
| 118 } | 118 } |
| 119 if (!((CBC_Codeword*)codewords->GetAt(codewordsRow))->hasValidRowNum
ber()) { | 119 if (!((CBC_Codeword*)codewords->GetAt(codewordsRow))->hasValidRowNum
ber()) { |
| 120 adjustRowNumbers(barcodeColumn, codewordsRow, codewords); | 120 adjustRowNumbers(barcodeColumn, codewordsRow, codewords); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 return unadjustedCount; | 124 return unadjustedCount; |
| 125 } | 125 } |
| 126 FX_INT32 CBC_DetectionResult::adjustRowNumbersByRow() | 126 int32_t CBC_DetectionResult::adjustRowNumbersByRow() |
| 127 { | 127 { |
| 128 adjustRowNumbersFromBothRI(); | 128 adjustRowNumbersFromBothRI(); |
| 129 FX_INT32 unadjustedCount = adjustRowNumbersFromLRI(); | 129 int32_t unadjustedCount = adjustRowNumbersFromLRI(); |
| 130 return unadjustedCount + adjustRowNumbersFromRRI(); | 130 return unadjustedCount + adjustRowNumbersFromRRI(); |
| 131 } | 131 } |
| 132 FX_INT32 CBC_DetectionResult::adjustRowNumbersFromBothRI() | 132 int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() |
| 133 { | 133 { |
| 134 if (m_detectionResultColumns[0] == NULL || m_detectionResultColumns[m_barcod
eColumnCount + 1] == NULL) { | 134 if (m_detectionResultColumns[0] == NULL || m_detectionResultColumns[m_barcod
eColumnCount + 1] == NULL) { |
| 135 return 0; | 135 return 0; |
| 136 } | 136 } |
| 137 CFX_PtrArray* LRIcodewords = ((CBC_DetectionResultColumn*)m_detectionResultC
olumns[0])->getCodewords(); | 137 CFX_PtrArray* LRIcodewords = ((CBC_DetectionResultColumn*)m_detectionResultC
olumns[0])->getCodewords(); |
| 138 CFX_PtrArray* RRIcodewords = ((CBC_DetectionResultColumn*)m_detectionResultC
olumns[m_barcodeColumnCount + 1])->getCodewords(); | 138 CFX_PtrArray* RRIcodewords = ((CBC_DetectionResultColumn*)m_detectionResultC
olumns[m_barcodeColumnCount + 1])->getCodewords(); |
| 139 for (FX_INT32 codewordsRow = 0; codewordsRow < LRIcodewords->GetSize(); code
wordsRow++) { | 139 for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize(); codew
ordsRow++) { |
| 140 if (LRIcodewords->GetAt(codewordsRow) != NULL && | 140 if (LRIcodewords->GetAt(codewordsRow) != NULL && |
| 141 RRIcodewords->GetAt(codewordsRow) != NULL && | 141 RRIcodewords->GetAt(codewordsRow) != NULL && |
| 142 ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber
() == ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow))->getRowNumber()) { | 142 ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber
() == ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow))->getRowNumber()) { |
| 143 for (FX_INT32 barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCou
nt; barcodeColumn++) { | 143 for (int32_t barcodeColumn = 1; barcodeColumn <= m_barcodeColumnCoun
t; barcodeColumn++) { |
| 144 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultCol
umn*)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRo
w); | 144 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultCol
umn*)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRo
w); |
| 145 if (codeword == NULL) { | 145 if (codeword == NULL) { |
| 146 continue; | 146 continue; |
| 147 } | 147 } |
| 148 codeword->setRowNumber(((CBC_Codeword*)LRIcodewords->GetAt(codew
ordsRow))->getRowNumber()); | 148 codeword->setRowNumber(((CBC_Codeword*)LRIcodewords->GetAt(codew
ordsRow))->getRowNumber()); |
| 149 if (!codeword->hasValidRowNumber()) { | 149 if (!codeword->hasValidRowNumber()) { |
| 150 ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcod
eColumn])->getCodewords()->SetAt(codewordsRow, NULL); | 150 ((CBC_DetectionResultColumn*)m_detectionResultColumns[barcod
eColumn])->getCodewords()->SetAt(codewordsRow, NULL); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 return 0; | 155 return 0; |
| 156 } | 156 } |
| 157 FX_INT32 CBC_DetectionResult::adjustRowNumbersFromRRI() | 157 int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() |
| 158 { | 158 { |
| 159 if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { | 159 if (m_detectionResultColumns[m_barcodeColumnCount + 1] == NULL) { |
| 160 return 0; | 160 return 0; |
| 161 } | 161 } |
| 162 FX_INT32 unadjustedCount = 0; | 162 int32_t unadjustedCount = 0; |
| 163 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*) m_detectionResultCol
umns.GetAt(m_barcodeColumnCount + 1))->getCodewords(); | 163 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*) m_detectionResultCol
umns.GetAt(m_barcodeColumnCount + 1))->getCodewords(); |
| 164 for (FX_INT32 codewordsRow = 0; codewordsRow < codewords->GetSize(); codewor
dsRow++) { | 164 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); codeword
sRow++) { |
| 165 if (codewords->GetAt(codewordsRow) == NULL) { | 165 if (codewords->GetAt(codewordsRow) == NULL) { |
| 166 continue; | 166 continue; |
| 167 } | 167 } |
| 168 FX_INT32 rowIndicatorRowNumber = ((CBC_Codeword*)codewords->GetAt(codewo
rdsRow))->getRowNumber(); | 168 int32_t rowIndicatorRowNumber = ((CBC_Codeword*)codewords->GetAt(codewor
dsRow))->getRowNumber(); |
| 169 FX_INT32 invalidRowCounts = 0; | 169 int32_t invalidRowCounts = 0; |
| 170 for (FX_INT32 barcodeColumn = m_barcodeColumnCount + 1; barcodeColumn >
0 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) { | 170 for (int32_t barcodeColumn = m_barcodeColumnCount + 1; barcodeColumn > 0
&& invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn--) { |
| 171 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns.GetAt(barcodeColumn))->getCodewords()->GetAt(codewords
Row); | 171 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns.GetAt(barcodeColumn))->getCodewords()->GetAt(codewords
Row); |
| 172 if (codeword != NULL) { | 172 if (codeword != NULL) { |
| 173 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword); | 173 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword); |
| 174 if (!codeword->hasValidRowNumber()) { | 174 if (!codeword->hasValidRowNumber()) { |
| 175 unadjustedCount++; | 175 unadjustedCount++; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 return unadjustedCount; | 180 return unadjustedCount; |
| 181 } | 181 } |
| 182 FX_INT32 CBC_DetectionResult::adjustRowNumbersFromLRI() | 182 int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() |
| 183 { | 183 { |
| 184 if (m_detectionResultColumns[0] == NULL) { | 184 if (m_detectionResultColumns[0] == NULL) { |
| 185 return 0; | 185 return 0; |
| 186 } | 186 } |
| 187 FX_INT32 unadjustedCount = 0; | 187 int32_t unadjustedCount = 0; |
| 188 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResultColu
mns.GetAt(0))->getCodewords(); | 188 CFX_PtrArray* codewords = ((CBC_DetectionResultColumn*)m_detectionResultColu
mns.GetAt(0))->getCodewords(); |
| 189 for (FX_INT32 codewordsRow = 0; codewordsRow < codewords->GetSize(); codewor
dsRow++) { | 189 for (int32_t codewordsRow = 0; codewordsRow < codewords->GetSize(); codeword
sRow++) { |
| 190 if (codewords->GetAt(codewordsRow) == NULL) { | 190 if (codewords->GetAt(codewordsRow) == NULL) { |
| 191 continue; | 191 continue; |
| 192 } | 192 } |
| 193 FX_INT32 rowIndicatorRowNumber = ((CBC_Codeword*)codewords->GetAt(codewo
rdsRow))->getRowNumber(); | 193 int32_t rowIndicatorRowNumber = ((CBC_Codeword*)codewords->GetAt(codewor
dsRow))->getRowNumber(); |
| 194 FX_INT32 invalidRowCounts = 0; | 194 int32_t invalidRowCounts = 0; |
| 195 for (FX_INT32 barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount +
1 && invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) { | 195 for (int32_t barcodeColumn = 1; barcodeColumn < m_barcodeColumnCount + 1
&& invalidRowCounts < ADJUST_ROW_NUMBER_SKIP; barcodeColumn++) { |
| 196 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRow); | 196 CBC_Codeword* codeword = (CBC_Codeword*)((CBC_DetectionResultColumn*
)m_detectionResultColumns[barcodeColumn])->getCodewords()->GetAt(codewordsRow); |
| 197 if (codeword != NULL) { | 197 if (codeword != NULL) { |
| 198 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword); | 198 invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber,
invalidRowCounts, codeword); |
| 199 if (!codeword->hasValidRowNumber()) { | 199 if (!codeword->hasValidRowNumber()) { |
| 200 unadjustedCount++; | 200 unadjustedCount++; |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 return unadjustedCount; | 205 return unadjustedCount; |
| 206 } | 206 } |
| 207 FX_INT32 CBC_DetectionResult::adjustRowNumberIfValid(FX_INT32 rowIndicatorRowNum
ber, FX_INT32 invalidRowCounts, CBC_Codeword* codeword) | 207 int32_t CBC_DetectionResult::adjustRowNumberIfValid(int32_t rowIndicatorRowNumbe
r, int32_t invalidRowCounts, CBC_Codeword* codeword) |
| 208 { | 208 { |
| 209 if (codeword == NULL) { | 209 if (codeword == NULL) { |
| 210 return invalidRowCounts; | 210 return invalidRowCounts; |
| 211 } | 211 } |
| 212 if (!codeword->hasValidRowNumber()) { | 212 if (!codeword->hasValidRowNumber()) { |
| 213 if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { | 213 if (codeword->isValidRowNumber(rowIndicatorRowNumber)) { |
| 214 codeword->setRowNumber(rowIndicatorRowNumber); | 214 codeword->setRowNumber(rowIndicatorRowNumber); |
| 215 invalidRowCounts = 0; | 215 invalidRowCounts = 0; |
| 216 } else { | 216 } else { |
| 217 ++invalidRowCounts; | 217 ++invalidRowCounts; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 return invalidRowCounts; | 220 return invalidRowCounts; |
| 221 } | 221 } |
| 222 void CBC_DetectionResult::adjustRowNumbers(FX_INT32 barcodeColumn, FX_INT32 code
wordsRow, CFX_PtrArray* codewords) | 222 void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn, int32_t codewo
rdsRow, CFX_PtrArray* codewords) |
| 223 { | 223 { |
| 224 CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); | 224 CBC_Codeword* codeword = (CBC_Codeword*)codewords->GetAt(codewordsRow); |
| 225 CFX_PtrArray* previousColumnCodewords = ((CBC_DetectionResultColumn*)m_detec
tionResultColumns.GetAt(barcodeColumn - 1))->getCodewords(); | 225 CFX_PtrArray* previousColumnCodewords = ((CBC_DetectionResultColumn*)m_detec
tionResultColumns.GetAt(barcodeColumn - 1))->getCodewords(); |
| 226 CFX_PtrArray* nextColumnCodewords = previousColumnCodewords; | 226 CFX_PtrArray* nextColumnCodewords = previousColumnCodewords; |
| 227 if (m_detectionResultColumns[barcodeColumn + 1] != NULL) { | 227 if (m_detectionResultColumns[barcodeColumn + 1] != NULL) { |
| 228 nextColumnCodewords = ((CBC_DetectionResultColumn*)m_detectionResultColu
mns[barcodeColumn + 1])->getCodewords(); | 228 nextColumnCodewords = ((CBC_DetectionResultColumn*)m_detectionResultColu
mns[barcodeColumn + 1])->getCodewords(); |
| 229 } | 229 } |
| 230 CFX_PtrArray otherCodewords; | 230 CFX_PtrArray otherCodewords; |
| 231 otherCodewords.SetSize(14); | 231 otherCodewords.SetSize(14); |
| 232 otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow); | 232 otherCodewords[2] = previousColumnCodewords->GetAt(codewordsRow); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 244 if (codewordsRow < codewords->GetSize() - 1) { | 244 if (codewordsRow < codewords->GetSize() - 1) { |
| 245 otherCodewords[1] = codewords->GetAt(codewordsRow + 1); | 245 otherCodewords[1] = codewords->GetAt(codewordsRow + 1); |
| 246 otherCodewords[6] = previousColumnCodewords->GetAt(codewordsRow + 1); | 246 otherCodewords[6] = previousColumnCodewords->GetAt(codewordsRow + 1); |
| 247 otherCodewords[7] = nextColumnCodewords->GetAt(codewordsRow + 1); | 247 otherCodewords[7] = nextColumnCodewords->GetAt(codewordsRow + 1); |
| 248 } | 248 } |
| 249 if (codewordsRow < codewords->GetSize() - 2) { | 249 if (codewordsRow < codewords->GetSize() - 2) { |
| 250 otherCodewords[9] = codewords->GetAt(codewordsRow + 2); | 250 otherCodewords[9] = codewords->GetAt(codewordsRow + 2); |
| 251 otherCodewords[12] = previousColumnCodewords->GetAt(codewordsRow + 2); | 251 otherCodewords[12] = previousColumnCodewords->GetAt(codewordsRow + 2); |
| 252 otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2); | 252 otherCodewords[13] = nextColumnCodewords->GetAt(codewordsRow + 2); |
| 253 } | 253 } |
| 254 for (FX_INT32 i = 0; i < otherCodewords.GetSize(); i++) { | 254 for (int32_t i = 0; i < otherCodewords.GetSize(); i++) { |
| 255 CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i); | 255 CBC_Codeword* otherCodeword = (CBC_Codeword*)otherCodewords.GetAt(i); |
| 256 if (adjustRowNumber(codeword, otherCodeword)) { | 256 if (adjustRowNumber(codeword, otherCodeword)) { |
| 257 return; | 257 return; |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, CBC_Codewor
d* otherCodeword) | 261 FX_BOOL CBC_DetectionResult::adjustRowNumber(CBC_Codeword* codeword, CBC_Codewor
d* otherCodeword) |
| 262 { | 262 { |
| 263 if (otherCodeword == NULL) { | 263 if (otherCodeword == NULL) { |
| 264 return FALSE; | 264 return FALSE; |
| 265 } | 265 } |
| 266 if (otherCodeword->hasValidRowNumber() && otherCodeword->getBucket() == code
word->getBucket()) { | 266 if (otherCodeword->hasValidRowNumber() && otherCodeword->getBucket() == code
word->getBucket()) { |
| 267 codeword->setRowNumber(otherCodeword->getRowNumber()); | 267 codeword->setRowNumber(otherCodeword->getRowNumber()); |
| 268 return TRUE; | 268 return TRUE; |
| 269 } | 269 } |
| 270 return FALSE; | 270 return FALSE; |
| 271 } | 271 } |
| 272 FX_INT32 CBC_DetectionResult::getBarcodeColumnCount() | 272 int32_t CBC_DetectionResult::getBarcodeColumnCount() |
| 273 { | 273 { |
| 274 return m_barcodeColumnCount; | 274 return m_barcodeColumnCount; |
| 275 } | 275 } |
| 276 FX_INT32 CBC_DetectionResult::getBarcodeRowCount() | 276 int32_t CBC_DetectionResult::getBarcodeRowCount() |
| 277 { | 277 { |
| 278 return m_barcodeMetadata->getRowCount(); | 278 return m_barcodeMetadata->getRowCount(); |
| 279 } | 279 } |
| 280 FX_INT32 CBC_DetectionResult::getBarcodeECLevel() | 280 int32_t CBC_DetectionResult::getBarcodeECLevel() |
| 281 { | 281 { |
| 282 return m_barcodeMetadata->getErrorCorrectionLevel(); | 282 return m_barcodeMetadata->getErrorCorrectionLevel(); |
| 283 } | 283 } |
| OLD | NEW |