| 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 | 6 |
| 7 #include "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "codec_int.h" | 8 #include "codec_int.h" |
| 9 extern const FX_BYTE OneLeadPos[256]; | 9 const FX_BYTE OneLeadPos[256] = { |
| 10 extern const FX_BYTE ZeroLeadPos[256]; | 10 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, |
| 11 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
| 12 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 13 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 14 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 15 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 16 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 17 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 18 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 19 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 20 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 21 0, 0, 0, 0, 0, 0, 0, 0, 0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3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
| 43 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, |
| 44 }; |
| 45 |
| 11 int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit) | 46 int _FindBit(const FX_BYTE* data_buf, int max_pos, int start_pos, int bit) |
| 12 { | 47 { |
| 13 if (start_pos >= max_pos) { | 48 if (start_pos >= max_pos) { |
| 14 return max_pos; | 49 return max_pos; |
| 15 } | 50 } |
| 16 FX_LPCBYTE leading_pos = bit ? OneLeadPos : ZeroLeadPos; | 51 FX_LPCBYTE leading_pos = bit ? OneLeadPos : ZeroLeadPos; |
| 17 if (start_pos % 8) { | 52 if (start_pos % 8) { |
| 18 FX_BYTE data = data_buf[start_pos / 8]; | 53 FX_BYTE data = data_buf[start_pos / 8]; |
| 19 if (bit) { | 54 if (bit) { |
| 20 data &= 0xff >> (start_pos % 8); | 55 data &= 0xff >> (start_pos % 8); |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D
WORD src_size, int width, int height, | 994 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D
WORD src_size, int width, int height, |
| 960 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in
t Columns, int Rows) | 995 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in
t Columns, int Rows) |
| 961 { | 996 { |
| 962 CCodec_FaxDecoder* pDecoder = FX_NEW CCodec_FaxDecoder; | 997 CCodec_FaxDecoder* pDecoder = FX_NEW CCodec_FaxDecoder; |
| 963 if (pDecoder == NULL) { | 998 if (pDecoder == NULL) { |
| 964 return NULL; | 999 return NULL; |
| 965 } | 1000 } |
| 966 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte
Align, BlackIs1, Columns, Rows); | 1001 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte
Align, BlackIs1, Columns, Rows); |
| 967 return pDecoder; | 1002 return pDecoder; |
| 968 } | 1003 } |
| OLD | NEW |