Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_fax.cpp

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/codec/fx_codec_flate.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
625 m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch); 628 m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch);
629 if (m_pRefBuf == NULL) {
630 return FALSE;
631 }
626 m_pSrcBuf = src_buf; 632 m_pSrcBuf = src_buf;
627 m_SrcSize = src_size; 633 m_SrcSize = src_size;
628 m_nComps = 1; 634 m_nComps = 1;
629 m_bpc = 1; 635 m_bpc = 1;
630 m_bColorTransformed = FALSE; 636 m_bColorTransformed = FALSE;
631 return TRUE; 637 return TRUE;
632 } 638 }
633 FX_BOOL CCodec_FaxDecoder::v_Rewind() 639 FX_BOOL CCodec_FaxDecoder::v_Rewind()
634 { 640 {
635 FXSYS_memset8(m_pRefBuf, 0xff, m_Pitch); 641 FXSYS_memset8(m_pRefBuf, 0xff, m_Pitch);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 } 698 }
693 return ret; 699 return ret;
694 } 700 }
695 extern "C" { 701 extern "C" {
696 void _FaxG4Decode(void*, FX_LPCBYTE src_buf, FX_DWORD src_size, int* pbitpos , FX_LPBYTE dest_buf, int width, int height, int pitch) 702 void _FaxG4Decode(void*, FX_LPCBYTE src_buf, FX_DWORD src_size, int* pbitpos , FX_LPBYTE dest_buf, int width, int height, int pitch)
697 { 703 {
698 if (pitch == 0) { 704 if (pitch == 0) {
699 pitch = (width + 7) / 8; 705 pitch = (width + 7) / 8;
700 } 706 }
701 FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch); 707 FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch);
708 if (ref_buf == NULL) {
709 return;
710 }
702 FXSYS_memset8(ref_buf, 0xff, pitch); 711 FXSYS_memset8(ref_buf, 0xff, pitch);
703 int bitpos = *pbitpos; 712 int bitpos = *pbitpos;
704 for (int iRow = 0; iRow < height; iRow ++) { 713 for (int iRow = 0; iRow < height; iRow ++) {
705 FX_LPBYTE line_buf = dest_buf + iRow * pitch; 714 FX_LPBYTE line_buf = dest_buf + iRow * pitch;
706 FXSYS_memset8(line_buf, 0xff, pitch); 715 FXSYS_memset8(line_buf, 0xff, pitch);
707 _FaxG4GetRow(src_buf, src_size << 3, bitpos, line_buf, ref_buf, widt h); 716 _FaxG4GetRow(src_buf, src_size << 3, bitpos, line_buf, ref_buf, widt h);
708 FXSYS_memcpy32(ref_buf, line_buf, pitch); 717 FXSYS_memcpy32(ref_buf, line_buf, pitch);
709 } 718 }
710 FX_Free(ref_buf); 719 FX_Free(ref_buf);
711 *pbitpos = bitpos; 720 *pbitpos = bitpos;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 int m_Cols, m_Rows, m_Pitch; 938 int m_Cols, m_Rows, m_Pitch;
930 FX_LPCBYTE m_pSrcBuf; 939 FX_LPCBYTE m_pSrcBuf;
931 }; 940 };
932 CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height, int pitch) 941 CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height, int pitch)
933 { 942 {
934 m_pSrcBuf = src_buf; 943 m_pSrcBuf = src_buf;
935 m_Cols = width; 944 m_Cols = width;
936 m_Rows = height; 945 m_Rows = height;
937 m_Pitch = pitch; 946 m_Pitch = pitch;
938 m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch); 947 m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch);
948 if (m_pRefLine == NULL) {
949 return;
950 }
939 FXSYS_memset8(m_pRefLine, 0xff, m_Pitch); 951 FXSYS_memset8(m_pRefLine, 0xff, m_Pitch);
940 m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8); 952 m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8);
941 m_DestBuf.EstimateSize(0, 10240); 953 m_DestBuf.EstimateSize(0, 10240);
942 } 954 }
943 CCodec_FaxEncoder::~CCodec_FaxEncoder() 955 CCodec_FaxEncoder::~CCodec_FaxEncoder()
944 { 956 {
945 if (m_pRefLine) { 957 if (m_pRefLine) {
946 FX_Free(m_pRefLine); 958 FX_Free(m_pRefLine);
947 } 959 }
948 if (m_pLineBuf) { 960 if (m_pLineBuf) {
(...skipping 27 matching lines...) Expand all
976 encoder.Encode(dest_buf, dest_size); 988 encoder.Encode(dest_buf, dest_size);
977 return TRUE; 989 return TRUE;
978 } 990 }
979 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D WORD src_size, int width, int height, 991 ICodec_ScanlineDecoder* CCodec_FaxModule::CreateDecoder(FX_LPCBYTE src_buf, FX_D WORD src_size, int width, int height,
980 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in t Columns, int Rows) 992 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1, in t Columns, int Rows)
981 { 993 {
982 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; 994 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder;
983 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte Align, BlackIs1, Columns, Rows); 995 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, EncodedByte Align, BlackIs1, Columns, Rows);
984 return pDecoder; 996 return pDecoder;
985 } 997 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec.cpp ('k') | core/src/fxcodec/codec/fx_codec_flate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698