OLD | NEW |
1 | 1 |
2 // Copyright 2014 PDFium Authors. All rights reserved. | 2 // Copyright 2014 PDFium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 6 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
7 | 7 |
8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
11 | 11 |
12 #include "codec_int.h" | 12 #include "codec_int.h" |
13 #include "core/include/fxcrt/fx_ext.h" | 13 #include "core/include/fxcrt/fx_ext.h" |
14 #include "core/include/fxcrt/fx_safe_types.h" | 14 #include "core/include/fxcrt/fx_safe_types.h" |
15 #include "third_party/base/logging.h" | 15 #include "third_party/base/logging.h" |
16 | 16 |
17 CCodec_ModuleMgr::CCodec_ModuleMgr() | 17 CCodec_ModuleMgr::CCodec_ModuleMgr() |
18 : m_pBasicModule(new CCodec_BasicModule), | 18 : m_pBasicModule(new CCodec_BasicModule), |
19 m_pFaxModule(new CCodec_FaxModule), | 19 m_pFaxModule(new CCodec_FaxModule), |
20 m_pJpegModule(new CCodec_JpegModule), | 20 m_pJpegModule(new CCodec_JpegModule), |
21 m_pJpxModule(new CCodec_JpxModule), | 21 m_pJpxModule(new CCodec_JpxModule), |
22 m_pJbig2Module(new CCodec_Jbig2Module), | 22 m_pJbig2Module(new CCodec_Jbig2Module), |
23 m_pIccModule(new CCodec_IccModule), | 23 m_pIccModule(new CCodec_IccModule), |
24 #ifndef PDF_ENABLE_XFA | 24 #ifdef PDF_ENABLE_XFA |
25 m_pFlateModule(new CCodec_FlateModule) { | |
26 } | |
27 #else | |
28 m_pFlateModule(new CCodec_FlateModule), | |
29 m_pPngModule(new CCodec_PngModule), | 25 m_pPngModule(new CCodec_PngModule), |
30 m_pGifModule(new CCodec_GifModule), | 26 m_pGifModule(new CCodec_GifModule), |
31 m_pBmpModule(new CCodec_BmpModule), | 27 m_pBmpModule(new CCodec_BmpModule), |
32 m_pTiffModule(new CCodec_TiffModule) { | 28 m_pTiffModule(new CCodec_TiffModule), |
| 29 #endif // PDF_ENABLE_XFA |
| 30 m_pFlateModule(new CCodec_FlateModule) { |
33 } | 31 } |
34 #endif | |
35 | 32 |
36 CCodec_ScanlineDecoder::ImageDataCache::ImageDataCache(int width, | 33 CCodec_ScanlineDecoder::ImageDataCache::ImageDataCache(int width, |
37 int height, | 34 int height, |
38 FX_DWORD pitch) | 35 FX_DWORD pitch) |
39 : m_Width(width), m_Height(height), m_Pitch(pitch), m_nCachedLines(0) {} | 36 : m_Width(width), m_Height(height), m_Pitch(pitch), m_nCachedLines(0) {} |
40 | 37 |
41 CCodec_ScanlineDecoder::ImageDataCache::~ImageDataCache() { | 38 CCodec_ScanlineDecoder::ImageDataCache::~ImageDataCache() { |
42 } | 39 } |
43 | 40 |
44 bool CCodec_ScanlineDecoder::ImageDataCache::AllocateCache() { | 41 bool CCodec_ScanlineDecoder::ImageDataCache::AllocateCache() { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 return is_negative ? -ret : ret; | 257 return is_negative ? -ret : ret; |
261 } | 258 } |
262 #undef EXPONENT_DETECT | 259 #undef EXPONENT_DETECT |
263 | 260 |
264 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, | 261 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, |
265 FX_DWORD src_size, | 262 FX_DWORD src_size, |
266 uint8_t*& dest_buf, | 263 uint8_t*& dest_buf, |
267 FX_DWORD& dest_size) { | 264 FX_DWORD& dest_size) { |
268 return FALSE; | 265 return FALSE; |
269 } | 266 } |
| 267 |
270 #ifdef PDF_ENABLE_XFA | 268 #ifdef PDF_ENABLE_XFA |
271 CFX_DIBAttribute::CFX_DIBAttribute() | 269 CFX_DIBAttribute::CFX_DIBAttribute() |
272 : m_nXDPI(-1), | 270 : m_nXDPI(-1), |
273 m_nYDPI(-1), | 271 m_nYDPI(-1), |
274 m_fAspectRatio(-1.0f), | 272 m_fAspectRatio(-1.0f), |
275 m_wDPIUnit(0), | 273 m_wDPIUnit(0), |
276 m_nGifLeft(0), | 274 m_nGifLeft(0), |
277 m_nGifTop(0), | 275 m_nGifTop(0), |
278 m_pGifLocalPalette(nullptr), | 276 m_pGifLocalPalette(nullptr), |
279 m_nGifLocalPalNum(0), | 277 m_nGifLocalPalNum(0), |
280 m_nBmpCompressType(0) { | 278 m_nBmpCompressType(0) { |
281 FXSYS_memset(m_strTime, 0, sizeof(m_strTime)); | 279 FXSYS_memset(m_strTime, 0, sizeof(m_strTime)); |
282 } | 280 } |
283 CFX_DIBAttribute::~CFX_DIBAttribute() { | 281 CFX_DIBAttribute::~CFX_DIBAttribute() { |
284 for (const auto& pair : m_Exif) | 282 for (const auto& pair : m_Exif) |
285 FX_Free(pair.second); | 283 FX_Free(pair.second); |
286 } | 284 } |
| 285 #endif // PDF_ENABLE_XFA |
287 | 286 |
288 #endif | |
289 class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { | 287 class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { |
290 public: | 288 public: |
291 CCodec_RLScanlineDecoder(); | 289 CCodec_RLScanlineDecoder(); |
292 ~CCodec_RLScanlineDecoder() override; | 290 ~CCodec_RLScanlineDecoder() override; |
293 | 291 |
294 FX_BOOL Create(const uint8_t* src_buf, | 292 FX_BOOL Create(const uint8_t* src_buf, |
295 FX_DWORD src_size, | 293 FX_DWORD src_size, |
296 int width, | 294 int width, |
297 int height, | 295 int height, |
298 int nComps, | 296 int nComps, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 int nComps, | 481 int nComps, |
484 int bpc) { | 482 int bpc) { |
485 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; | 483 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; |
486 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 484 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
487 bpc)) { | 485 bpc)) { |
488 delete pRLScanlineDecoder; | 486 delete pRLScanlineDecoder; |
489 return NULL; | 487 return NULL; |
490 } | 488 } |
491 return pRLScanlineDecoder; | 489 return pRLScanlineDecoder; |
492 } | 490 } |
OLD | NEW |