| 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 "codec_int.h" | 7 #include "codec_int.h" |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 m_bByteAlign = EncodedByteAlign; | 649 m_bByteAlign = EncodedByteAlign; |
| 650 m_bBlack = BlackIs1; | 650 m_bBlack = BlackIs1; |
| 651 m_OrigWidth = Columns; | 651 m_OrigWidth = Columns; |
| 652 m_OrigHeight = Rows; | 652 m_OrigHeight = Rows; |
| 653 if (m_OrigWidth == 0) { | 653 if (m_OrigWidth == 0) { |
| 654 m_OrigWidth = width; | 654 m_OrigWidth = width; |
| 655 } | 655 } |
| 656 if (m_OrigHeight == 0) { | 656 if (m_OrigHeight == 0) { |
| 657 m_OrigHeight = height; | 657 m_OrigHeight = height; |
| 658 } | 658 } |
| 659 m_Pitch = (m_OrigWidth + 31) / 32 * 4; | 659 // Should not overflow. Checked by FPDFAPI_CreateFaxDecoder. |
| 660 m_Pitch = (static_cast<FX_DWORD>(m_OrigWidth) + 31) / 32 * 4; |
| 660 m_OutputWidth = m_OrigWidth; | 661 m_OutputWidth = m_OrigWidth; |
| 661 m_OutputHeight = m_OrigHeight; | 662 m_OutputHeight = m_OrigHeight; |
| 662 m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); | 663 m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); |
| 663 m_pRefBuf = FX_Alloc(uint8_t, m_Pitch); | 664 m_pRefBuf = FX_Alloc(uint8_t, m_Pitch); |
| 664 m_pSrcBuf = src_buf; | 665 m_pSrcBuf = src_buf; |
| 665 m_SrcSize = src_size; | 666 m_SrcSize = src_size; |
| 666 m_nComps = 1; | 667 m_nComps = 1; |
| 667 m_bpc = 1; | 668 m_bpc = 1; |
| 668 m_bColorTransformed = FALSE; | 669 m_bColorTransformed = FALSE; |
| 669 return TRUE; | 670 return TRUE; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 m_bByteAlign = FALSE; | 710 m_bByteAlign = FALSE; |
| 710 } else { | 711 } else { |
| 711 bitpos0++; | 712 bitpos0++; |
| 712 } | 713 } |
| 713 } | 714 } |
| 714 if (m_bByteAlign) { | 715 if (m_bByteAlign) { |
| 715 bitpos = bitpos1; | 716 bitpos = bitpos1; |
| 716 } | 717 } |
| 717 } | 718 } |
| 718 if (m_bBlack) { | 719 if (m_bBlack) { |
| 719 for (int i = 0; i < m_Pitch; i++) { | 720 for (FX_DWORD i = 0; i < m_Pitch; i++) { |
| 720 m_pScanlineBuf[i] = ~m_pScanlineBuf[i]; | 721 m_pScanlineBuf[i] = ~m_pScanlineBuf[i]; |
| 721 } | 722 } |
| 722 } | 723 } |
| 723 return m_pScanlineBuf; | 724 return m_pScanlineBuf; |
| 724 } | 725 } |
| 725 FX_DWORD CCodec_FaxDecoder::GetSrcOffset() { | 726 FX_DWORD CCodec_FaxDecoder::GetSrcOffset() { |
| 726 FX_DWORD ret = (bitpos + 7) / 8; | 727 FX_DWORD ret = (bitpos + 7) / 8; |
| 727 if (ret > m_SrcSize) { | 728 if (ret > m_SrcSize) { |
| 728 ret = m_SrcSize; | 729 ret = m_SrcSize; |
| 729 } | 730 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 FX_BOOL EndOfLine, | 822 FX_BOOL EndOfLine, |
| 822 FX_BOOL EncodedByteAlign, | 823 FX_BOOL EncodedByteAlign, |
| 823 FX_BOOL BlackIs1, | 824 FX_BOOL BlackIs1, |
| 824 int Columns, | 825 int Columns, |
| 825 int Rows) { | 826 int Rows) { |
| 826 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; | 827 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; |
| 827 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, | 828 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, |
| 828 EncodedByteAlign, BlackIs1, Columns, Rows); | 829 EncodedByteAlign, BlackIs1, Columns, Rows); |
| 829 return pDecoder; | 830 return pDecoder; |
| 830 } | 831 } |
| OLD | NEW |