1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ 8 #define XFA_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ 9 10 #include "core/include/fxcrt/fx_basic.h" 11 #include "core/include/fxcrt/fx_string.h" 12 13 class CBC_CommonDecoderResult; 14 class CBC_PDF417ResultMetadata; 15 16 class CBC_DecodedBitStreamPaser { 17 public: 18 CBC_DecodedBitStreamPaser(); 19 virtual ~CBC_DecodedBitStreamPaser(); 20 static void Initialize(); 21 static void Finalize(); 22 static CBC_CommonDecoderResult* decode(CFX_Int32Array& codewords, 23 CFX_ByteString ecLevel, 24 int32_t& e); 25 26 private: 27 enum Mode { ALPHA, LOWER, MIXED, PUNCT, ALPHA_SHIFT, PUNCT_SHIFT }; 28 static int32_t MAX_NUMERIC_CODEWORDS; 29 static int32_t PL; 30 static int32_t LL; 31 static int32_t AS; 32 static int32_t ML; 33 static int32_t AL; 34 static int32_t PS; 35 static int32_t PAL; 36 static FX_CHAR PUNCT_CHARS[29]; 37 static FX_CHAR MIXED_CHARS[30]; 38 static int32_t NUMBER_OF_SEQUENCE_CODEWORDS; 39 static int32_t decodeMacroBlock(CFX_Int32Array& codewords, 40 int32_t codeIndex, 41 CBC_PDF417ResultMetadata* resultMetadata, 42 int32_t& e); 43 static int32_t textCompaction(CFX_Int32Array& codewords, 44 int32_t codeIndex, 45 CFX_ByteString& result); 46 static void decodeTextCompaction(CFX_Int32Array& textCompactionData, 47 CFX_Int32Array& byteCompactionData, 48 int32_t length, 49 CFX_ByteString& result); 50 static int32_t byteCompaction(int32_t mode, 51 CFX_Int32Array& codewords, 52 int32_t codeIndex, 53 CFX_ByteString& result); 54 static int32_t numericCompaction(CFX_Int32Array& codewords, 55 int32_t codeIndex, 56 CFX_ByteString& result, 57 int32_t& e); 58 static CFX_ByteString decodeBase900toBase10(CFX_Int32Array& codewords, 59 int32_t count, 60 int32_t& e); 61 }; 62 #endif // XFA_SRC_FXBARCODE_PDF417_BC_PDF417DECODEDBITSTREAMPARSER_H_ 63