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 { | 10 { |
11 m_pBasicModule = FX_NEW CCodec_BasicModule; | 11 m_pBasicModule = FX_NEW CCodec_BasicModule; |
12 m_pFaxModule = FX_NEW CCodec_FaxModule; | 12 m_pFaxModule = FX_NEW CCodec_FaxModule; |
13 m_pJpegModule = FX_NEW CCodec_JpegModule; | 13 m_pJpegModule = FX_NEW CCodec_JpegModule; |
14 m_pJpxModule = FX_NEW CCodec_JpxModule; | 14 m_pJpxModule = FX_NEW CCodec_JpxModule; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 dest_height = -dest_height; | 112 dest_height = -dest_height; |
113 } | 113 } |
114 v_DownScale(dest_width, dest_height); | 114 v_DownScale(dest_width, dest_height); |
115 if (m_pDataCache) { | 115 if (m_pDataCache) { |
116 if (m_pDataCache->m_Height == m_OutputHeight && m_pDataCache->m_Width ==
m_OutputWidth) { | 116 if (m_pDataCache->m_Height == m_OutputHeight && m_pDataCache->m_Width ==
m_OutputWidth) { |
117 return; | 117 return; |
118 } | 118 } |
119 FX_Free(m_pDataCache); | 119 FX_Free(m_pDataCache); |
120 m_pDataCache = NULL; | 120 m_pDataCache = NULL; |
121 } | 121 } |
122 m_pDataCache = (CCodec_ImageDataCache*)FXMEM_DefaultAlloc( | 122 m_pDataCache = (CCodec_ImageDataCache*)FX_AllocNL(FX_BYTE, sizeof(CCodec_Ima
geDataCache) + m_Pitch * m_OutputHeight); |
123 sizeof(CCodec_ImageDataCache) + m_Pitch * m_OutputHeight,
FXMEM_NONLEAVE); | |
124 if (m_pDataCache == NULL) { | 123 if (m_pDataCache == NULL) { |
125 return; | 124 return; |
126 } | 125 } |
127 m_pDataCache->m_Height = m_OutputHeight; | 126 m_pDataCache->m_Height = m_OutputHeight; |
128 m_pDataCache->m_Width = m_OutputWidth; | 127 m_pDataCache->m_Width = m_OutputWidth; |
129 m_pDataCache->m_nCachedLines = 0; | 128 m_pDataCache->m_nCachedLines = 0; |
130 } | 129 } |
131 FX_BOOL CCodec_BasicModule::RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src
_size, FX_LPBYTE& dest_buf, | 130 FX_BOOL CCodec_BasicModule::RunLengthEncode(const FX_BYTE* src_buf, FX_DWORD src
_size, FX_LPBYTE& dest_buf, |
132 FX_DWORD& dest_size) | 131 FX_DWORD& dest_size) |
133 { | 132 { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 m_nComps = nComps; | 329 m_nComps = nComps; |
331 m_bpc = bpc; | 330 m_bpc = bpc; |
332 m_bColorTransformed = FALSE; | 331 m_bColorTransformed = FALSE; |
333 m_DownScale = 1; | 332 m_DownScale = 1; |
334 m_Pitch = (width * nComps * bpc + 31) / 32 * 4; | 333 m_Pitch = (width * nComps * bpc + 31) / 32 * 4; |
335 m_dwLineBytes = (width * nComps * bpc + 7) / 8; | 334 m_dwLineBytes = (width * nComps * bpc + 7) / 8; |
336 m_pScanline = FX_Alloc(FX_BYTE, m_Pitch); | 335 m_pScanline = FX_Alloc(FX_BYTE, m_Pitch); |
337 if (m_pScanline == NULL) { | 336 if (m_pScanline == NULL) { |
338 return FALSE; | 337 return FALSE; |
339 } | 338 } |
340 FXSYS_memset32(m_pScanline, 0, m_Pitch); | |
341 return CheckDestSize(); | 339 return CheckDestSize(); |
342 } | 340 } |
343 FX_BOOL CCodec_RLScanlineDecoder::v_Rewind() | 341 FX_BOOL CCodec_RLScanlineDecoder::v_Rewind() |
344 { | 342 { |
345 FXSYS_memset32(m_pScanline, 0, m_Pitch); | 343 FXSYS_memset32(m_pScanline, 0, m_Pitch); |
346 m_SrcOffset = 0; | 344 m_SrcOffset = 0; |
347 m_bEOD = FALSE; | 345 m_bEOD = FALSE; |
348 m_Operator = 0; | 346 m_Operator = 0; |
349 return TRUE; | 347 return TRUE; |
350 } | 348 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 CCodec_RLScanlineDecoder* pRLScanlineDecoder = FX_NEW CCodec_RLScanlineDecod
er; | 436 CCodec_RLScanlineDecoder* pRLScanlineDecoder = FX_NEW CCodec_RLScanlineDecod
er; |
439 if (pRLScanlineDecoder == NULL) { | 437 if (pRLScanlineDecoder == NULL) { |
440 return NULL; | 438 return NULL; |
441 } | 439 } |
442 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bp
c)) { | 440 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bp
c)) { |
443 delete pRLScanlineDecoder; | 441 delete pRLScanlineDecoder; |
444 return NULL; | 442 return NULL; |
445 } | 443 } |
446 return pRLScanlineDecoder; | 444 return pRLScanlineDecoder; |
447 } | 445 } |
OLD | NEW |