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

Side by Side Diff: core/include/fxcodec/fx_codec.h

Issue 1398383002: core/ difference with XFA (for information only). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 2015-11-24 version Created 5 years 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/include/fpdfdoc/fpdf_doc.h ('k') | core/include/fxcodec/fx_codec_def.h » ('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 #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_ 7 #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_
8 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_ 8 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_
9 9
10 #ifdef PDF_ENABLE_XFA
11 #include <map>
12 #endif
10 #include <vector> 13 #include <vector>
11 14
12 #include "core/include/fxcrt/fx_basic.h" 15 #include "core/include/fxcrt/fx_basic.h"
13 #include "fx_codec_def.h" 16 #include "fx_codec_def.h"
14 #include "third_party/base/nonstd_unique_ptr.h" 17 #include "third_party/base/nonstd_unique_ptr.h"
15 18
19 #ifdef PDF_ENABLE_XFA
20 #include "../fxcrt/fx_coordinates.h" // For FX_RECT.
21
22 #endif
16 class CFX_DIBSource; 23 class CFX_DIBSource;
17 class CJPX_Decoder; 24 class CJPX_Decoder;
18 class CPDF_PrivateData; 25 class CPDF_PrivateData;
19 class CPDF_StreamAcc; 26 class CPDF_StreamAcc;
27 #ifndef PDF_ENABLE_XFA
20 class ICodec_ScanlineDecoder; 28 class ICodec_ScanlineDecoder;
29 #endif
21 class ICodec_BasicModule; 30 class ICodec_BasicModule;
22 class ICodec_FaxModule; 31 class ICodec_FaxModule;
32 #ifdef PDF_ENABLE_XFA
33 class ICodec_FlateModule;
34 class ICodec_IccModule;
35 class ICodec_Jbig2Encoder;
36 class ICodec_Jbig2Module;
37 #endif
23 class ICodec_JpegModule; 38 class ICodec_JpegModule;
24 class ICodec_JpxModule; 39 class ICodec_JpxModule;
40 #ifndef PDF_ENABLE_XFA
25 class ICodec_Jbig2Module; 41 class ICodec_Jbig2Module;
26 class ICodec_IccModule; 42 class ICodec_IccModule;
27 class ICodec_FlateModule; 43 class ICodec_FlateModule;
28 class ICodec_Jbig2Encoder; 44 class ICodec_Jbig2Encoder;
45 #endif
29 class ICodec_ScanlineDecoder; 46 class ICodec_ScanlineDecoder;
30 47
48 #ifdef PDF_ENABLE_XFA
49 class ICodec_BmpModule;
50 class ICodec_GifModule;
51 class ICodec_PngModule;
52 class ICodec_ProgressiveDecoder;
53 class ICodec_TiffModule;
54
55 class CFX_DIBAttribute {
56 public:
57 CFX_DIBAttribute();
58 ~CFX_DIBAttribute();
59
60 int32_t m_nXDPI;
61 int32_t m_nYDPI;
62 FX_FLOAT m_fAspectRatio;
63 FX_WORD m_wDPIUnit;
64 CFX_ByteString m_strAuthor;
65 uint8_t m_strTime[20];
66 int32_t m_nGifLeft;
67 int32_t m_nGifTop;
68 FX_DWORD* m_pGifLocalPalette;
69 FX_DWORD m_nGifLocalPalNum;
70 int32_t m_nBmpCompressType;
71 std::map<FX_DWORD, void*> m_Exif;
72 };
73
74 #endif
31 class CCodec_ModuleMgr { 75 class CCodec_ModuleMgr {
32 public: 76 public:
33 CCodec_ModuleMgr(); 77 CCodec_ModuleMgr();
34 78
35 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } 79 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
36 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } 80 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
37 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } 81 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
38 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } 82 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
39 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } 83 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
40 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } 84 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
41 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } 85 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
42 86
87 #ifdef PDF_ENABLE_XFA
88 ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
89 ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
90 ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
91 ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
92 ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
93
94 #endif
43 protected: 95 protected:
44 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule; 96 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule;
45 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule; 97 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule;
46 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule; 98 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule;
47 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule; 99 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule;
48 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; 100 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
49 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; 101 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule;
50 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; 102 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule;
103 #ifdef PDF_ENABLE_XFA
104
105 nonstd::unique_ptr<ICodec_PngModule> m_pPngModule;
106 nonstd::unique_ptr<ICodec_GifModule> m_pGifModule;
107 nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule;
108 nonstd::unique_ptr<ICodec_TiffModule> m_pTiffModule;
109 #endif
51 }; 110 };
52 class ICodec_BasicModule { 111 class ICodec_BasicModule {
53 public: 112 public:
54 virtual ~ICodec_BasicModule() {} 113 virtual ~ICodec_BasicModule() {}
55 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, 114 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
56 FX_DWORD src_size, 115 FX_DWORD src_size,
57 uint8_t*& dest_buf, 116 uint8_t*& dest_buf,
58 FX_DWORD& dest_size) = 0; 117 FX_DWORD& dest_size) = 0;
59 virtual FX_BOOL A85Encode(const uint8_t* src_buf, 118 virtual FX_BOOL A85Encode(const uint8_t* src_buf,
60 FX_DWORD src_size, 119 FX_DWORD src_size,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 243
185 virtual void Finish(void* pContext) = 0; 244 virtual void Finish(void* pContext) = 0;
186 245
187 virtual void Input(void* pContext, 246 virtual void Input(void* pContext,
188 const uint8_t* src_buf, 247 const uint8_t* src_buf,
189 FX_DWORD src_size) = 0; 248 FX_DWORD src_size) = 0;
190 249
191 virtual int ReadHeader(void* pContext, 250 virtual int ReadHeader(void* pContext,
192 int* width, 251 int* width,
193 int* height, 252 int* height,
253 #ifndef PDF_ENABLE_XFA
194 int* nComps) = 0; 254 int* nComps) = 0;
255 #else
256 int* nComps,
257 CFX_DIBAttribute* pAttribute) = 0;
258 #endif
195 259
196 virtual int StartScanline(void* pContext, int down_scale) = 0; 260 virtual int StartScanline(void* pContext, int down_scale) = 0;
197 261
198 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; 262 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0;
199 263
200 virtual FX_DWORD GetAvailInput(void* pContext, 264 virtual FX_DWORD GetAvailInput(void* pContext,
201 uint8_t** avail_buf_ptr = NULL) = 0; 265 uint8_t** avail_buf_ptr = NULL) = 0;
202 }; 266 };
203 267
204 class ICodec_JpxModule { 268 class ICodec_JpxModule {
205 public: 269 public:
206 virtual ~ICodec_JpxModule() {} 270 virtual ~ICodec_JpxModule() {}
207 271
208 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, 272 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
209 FX_DWORD src_size, 273 FX_DWORD src_size,
210 bool use_colorspace) = 0; 274 bool use_colorspace) = 0;
211 275
212 virtual void GetImageInfo(CJPX_Decoder* pDecoder, 276 virtual void GetImageInfo(CJPX_Decoder* pDecoder,
213 FX_DWORD* width, 277 FX_DWORD* width,
214 FX_DWORD* height, 278 FX_DWORD* height,
215 FX_DWORD* components) = 0; 279 FX_DWORD* components) = 0;
216 280
217 virtual bool Decode(CJPX_Decoder* pDecoder, 281 virtual bool Decode(CJPX_Decoder* pDecoder,
218 uint8_t* dest_data, 282 uint8_t* dest_data,
219 int pitch, 283 int pitch,
220 const std::vector<uint8_t>& offsets) = 0; 284 const std::vector<uint8_t>& offsets) = 0;
221 285
222 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0; 286 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0;
223 }; 287 };
288 #ifdef PDF_ENABLE_XFA
289 class ICodec_PngModule {
290 public:
291 virtual ~ICodec_PngModule() {}
292
293 virtual void* Start(void* pModule) = 0;
294
295 virtual void Finish(void* pContext) = 0;
296
297 virtual FX_BOOL Input(void* pContext,
298 const uint8_t* src_buf,
299 FX_DWORD src_size,
300 CFX_DIBAttribute* pAttribute) = 0;
301
302 FX_BOOL (*ReadHeaderCallback)(void* pModule,
303 int width,
304 int height,
305 int bpc,
306 int pass,
307 int* color_type,
308 double* gamma);
309
310 FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
311
312 void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
313 };
314 class ICodec_GifModule {
315 public:
316 virtual ~ICodec_GifModule() {}
317
318 virtual void* Start(void* pModule) = 0;
319
320 virtual void Finish(void* pContext) = 0;
321
322 virtual FX_DWORD GetAvailInput(void* pContext,
323 uint8_t** avail_buf_ptr = NULL) = 0;
324
325 virtual void Input(void* pContext,
326 const uint8_t* src_buf,
327 FX_DWORD src_size) = 0;
328
329 virtual int32_t ReadHeader(void* pContext,
330 int* width,
331 int* height,
332 int* pal_num,
333 void** pal_pp,
334 int* bg_index,
335 CFX_DIBAttribute* pAttribute) = 0;
336
337 virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0;
338
339 void (*RecordCurrentPositionCallback)(void* pModule, FX_DWORD& cur_pos);
340
341 uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
342 int32_t frame_num,
343 int32_t pal_size);
344
345 virtual int32_t LoadFrame(void* pContext,
346 int frame_num,
347 CFX_DIBAttribute* pAttribute) = 0;
348
349 FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
350 FX_DWORD rcd_pos,
351 const FX_RECT& img_rc,
352 int32_t pal_num,
353 void* pal_ptr,
354 int32_t delay_time,
355 FX_BOOL user_input,
356 int32_t trans_index,
357 int32_t disposal_method,
358 FX_BOOL interlace);
359
360 void (*ReadScanlineCallback)(void* pModule,
361 int32_t row_num,
362 uint8_t* row_buf);
363 };
364 class ICodec_BmpModule {
365 public:
366 virtual ~ICodec_BmpModule() {}
367
368 virtual void* Start(void* pModule) = 0;
369
370 virtual void Finish(void* pContext) = 0;
371
372 virtual FX_DWORD GetAvailInput(void* pContext,
373 uint8_t** avail_buf_ptr = NULL) = 0;
374
375 virtual void Input(void* pContext,
376 const uint8_t* src_buf,
377 FX_DWORD src_size) = 0;
378
379 virtual int32_t ReadHeader(void* pContext,
380 int32_t* width,
381 int32_t* height,
382 FX_BOOL* tb_flag,
383 int32_t* components,
384 int* pal_num,
385 FX_DWORD** pal_pp,
386 CFX_DIBAttribute* pAttribute) = 0;
387
388 virtual int32_t LoadImage(void* pContext) = 0;
389
390 FX_BOOL (*InputImagePositionBufCallback)(void* pModule, FX_DWORD rcd_pos);
391
392 void (*ReadScanlineCallback)(void* pModule,
393 int32_t row_num,
394 uint8_t* row_buf);
395 };
396 class ICodec_TiffModule {
397 public:
398 virtual ~ICodec_TiffModule() {}
399
400 virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0;
401
402 virtual void GetFrames(void* ctx, int32_t& frames) = 0;
403
404 virtual FX_BOOL LoadFrameInfo(void* ctx,
405 int32_t frame,
406 FX_DWORD& width,
407 FX_DWORD& height,
408 FX_DWORD& comps,
409 FX_DWORD& bpc,
410 CFX_DIBAttribute* pAttribute) = 0;
411
412 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0;
413
414 virtual void DestroyDecoder(void* ctx) = 0;
415 };
416 #endif
224 417
225 class ICodec_Jbig2Module { 418 class ICodec_Jbig2Module {
226 public: 419 public:
227 virtual ~ICodec_Jbig2Module() {} 420 virtual ~ICodec_Jbig2Module() {}
228 421
229 virtual void* CreateJbig2Context() = 0; 422 virtual void* CreateJbig2Context() = 0;
230 423
231 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, 424 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context,
232 CFX_PrivateData* pPrivateData, 425 CFX_PrivateData* pPrivateData,
233 FX_DWORD width, 426 FX_DWORD width,
234 FX_DWORD height, 427 FX_DWORD height,
235 CPDF_StreamAcc* src_stream, 428 CPDF_StreamAcc* src_stream,
236 CPDF_StreamAcc* global_stream, 429 CPDF_StreamAcc* global_stream,
237 uint8_t* dest_buf, 430 uint8_t* dest_buf,
238 FX_DWORD dest_pitch, 431 FX_DWORD dest_pitch,
239 IFX_Pause* pPause) = 0; 432 IFX_Pause* pPause) = 0;
240 433
241 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, 434 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content,
242 IFX_Pause* pPause) = 0; 435 IFX_Pause* pPause) = 0;
243 virtual void DestroyJbig2Context(void* pJbig2Content) = 0; 436 virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
244 }; 437 };
438 #ifdef PDF_ENABLE_XFA
439 class ICodec_ProgressiveDecoder {
440 public:
441 virtual ~ICodec_ProgressiveDecoder() {}
442
443 virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
444 FXCODEC_IMAGE_TYPE imageType,
445 CFX_DIBAttribute* pAttribute) = 0;
446
447 virtual FXCODEC_IMAGE_TYPE GetType() const = 0;
448 virtual int32_t GetWidth() const = 0;
449 virtual int32_t GetHeight() const = 0;
450 virtual int32_t GetNumComponents() const = 0;
451 virtual int32_t GetBPC() const = 0;
452
453 virtual void SetClipBox(FX_RECT* clip) = 0;
454
455 virtual FXCODEC_STATUS GetFrames(int32_t& frames,
456 IFX_Pause* pPause = NULL) = 0;
457
458 virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap,
459 int32_t start_x,
460 int32_t start_y,
461 int32_t size_x,
462 int32_t size_y,
463 int32_t frames = 0,
464 FX_BOOL bInterpol = TRUE) = 0;
465
466 virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0;
467 };
468 #endif
245 class ICodec_Jbig2Encoder { 469 class ICodec_Jbig2Encoder {
246 public: 470 public:
247 virtual ~ICodec_Jbig2Encoder() {} 471 virtual ~ICodec_Jbig2Encoder() {}
248 }; 472 };
249 class ICodec_IccModule { 473 class ICodec_IccModule {
250 public: 474 public:
251 typedef enum { 475 typedef enum {
252 IccCS_Unknown = 0, 476 IccCS_Unknown = 0,
253 IccCS_XYZ, 477 IccCS_XYZ,
254 IccCS_Lab, 478 IccCS_Lab,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]); 559 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]);
336 void FaxG4Decode(const uint8_t* src_buf, 560 void FaxG4Decode(const uint8_t* src_buf,
337 FX_DWORD src_size, 561 FX_DWORD src_size,
338 int* pbitpos, 562 int* pbitpos,
339 uint8_t* dest_buf, 563 uint8_t* dest_buf,
340 int width, 564 int width,
341 int height, 565 int height,
342 int pitch); 566 int pitch);
343 567
344 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_ 568 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_
OLDNEW
« no previous file with comments | « core/include/fpdfdoc/fpdf_doc.h ('k') | core/include/fxcodec/fx_codec_def.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698