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 const FX_BYTE OneLeadPos[256] = { | 9 const FX_BYTE OneLeadPos[256] = { |
10 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, | 10 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 if (m_OrigWidth == 0) { | 615 if (m_OrigWidth == 0) { |
616 m_OrigWidth = width; | 616 m_OrigWidth = width; |
617 } | 617 } |
618 if (m_OrigHeight == 0) { | 618 if (m_OrigHeight == 0) { |
619 m_OrigHeight = height; | 619 m_OrigHeight = height; |
620 } | 620 } |
621 m_Pitch = (m_OrigWidth + 31) / 32 * 4; | 621 m_Pitch = (m_OrigWidth + 31) / 32 * 4; |
622 m_OutputWidth = m_OrigWidth; | 622 m_OutputWidth = m_OrigWidth; |
623 m_OutputHeight = m_OrigHeight; | 623 m_OutputHeight = m_OrigHeight; |
624 m_pScanlineBuf = FX_Alloc(FX_BYTE, m_Pitch); | 624 m_pScanlineBuf = FX_Alloc(FX_BYTE, m_Pitch); |
625 if (m_pScanlineBuf == NULL) { | |
626 return FALSE; | |
627 } | |
628 m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch); | 625 m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch); |
629 if (m_pRefBuf == NULL) { | |
630 return FALSE; | |
631 } | |
632 m_pSrcBuf = src_buf; | 626 m_pSrcBuf = src_buf; |
633 m_SrcSize = src_size; | 627 m_SrcSize = src_size; |
634 m_nComps = 1; | 628 m_nComps = 1; |
635 m_bpc = 1; | 629 m_bpc = 1; |
636 m_bColorTransformed = FALSE; | 630 m_bColorTransformed = FALSE; |
637 return TRUE; | 631 return TRUE; |
638 } | 632 } |
639 FX_BOOL CCodec_FaxDecoder::v_Rewind() | 633 FX_BOOL CCodec_FaxDecoder::v_Rewind() |
640 { | 634 { |
641 FXSYS_memset8(m_pRefBuf, 0xff, m_Pitch); | 635 FXSYS_memset8(m_pRefBuf, 0xff, m_Pitch); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 692 } |
699 return ret; | 693 return ret; |
700 } | 694 } |
701 extern "C" { | 695 extern "C" { |
702 void _FaxG4Decode(void*, FX_LPCBYTE src_buf, FX_DWORD src_size, int* pbitpos
, FX_LPBYTE dest_buf, int width, int height, int pitch) | 696 void _FaxG4Decode(void*, FX_LPCBYTE src_buf, FX_DWORD src_size, int* pbitpos
, FX_LPBYTE dest_buf, int width, int height, int pitch) |
703 { | 697 { |
704 if (pitch == 0) { | 698 if (pitch == 0) { |
705 pitch = (width + 7) / 8; | 699 pitch = (width + 7) / 8; |
706 } | 700 } |
707 FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch); | 701 FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch); |
708 if (ref_buf == NULL) { | |
709 return; | |
710 } | |
711 FXSYS_memset8(ref_buf, 0xff, pitch); | 702 FXSYS_memset8(ref_buf, 0xff, pitch); |
712 int bitpos = *pbitpos; | 703 int bitpos = *pbitpos; |
713 for (int iRow = 0; iRow < height; iRow ++) { | 704 for (int iRow = 0; iRow < height; iRow ++) { |
714 FX_LPBYTE line_buf = dest_buf + iRow * pitch; | 705 FX_LPBYTE line_buf = dest_buf + iRow * pitch; |
715 FXSYS_memset8(line_buf, 0xff, pitch); | 706 FXSYS_memset8(line_buf, 0xff, pitch); |
716 _FaxG4GetRow(src_buf, src_size << 3, bitpos, line_buf, ref_buf, widt
h); | 707 _FaxG4GetRow(src_buf, src_size << 3, bitpos, line_buf, ref_buf, widt
h); |
717 FXSYS_memcpy32(ref_buf, line_buf, pitch); | 708 FXSYS_memcpy32(ref_buf, line_buf, pitch); |
718 } | 709 } |
719 FX_Free(ref_buf); | 710 FX_Free(ref_buf); |
720 *pbitpos = bitpos; | 711 *pbitpos = bitpos; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 int m_Cols, m_Rows, m_Pitch; | 929 int m_Cols, m_Rows, m_Pitch; |
939 FX_LPCBYTE m_pSrcBuf; | 930 FX_LPCBYTE m_pSrcBuf; |
940 }; | 931 }; |
941 CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height,
int pitch) | 932 CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height,
int pitch) |
942 { | 933 { |
943 m_pSrcBuf = src_buf; | 934 m_pSrcBuf = src_buf; |
944 m_Cols = width; | 935 m_Cols = width; |
945 m_Rows = height; | 936 m_Rows = height; |
946 m_Pitch = pitch; | 937 m_Pitch = pitch; |
947 m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch); | 938 m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch); |
948 if (m_pRefLine == NULL) { | |
949 return; | |
950 } | |
951 FXSYS_memset8(m_pRefLine, 0xff, m_Pitch); | 939 FXSYS_memset8(m_pRefLine, 0xff, m_Pitch); |
952 m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8); | 940 m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8); |
953 m_DestBuf.EstimateSize(0, 10240); | 941 m_DestBuf.EstimateSize(0, 10240); |
954 } | 942 } |
955 CCodec_FaxEncoder::~CCodec_FaxEncoder() | 943 CCodec_FaxEncoder::~CCodec_FaxEncoder() |
956 { | 944 { |
957 if (m_pRefLine) { | 945 if (m_pRefLine) { |
958 FX_Free(m_pRefLine); | 946 FX_Free(m_pRefLine); |
959 } | 947 } |
960 if (m_pLineBuf) { | 948 if (m_pLineBuf) { |
(...skipping 27 matching lines...) Expand all Loading... |
988 encoder.Encode(dest_buf, dest_size); | 976 encoder.Encode(dest_buf, dest_size); |
989 return TRUE; | 977 return TRUE; |
990 } | 978 } |
991 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D
WORD src_size, int width, int height, | 979 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D
WORD src_size, int width, int height, |
992 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in
t Columns, int Rows) | 980 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in
t Columns, int Rows) |
993 { | 981 { |
994 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; | 982 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; |
995 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte
Align, BlackIs1, Columns, Rows); | 983 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte
Align, BlackIs1, Columns, Rows); |
996 return pDecoder; | 984 return pDecoder; |
997 } | 985 } |
OLD | NEW |