Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxbarcode / src / include / BC_PDF417ScanningDecoder.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _BC_PDF417SCANNINGDECODER_H_\r
8 #define _BC_PDF417SCANNINGDECODER_H_\r
9 class CBC_CommonDecoderResult;\r
10 class CBC_CommonBitMatrix;\r
11 class CBC_ErrorCorrection;\r
12 class CBC_Codeword;\r
13 class CBC_BoundingBox;\r
14 class CBC_ResultPoint;\r
15 class CBC_BarcodeMetadata;\r
16 class CBC_BarcodeValue;\r
17 class CBC_DetectionResult;\r
18 class CBC_DetectionResultRowIndicatorColumn;\r
19 class CBC_PDF417ScanningDecoder;\r
20 class CBC_PDF417ScanningDecoder  : public CFX_Object\r
21 {\r
22 public:\r
23     CBC_PDF417ScanningDecoder();\r
24     virtual ~CBC_PDF417ScanningDecoder();\r
25     static void Initialize();\r
26     static void Finalize();\r
27     static CBC_CommonDecoderResult* decode(CBC_CommonBitMatrix* image, CBC_ResultPoint* imageTopLeft, CBC_ResultPoint* imageBottomLeft, CBC_ResultPoint* imageTopRight,\r
28                                            CBC_ResultPoint* imageBottomRight, FX_INT32 minCodewordWidth, FX_INT32 maxCodewordWidth, FX_INT32 &e);\r
29     static CFX_ByteString toString(CFX_PtrArray* barcodeMatrix);\r
30 private:\r
31     static FX_INT32 CODEWORD_SKEW_SIZE;\r
32     static FX_INT32 MAX_ERRORS;\r
33     static FX_INT32 MAX_EC_CODEWORDS;\r
34     static CBC_PDF417ECErrorCorrection* errorCorrection;\r
35     static CBC_DetectionResult* merge(CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn, FX_INT32 &e);\r
36     static CBC_BoundingBox* adjustBoundingBox(CBC_DetectionResultRowIndicatorColumn* rowIndicatorColumn, FX_INT32 &e);\r
37     static FX_INT32 getMax(CFX_Int32Array& values);\r
38     static CBC_BarcodeMetadata* getBarcodeMetadata(CBC_DetectionResultRowIndicatorColumn* leftRowIndicatorColumn, CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn);\r
39     static CBC_DetectionResultRowIndicatorColumn* getRowIndicatorColumn(CBC_CommonBitMatrix* image, CBC_BoundingBox* boundingBox, CBC_ResultPoint startPoint,\r
40             FX_BOOL leftToRight, FX_INT32 minCodewordWidth, FX_INT32 maxCodewordWidth);\r
41     static void adjustCodewordCount(CBC_DetectionResult* detectionResult, CFX_PtrArray* barcodeMatrix, FX_INT32 &e);\r
42     static CBC_CommonDecoderResult* createDecoderResult(CBC_DetectionResult* detectionResult, FX_INT32 &e);\r
43     static CBC_CommonDecoderResult* createDecoderResultFromAmbiguousValues(FX_INT32 ecLevel, CFX_Int32Array &codewords, CFX_Int32Array &erasureArray, CFX_Int32Array &ambiguousIndexes,\r
44             CFX_PtrArray& ambiguousIndexValues, FX_INT32 &e);\r
45     static CFX_PtrArray* createBarcodeMatrix(CBC_DetectionResult* detectionResult);\r
46     static FX_BOOL isValidBarcodeColumn(CBC_DetectionResult* detectionResult, FX_INT32 barcodeColumn);\r
47     static FX_INT32 getStartColumn(CBC_DetectionResult* detectionResult, FX_INT32 barcodeColumn, FX_INT32 imageRow, FX_BOOL leftToRight);\r
48     static CBC_Codeword* detectCodeword(CBC_CommonBitMatrix* image, FX_INT32 minColumn, FX_INT32 maxColumn, FX_BOOL leftToRight, FX_INT32 startColumn,\r
49                                         FX_INT32 imageRow, FX_INT32 minCodewordWidth, FX_INT32 maxCodewordWidth);\r
50     static CFX_Int32Array* getModuleBitCount(CBC_CommonBitMatrix* image, FX_INT32 minColumn, FX_INT32 maxColumn, FX_BOOL leftToRight, FX_INT32 startColumn, FX_INT32 imageRow);\r
51     static FX_INT32 getNumberOfECCodeWords(FX_INT32 barcodeECLevel);\r
52     static FX_INT32 adjustCodewordStartColumn(CBC_CommonBitMatrix* image, FX_INT32 minColumn, FX_INT32 maxColumn, FX_BOOL leftToRight, FX_INT32 codewordStartColumn, FX_INT32 imageRow);\r
53     static FX_BOOL checkCodewordSkew(FX_INT32 codewordSize, FX_INT32 minCodewordWidth, FX_INT32 maxCodewordWidth);\r
54     static CBC_CommonDecoderResult* decodeCodewords(CFX_Int32Array &codewords, FX_INT32 ecLevel, CFX_Int32Array &erasures, FX_INT32 &e);\r
55     static FX_INT32 correctErrors(CFX_Int32Array &codewords, CFX_Int32Array &erasures, FX_INT32 numECCodewords, FX_INT32 &e);\r
56     static void verifyCodewordCount(CFX_Int32Array &codewords, FX_INT32 numECCodewords, FX_INT32 &e);\r
57     static CFX_Int32Array* getBitCountForCodeword(FX_INT32 codeword);\r
58     static FX_INT32 getCodewordBucketNumber(FX_INT32 codeword);\r
59     static FX_INT32 getCodewordBucketNumber(CFX_Int32Array& moduleBitCount);\r
60 };\r
61 #endif\r