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 CCodec_ModuleMgr::CCodec_ModuleMgr() | 9 CCodec_ModuleMgr::CCodec_ModuleMgr() |
10 : m_pBasicModule(new CCodec_BasicModule), | 10 : m_pBasicModule(new CCodec_BasicModule), |
11 m_pFaxModule(new CCodec_FaxModule), | 11 m_pFaxModule(new CCodec_FaxModule), |
12 m_pJpegModule(new CCodec_JpegModule), | 12 m_pJpegModule(new CCodec_JpegModule), |
13 m_pJpxModule(new CCodec_JpxModule), | 13 m_pJpxModule(new CCodec_JpxModule), |
14 m_pJbig2Module(new CCodec_Jbig2Module), | 14 m_pJbig2Module(new CCodec_Jbig2Module), |
15 m_pIccModule(new CCodec_IccModule), | 15 m_pIccModule(new CCodec_IccModule), |
16 m_pFlateModule(new CCodec_FlateModule) {} | 16 m_pFlateModule(new CCodec_FlateModule) {} |
17 CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() { | 17 CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() { |
18 m_NextLine = -1; | 18 m_NextLine = -1; |
19 m_pDataCache = NULL; | 19 m_pDataCache = NULL; |
20 m_pLastScanline = NULL; | 20 m_pLastScanline = NULL; |
21 } | 21 } |
22 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() { | 22 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() { |
23 if (m_pDataCache) { | |
24 FX_Free(m_pDataCache); | 23 FX_Free(m_pDataCache); |
25 } | |
26 } | 24 } |
27 uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { | 25 uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { |
28 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) { | 26 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) { |
29 return &m_pDataCache->m_Data + line * m_Pitch; | 27 return &m_pDataCache->m_Data + line * m_Pitch; |
30 } | 28 } |
31 if (m_NextLine == line + 1) { | 29 if (m_NextLine == line + 1) { |
32 return m_pLastScanline; | 30 return m_pLastScanline; |
33 } | 31 } |
34 if (m_NextLine < 0 || m_NextLine > line) { | 32 if (m_NextLine < 0 || m_NextLine > line) { |
35 if (!v_Rewind()) { | 33 if (!v_Rewind()) { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 }; | 242 }; |
245 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() | 243 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() |
246 : m_pScanline(NULL), | 244 : m_pScanline(NULL), |
247 m_pSrcBuf(NULL), | 245 m_pSrcBuf(NULL), |
248 m_SrcSize(0), | 246 m_SrcSize(0), |
249 m_dwLineBytes(0), | 247 m_dwLineBytes(0), |
250 m_SrcOffset(0), | 248 m_SrcOffset(0), |
251 m_bEOD(FALSE), | 249 m_bEOD(FALSE), |
252 m_Operator(0) {} | 250 m_Operator(0) {} |
253 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { | 251 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { |
254 if (m_pScanline) { | |
255 FX_Free(m_pScanline); | 252 FX_Free(m_pScanline); |
256 } | |
257 } | 253 } |
258 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { | 254 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { |
259 FX_DWORD i = 0; | 255 FX_DWORD i = 0; |
260 FX_DWORD old_size = 0; | 256 FX_DWORD old_size = 0; |
261 FX_DWORD dest_size = 0; | 257 FX_DWORD dest_size = 0; |
262 while (i < m_SrcSize) { | 258 while (i < m_SrcSize) { |
263 if (m_pSrcBuf[i] < 128) { | 259 if (m_pSrcBuf[i] < 128) { |
264 old_size = dest_size; | 260 old_size = dest_size; |
265 dest_size += m_pSrcBuf[i] + 1; | 261 dest_size += m_pSrcBuf[i] + 1; |
266 if (dest_size < old_size) { | 262 if (dest_size < old_size) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 int nComps, | 395 int nComps, |
400 int bpc) { | 396 int bpc) { |
401 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; | 397 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; |
402 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 398 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
403 bpc)) { | 399 bpc)) { |
404 delete pRLScanlineDecoder; | 400 delete pRLScanlineDecoder; |
405 return NULL; | 401 return NULL; |
406 } | 402 } |
407 return pRLScanlineDecoder; | 403 return pRLScanlineDecoder; |
408 } | 404 } |
OLD | NEW |