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 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 7 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
9 | 9 |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 13 matching lines...) Expand all Loading... | |
24 FX_DWORD src_size, | 24 FX_DWORD src_size, |
25 uint8_t*& dest_buf, | 25 uint8_t*& dest_buf, |
26 FX_DWORD& dest_size); | 26 FX_DWORD& dest_size); |
27 virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, | 27 virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf, |
28 FX_DWORD src_size, | 28 FX_DWORD src_size, |
29 int width, | 29 int width, |
30 int height, | 30 int height, |
31 int nComps, | 31 int nComps, |
32 int bpc); | 32 int bpc); |
33 }; | 33 }; |
34 | |
34 struct CCodec_ImageDataCache { | 35 struct CCodec_ImageDataCache { |
35 int m_Width, m_Height; | 36 int m_Width, m_Height; |
36 int m_nCachedLines; | 37 int m_nCachedLines; |
37 uint8_t m_Data; | 38 uint8_t m_Data; |
38 }; | 39 }; |
40 | |
39 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { | 41 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { |
40 public: | 42 public: |
41 CCodec_ScanlineDecoder(); | 43 CCodec_ScanlineDecoder(); |
44 ~CCodec_ScanlineDecoder() override; | |
42 | 45 |
43 virtual ~CCodec_ScanlineDecoder(); | 46 // ICodec_ScanlineDecoder |
44 | 47 FX_DWORD GetSrcOffset() override { return -1; } |
45 virtual FX_DWORD GetSrcOffset() { return -1; } | 48 void DownScale(int dest_width, int dest_height) override; |
46 | 49 uint8_t* GetScanline(int line) override; |
47 virtual void DownScale(int dest_width, int dest_height); | 50 FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override; |
48 | 51 int GetWidth() override { return m_OutputWidth; } |
49 uint8_t* GetScanline(int line); | 52 int GetHeight() override { return m_OutputHeight; } |
50 | 53 int CountComps() override { return m_nComps; } |
51 FX_BOOL SkipToScanline(int line, IFX_Pause* pPause); | 54 int GetBPC() override { return m_bpc; } |
52 | 55 FX_BOOL IsColorTransformed() override { return m_bColorTransformed; } |
53 int GetWidth() { return m_OutputWidth; } | 56 void ClearImageData() override { |
54 | |
55 int GetHeight() { return m_OutputHeight; } | |
56 | |
57 int CountComps() { return m_nComps; } | |
58 | |
59 int GetBPC() { return m_bpc; } | |
60 | |
61 FX_BOOL IsColorTransformed() { return m_bColorTransformed; } | |
62 | |
63 void ClearImageData() { | |
64 if (m_pDataCache) { | 57 if (m_pDataCache) { |
65 FX_Free(m_pDataCache); | 58 FX_Free(m_pDataCache); |
66 } | 59 } |
67 m_pDataCache = NULL; | 60 m_pDataCache = NULL; |
68 } | 61 } |
69 | 62 |
70 protected: | 63 protected: |
71 int m_OrigWidth; | 64 int m_OrigWidth; |
72 | 65 |
73 int m_OrigHeight; | 66 int m_OrigHeight; |
(...skipping 19 matching lines...) Expand all Loading... | |
93 virtual uint8_t* v_GetNextLine() = 0; | 86 virtual uint8_t* v_GetNextLine() = 0; |
94 | 87 |
95 virtual void v_DownScale(int dest_width, int dest_height) = 0; | 88 virtual void v_DownScale(int dest_width, int dest_height) = 0; |
96 | 89 |
97 int m_NextLine; | 90 int m_NextLine; |
98 | 91 |
99 uint8_t* m_pLastScanline; | 92 uint8_t* m_pLastScanline; |
100 | 93 |
101 CCodec_ImageDataCache* m_pDataCache; | 94 CCodec_ImageDataCache* m_pDataCache; |
102 }; | 95 }; |
96 | |
103 class CCodec_FaxModule : public ICodec_FaxModule { | 97 class CCodec_FaxModule : public ICodec_FaxModule { |
104 public: | 98 public: |
105 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, | 99 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, |
106 FX_DWORD src_size, | 100 FX_DWORD src_size, |
107 int width, | 101 int width, |
108 int height, | 102 int height, |
109 int K, | 103 int K, |
110 FX_BOOL EndOfLine, | 104 FX_BOOL EndOfLine, |
111 FX_BOOL EncodedByteAlign, | 105 FX_BOOL EncodedByteAlign, |
112 FX_BOOL BlackIs1, | 106 FX_BOOL BlackIs1, |
113 int Columns, | 107 int Columns, |
114 int Rows); | 108 int Rows); |
115 FX_BOOL Encode(const uint8_t* src_buf, | 109 FX_BOOL Encode(const uint8_t* src_buf, |
116 int width, | 110 int width, |
117 int height, | 111 int height, |
118 int pitch, | 112 int pitch, |
119 uint8_t*& dest_buf, | 113 uint8_t*& dest_buf, |
120 FX_DWORD& dest_size); | 114 FX_DWORD& dest_size); |
121 }; | 115 }; |
116 | |
122 class CCodec_FlateModule : public ICodec_FlateModule { | 117 class CCodec_FlateModule : public ICodec_FlateModule { |
123 public: | 118 public: |
124 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, | 119 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, |
125 FX_DWORD src_size, | 120 FX_DWORD src_size, |
126 int width, | 121 int width, |
127 int height, | 122 int height, |
128 int nComps, | 123 int nComps, |
129 int bpc, | 124 int bpc, |
130 int predictor, | 125 int predictor, |
131 int Colors, | 126 int Colors, |
(...skipping 16 matching lines...) Expand all Loading... | |
148 int Colors, | 143 int Colors, |
149 int BitsPerComponent, | 144 int BitsPerComponent, |
150 int Columns, | 145 int Columns, |
151 uint8_t*& dest_buf, | 146 uint8_t*& dest_buf, |
152 FX_DWORD& dest_size); | 147 FX_DWORD& dest_size); |
153 virtual FX_BOOL Encode(const uint8_t* src_buf, | 148 virtual FX_BOOL Encode(const uint8_t* src_buf, |
154 FX_DWORD src_size, | 149 FX_DWORD src_size, |
155 uint8_t*& dest_buf, | 150 uint8_t*& dest_buf, |
156 FX_DWORD& dest_size); | 151 FX_DWORD& dest_size); |
157 }; | 152 }; |
153 | |
158 class CCodec_JpegModule : public ICodec_JpegModule { | 154 class CCodec_JpegModule : public ICodec_JpegModule { |
159 public: | 155 public: |
160 CCodec_JpegModule() : m_pExtProvider(NULL) {} | 156 CCodec_JpegModule() : m_pExtProvider(NULL) {} |
161 void SetPovider(IFX_JpegProvider* pJP) { m_pExtProvider = pJP; } | 157 void SetPovider(IFX_JpegProvider* pJP) { m_pExtProvider = pJP; } |
162 ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, | 158 ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, |
163 FX_DWORD src_size, | 159 FX_DWORD src_size, |
164 int width, | 160 int width, |
165 int height, | 161 int height, |
166 int nComps, | 162 int nComps, |
167 FX_BOOL ColorTransform); | 163 FX_BOOL ColorTransform); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 typedef enum { | 297 typedef enum { |
302 Icc_CLASS_INPUT = 0, | 298 Icc_CLASS_INPUT = 0, |
303 Icc_CLASS_OUTPUT, | 299 Icc_CLASS_OUTPUT, |
304 Icc_CLASS_PROOF, | 300 Icc_CLASS_PROOF, |
305 Icc_CLASS_MAX | 301 Icc_CLASS_MAX |
306 } Icc_CLASS; | 302 } Icc_CLASS; |
307 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, | 303 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
308 Icc_CLASS ic, | 304 Icc_CLASS ic, |
309 CFX_BinaryBuf* pTransformKey); | 305 CFX_BinaryBuf* pTransformKey); |
310 }; | 306 }; |
307 | |
311 class CCodec_JpxModule : public ICodec_JpxModule { | 308 class CCodec_JpxModule : public ICodec_JpxModule { |
312 public: | 309 public: |
313 CCodec_JpxModule(); | 310 CCodec_JpxModule(); |
314 void* CreateDecoder(const uint8_t* src_buf, | 311 void* CreateDecoder(const uint8_t* src_buf, |
315 FX_DWORD src_size, | 312 FX_DWORD src_size, |
316 FX_BOOL useColorSpace = FALSE); | 313 FX_BOOL useColorSpace = FALSE); |
317 void GetImageInfo(void* ctx, | 314 void GetImageInfo(void* ctx, |
318 FX_DWORD& width, | 315 FX_DWORD& width, |
319 FX_DWORD& height, | 316 FX_DWORD& height, |
320 FX_DWORD& codestream_nComps, | 317 FX_DWORD& codestream_nComps, |
321 FX_DWORD& output_nComps); | 318 FX_DWORD& output_nComps); |
322 FX_BOOL Decode(void* ctx, | 319 FX_BOOL Decode(void* ctx, |
323 uint8_t* dest_data, | 320 uint8_t* dest_data, |
324 int pitch, | 321 int pitch, |
325 FX_BOOL bTranslateColor, | 322 FX_BOOL bTranslateColor, |
326 uint8_t* offsets); | 323 uint8_t* offsets); |
327 void DestroyDecoder(void* ctx); | 324 void DestroyDecoder(void* ctx); |
328 }; | 325 }; |
326 | |
329 class CCodec_TiffModule : public ICodec_TiffModule { | 327 class CCodec_TiffModule : public ICodec_TiffModule { |
Lei Zhang
2015/08/15 04:49:07
This is new in XFA.
| |
330 public: | 328 public: |
331 virtual void* CreateDecoder(IFX_FileRead* file_ptr); | 329 // ICodec_TiffModule |
332 virtual void GetFrames(void* ctx, int32_t& frames); | 330 void* CreateDecoder(IFX_FileRead* file_ptr) override; |
333 virtual FX_BOOL LoadFrameInfo(void* ctx, | 331 void GetFrames(void* ctx, int32_t& frames) override; |
334 int32_t frame, | 332 FX_BOOL LoadFrameInfo(void* ctx, |
335 FX_DWORD& width, | 333 int32_t frame, |
336 FX_DWORD& height, | 334 FX_DWORD& width, |
337 FX_DWORD& comps, | 335 FX_DWORD& height, |
338 FX_DWORD& bpc, | 336 FX_DWORD& comps, |
339 CFX_DIBAttribute* pAttribute = NULL); | 337 FX_DWORD& bpc, |
340 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap); | 338 CFX_DIBAttribute* pAttribute = NULL) override; |
341 virtual void DestroyDecoder(void* ctx); | 339 FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override; |
340 void DestroyDecoder(void* ctx) override; | |
341 | |
342 protected: | |
343 ~CCodec_TiffModule() override {} | |
342 }; | 344 }; |
345 | |
343 class CPDF_Jbig2Interface : public CJBig2_Module { | 346 class CPDF_Jbig2Interface : public CJBig2_Module { |
344 public: | 347 public: |
345 virtual void* JBig2_Malloc(FX_DWORD dwSize) { | 348 virtual void* JBig2_Malloc(FX_DWORD dwSize) { |
346 return FX_Alloc(uint8_t, dwSize); | 349 return FX_Alloc(uint8_t, dwSize); |
347 } | 350 } |
348 virtual void* JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize) { | 351 virtual void* JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize) { |
349 if (dwSize && num >= UINT_MAX / dwSize) { | 352 if (dwSize && num >= UINT_MAX / dwSize) { |
350 return NULL; | 353 return NULL; |
351 } | 354 } |
352 return FX_Alloc(uint8_t, num * dwSize); | 355 return FX_Alloc(uint8_t, num * dwSize); |
353 } | 356 } |
354 virtual void* JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2) { | 357 virtual void* JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2) { |
355 if (dwSize2 && dwSize >= UINT_MAX / dwSize2) { | 358 if (dwSize2 && dwSize >= UINT_MAX / dwSize2) { |
356 return NULL; | 359 return NULL; |
357 } | 360 } |
358 FX_DWORD size = dwSize2 * dwSize; | 361 FX_DWORD size = dwSize2 * dwSize; |
359 if (size && num >= UINT_MAX / size) { | 362 if (size && num >= UINT_MAX / size) { |
360 return NULL; | 363 return NULL; |
361 } | 364 } |
362 return FX_Alloc(uint8_t, num * size); | 365 return FX_Alloc(uint8_t, num * size); |
363 } | 366 } |
364 virtual void* JBig2_Realloc(void* pMem, FX_DWORD dwSize) { | 367 virtual void* JBig2_Realloc(void* pMem, FX_DWORD dwSize) { |
365 return FX_Realloc(uint8_t, pMem, dwSize); | 368 return FX_Realloc(uint8_t, pMem, dwSize); |
366 } | 369 } |
367 virtual void JBig2_Free(void* pMem) { FX_Free(pMem); } | 370 virtual void JBig2_Free(void* pMem) { FX_Free(pMem); } |
368 }; | 371 }; |
372 | |
369 class CCodec_Jbig2Context { | 373 class CCodec_Jbig2Context { |
370 public: | 374 public: |
371 CCodec_Jbig2Context(); | 375 CCodec_Jbig2Context(); |
372 ~CCodec_Jbig2Context(){}; | 376 ~CCodec_Jbig2Context(){}; |
373 | 377 |
374 FX_DWORD m_width; | 378 FX_DWORD m_width; |
375 FX_DWORD m_height; | 379 FX_DWORD m_height; |
376 uint8_t* m_src_buf; | 380 uint8_t* m_src_buf; |
377 FX_DWORD m_src_size; | 381 FX_DWORD m_src_size; |
378 const uint8_t* m_global_data; | 382 const uint8_t* m_global_data; |
379 FX_DWORD m_global_size; | 383 FX_DWORD m_global_size; |
380 uint8_t* m_dest_buf; | 384 uint8_t* m_dest_buf; |
381 FX_DWORD m_dest_pitch; | 385 FX_DWORD m_dest_pitch; |
382 FX_BOOL m_bFileReader; | 386 FX_BOOL m_bFileReader; |
383 IFX_Pause* m_pPause; | 387 IFX_Pause* m_pPause; |
384 CJBig2_Context* m_pContext; | 388 CJBig2_Context* m_pContext; |
385 CJBig2_Image* m_dest_image; | 389 CJBig2_Image* m_dest_image; |
386 }; | 390 }; |
387 class CCodec_Jbig2Module : public ICodec_Jbig2Module { | 391 class CCodec_Jbig2Module : public ICodec_Jbig2Module { |
388 public: | 392 public: |
389 CCodec_Jbig2Module(){}; | 393 CCodec_Jbig2Module(){}; |
390 ~CCodec_Jbig2Module(); | 394 ~CCodec_Jbig2Module() override; |
395 | |
396 // ICodec_Jbig2Module | |
391 FX_BOOL Decode(FX_DWORD width, | 397 FX_BOOL Decode(FX_DWORD width, |
392 FX_DWORD height, | 398 FX_DWORD height, |
393 const uint8_t* src_buf, | 399 const uint8_t* src_buf, |
394 FX_DWORD src_size, | 400 FX_DWORD src_size, |
395 const uint8_t* global_data, | 401 const uint8_t* global_data, |
396 FX_DWORD global_size, | 402 FX_DWORD global_size, |
397 uint8_t* dest_buf, | 403 uint8_t* dest_buf, |
398 FX_DWORD dest_pitch); | 404 FX_DWORD dest_pitch) override; |
399 FX_BOOL Decode(IFX_FileRead* file_ptr, | 405 FX_BOOL Decode(IFX_FileRead* file_ptr, |
400 FX_DWORD& width, | 406 FX_DWORD& width, |
401 FX_DWORD& height, | 407 FX_DWORD& height, |
402 FX_DWORD& pitch, | 408 FX_DWORD& pitch, |
403 uint8_t*& dest_buf); | 409 uint8_t*& dest_buf) override; |
404 void* CreateJbig2Context(); | 410 void* CreateJbig2Context() override; |
405 FXCODEC_STATUS StartDecode(void* pJbig2Context, | 411 FXCODEC_STATUS StartDecode(void* pJbig2Context, |
406 FX_DWORD width, | 412 FX_DWORD width, |
407 FX_DWORD height, | 413 FX_DWORD height, |
408 const uint8_t* src_buf, | 414 const uint8_t* src_buf, |
409 FX_DWORD src_size, | 415 FX_DWORD src_size, |
410 const uint8_t* global_data, | 416 const uint8_t* global_data, |
411 FX_DWORD global_size, | 417 FX_DWORD global_size, |
412 uint8_t* dest_buf, | 418 uint8_t* dest_buf, |
413 FX_DWORD dest_pitch, | 419 FX_DWORD dest_pitch, |
414 IFX_Pause* pPause); | 420 IFX_Pause* pPause) override; |
415 | |
416 FXCODEC_STATUS StartDecode(void* pJbig2Context, | 421 FXCODEC_STATUS StartDecode(void* pJbig2Context, |
417 IFX_FileRead* file_ptr, | 422 IFX_FileRead* file_ptr, |
418 FX_DWORD& width, | 423 FX_DWORD& width, |
419 FX_DWORD& height, | 424 FX_DWORD& height, |
420 FX_DWORD& pitch, | 425 FX_DWORD& pitch, |
421 uint8_t*& dest_buf, | 426 uint8_t*& dest_buf, |
422 IFX_Pause* pPause); | 427 IFX_Pause* pPause) override; |
423 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause); | 428 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, |
424 void DestroyJbig2Context(void* pJbig2Context); | 429 IFX_Pause* pPause) override; |
430 void DestroyJbig2Context(void* pJbig2Context) override; | |
431 | |
432 private: | |
425 CPDF_Jbig2Interface m_Module; | 433 CPDF_Jbig2Interface m_Module; |
426 std::list<CJBig2_CachePair> m_SymbolDictCache; | 434 std::list<CJBig2_CachePair> m_SymbolDictCache; |
427 | |
428 private: | |
429 }; | 435 }; |
430 class CFX_DIBAttributeExif : public IFX_DIBAttributeExif { | 436 class CFX_DIBAttributeExif : public IFX_DIBAttributeExif { |
431 public: | 437 public: |
432 CFX_DIBAttributeExif(); | 438 CFX_DIBAttributeExif(); |
433 ~CFX_DIBAttributeExif(); | 439 ~CFX_DIBAttributeExif(); |
434 virtual FX_BOOL GetInfo(FX_WORD tag, void* val); | 440 virtual FX_BOOL GetInfo(FX_WORD tag, void* val); |
435 | 441 |
436 FX_BOOL ParseExif(CFX_MapPtrTemplate<FX_DWORD, uint8_t*>* pHead, | 442 FX_BOOL ParseExif(CFX_MapPtrTemplate<FX_DWORD, uint8_t*>* pHead, |
437 uint8_t* data, | 443 uint8_t* data, |
438 FX_DWORD len, | 444 FX_DWORD len, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, | 478 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, |
473 OPJ_SIZE_T nb_bytes, | 479 OPJ_SIZE_T nb_bytes, |
474 void* p_user_data); | 480 void* p_user_data); |
475 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, | 481 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, |
476 OPJ_SIZE_T nb_bytes, | 482 OPJ_SIZE_T nb_bytes, |
477 void* p_user_data); | 483 void* p_user_data); |
478 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 484 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
479 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 485 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
480 | 486 |
481 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 487 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
OLD | NEW |