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

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: After bidi Created 5 years, 1 month 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
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 "../../../third_party/base/nonstd_unique_ptr.h" 15 #include "../../../third_party/base/nonstd_unique_ptr.h"
13 #include "../fxcrt/fx_basic.h" 16 #include "../fxcrt/fx_basic.h"
17 #ifdef PDF_ENABLE_XFA
18 #include "../fxcrt/fx_coordinates.h"
19 #endif
14 #include "fx_codec_def.h" 20 #include "fx_codec_def.h"
15 #include "fx_codec_provider.h" 21 #include "fx_codec_provider.h"
16 22
17 class CFX_DIBSource; 23 class CFX_DIBSource;
18 class CJPX_Decoder; 24 class CJPX_Decoder;
19 class CPDF_PrivateData; 25 class CPDF_PrivateData;
20 class CPDF_StreamAcc; 26 class CPDF_StreamAcc;
21 class ICodec_ScanlineDecoder; 27 class ICodec_ScanlineDecoder;
28 #ifdef PDF_ENABLE_XFA
29 class ICodec_ProgressiveDecoder;
30 #endif
22 class ICodec_BasicModule; 31 class ICodec_BasicModule;
23 class ICodec_FaxModule; 32 class ICodec_FaxModule;
24 class ICodec_JpegModule; 33 class ICodec_JpegModule;
25 class ICodec_JpxModule; 34 class ICodec_JpxModule;
26 class ICodec_Jbig2Module; 35 class ICodec_Jbig2Module;
27 class ICodec_IccModule; 36 class ICodec_IccModule;
28 class ICodec_FlateModule; 37 class ICodec_FlateModule;
29 class ICodec_Jbig2Encoder; 38 class ICodec_Jbig2Encoder;
39 #ifdef PDF_ENABLE_XFA
40 class ICodec_PngModule;
41 class ICodec_GifModule;
42 class ICodec_BmpModule;
43 class ICodec_TiffModule;
44 class CFX_DIBAttribute;
45 #endif
30 class ICodec_ScanlineDecoder; 46 class ICodec_ScanlineDecoder;
31 47
32 class CCodec_ModuleMgr { 48 class CCodec_ModuleMgr {
33 public: 49 public:
34 CCodec_ModuleMgr(); 50 CCodec_ModuleMgr();
51 #ifdef PDF_ENABLE_XFA
52 ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
53 #endif
35 ICodec_Jbig2Encoder* CreateJbig2Encoder(); 54 ICodec_Jbig2Encoder* CreateJbig2Encoder();
36 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } 55 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
37 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } 56 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
38 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } 57 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
39 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } 58 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
40 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } 59 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
41 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } 60 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
42 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } 61 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
62 #ifdef PDF_ENABLE_XFA
63 ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
64 ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
65 ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
66 ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
67 #endif
43 68
44 protected: 69 protected:
45 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule; 70 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule;
46 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule; 71 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule;
47 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule; 72 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule;
48 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule; 73 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule;
49 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; 74 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
50 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; 75 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule;
51 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; 76 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule;
77 #ifdef PDF_ENABLE_XFA
78 nonstd::unique_ptr<ICodec_PngModule> m_pPngModule;
79 nonstd::unique_ptr<ICodec_GifModule> m_pGifModule;
80 nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule;
81 nonstd::unique_ptr<ICodec_TiffModule> m_pTiffModule;
82 #endif
52 }; 83 };
53 class ICodec_BasicModule { 84 class ICodec_BasicModule {
54 public: 85 public:
55 virtual ~ICodec_BasicModule() {} 86 virtual ~ICodec_BasicModule() {}
56 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, 87 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
57 FX_DWORD src_size, 88 FX_DWORD src_size,
58 uint8_t*& dest_buf, 89 uint8_t*& dest_buf,
59 FX_DWORD& dest_size) = 0; 90 FX_DWORD& dest_size) = 0;
60 virtual FX_BOOL A85Encode(const uint8_t* src_buf, 91 virtual FX_BOOL A85Encode(const uint8_t* src_buf,
61 FX_DWORD src_size, 92 FX_DWORD src_size,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 218
188 virtual void Finish(void* pContext) = 0; 219 virtual void Finish(void* pContext) = 0;
189 220
190 virtual void Input(void* pContext, 221 virtual void Input(void* pContext,
191 const uint8_t* src_buf, 222 const uint8_t* src_buf,
192 FX_DWORD src_size) = 0; 223 FX_DWORD src_size) = 0;
193 224
194 virtual int ReadHeader(void* pContext, 225 virtual int ReadHeader(void* pContext,
195 int* width, 226 int* width,
196 int* height, 227 int* height,
228 #ifndef PDF_ENABLE_XFA
197 int* nComps) = 0; 229 int* nComps) = 0;
230 #else
231 int* nComps,
232 CFX_DIBAttribute* pAttribute = NULL) = 0;
233 #endif
198 234
199 virtual int StartScanline(void* pContext, int down_scale) = 0; 235 virtual int StartScanline(void* pContext, int down_scale) = 0;
200 236
201 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; 237 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0;
202 238
203 virtual FX_DWORD GetAvailInput(void* pContext, 239 virtual FX_DWORD GetAvailInput(void* pContext,
204 uint8_t** avail_buf_ptr = NULL) = 0; 240 uint8_t** avail_buf_ptr = NULL) = 0;
205 }; 241 };
206 242
207 class ICodec_JpxModule { 243 class ICodec_JpxModule {
208 public: 244 public:
209 virtual ~ICodec_JpxModule() {} 245 virtual ~ICodec_JpxModule() {}
210 246
211 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, 247 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
212 FX_DWORD src_size, 248 FX_DWORD src_size,
213 bool use_colorspace) = 0; 249 bool use_colorspace) = 0;
214 250
215 virtual void GetImageInfo(CJPX_Decoder* pDecoder, 251 virtual void GetImageInfo(CJPX_Decoder* pDecoder,
216 FX_DWORD* width, 252 FX_DWORD* width,
217 FX_DWORD* height, 253 FX_DWORD* height,
218 FX_DWORD* components) = 0; 254 FX_DWORD* components) = 0;
219 255
220 virtual bool Decode(CJPX_Decoder* pDecoder, 256 virtual bool Decode(CJPX_Decoder* pDecoder,
221 uint8_t* dest_data, 257 uint8_t* dest_data,
222 int pitch, 258 int pitch,
223 const std::vector<uint8_t>& offsets) = 0; 259 const std::vector<uint8_t>& offsets) = 0;
224 260
225 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0; 261 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0;
226 }; 262 };
263 #ifdef PDF_ENABLE_XFA
264 class ICodec_PngModule {
265 public:
266 virtual ~ICodec_PngModule() {}
267
268 virtual void* Start(void* pModule) = 0;
269
270 virtual void Finish(void* pContext) = 0;
271
272 virtual FX_BOOL Input(void* pContext,
273 const uint8_t* src_buf,
274 FX_DWORD src_size,
275 CFX_DIBAttribute* pAttribute = NULL) = 0;
276
277 FX_BOOL (*ReadHeaderCallback)(void* pModule, int width, int height, int bpc, int pass, int* color_type, double* gamma);
278
279 FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
280
281 void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
282 };
283 class ICodec_GifModule {
284 public:
285 virtual ~ICodec_GifModule() {}
286
287 virtual void* Start(void* pModule) = 0;
288
289 virtual void Finish(void* pContext) = 0;
290
291 virtual FX_DWORD GetAvailInput(void* pContext,
292 uint8_t** avail_buf_ptr = NULL) = 0;
293
294 virtual void Input(void* pContext,
295 const uint8_t* src_buf,
296 FX_DWORD src_size) = 0;
297
298 virtual int32_t ReadHeader(void* pContext,
299 int* width,
300 int* height,
301 int* pal_num,
302 void** pal_pp,
303 int* bg_index,
304 CFX_DIBAttribute* pAttribute = NULL) = 0;
305
306 virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0;
307
308 void (*RecordCurrentPositionCallback)(void* pModule, FX_DWORD& cur_pos);
309
310 uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
311 int32_t frame_num,
312 int32_t pal_size);
313
314 virtual int32_t LoadFrame(void* pContext,
315 int frame_num,
316 CFX_DIBAttribute* pAttribute = NULL) = 0;
317
318 FX_BOOL (*InputRecordPositionBufCallback)(void* pModule, FX_DWORD rcd_pos, const FX_RECT& img_rc,
319 int32_t pal_num, void* pal_ptr,
320 int32_t delay_time, FX_BOOL user_input,
321 int32_t trans_index, int32_t disposal_method, FX_BOOL interlace);
322
323 void (*ReadScanlineCallback)(void* pModule,
324 int32_t row_num,
325 uint8_t* row_buf);
326 };
327 class ICodec_BmpModule {
328 public:
329 virtual ~ICodec_BmpModule() {}
330
331 virtual void* Start(void* pModule) = 0;
332
333 virtual void Finish(void* pContext) = 0;
334
335 virtual FX_DWORD GetAvailInput(void* pContext,
336 uint8_t** avail_buf_ptr = NULL) = 0;
337
338 virtual void Input(void* pContext,
339 const uint8_t* src_buf,
340 FX_DWORD src_size) = 0;
341
342 virtual int32_t ReadHeader(void* pContext,
343 int32_t* width,
344 int32_t* height,
345 FX_BOOL* tb_flag,
346 int32_t* components,
347 int* pal_num,
348 FX_DWORD** pal_pp,
349 CFX_DIBAttribute* pAttribute = NULL) = 0;
350
351 virtual int32_t LoadImage(void* pContext) = 0;
352
353 FX_BOOL (*InputImagePositionBufCallback)(void* pModule, FX_DWORD rcd_pos);
354
355 void (*ReadScanlineCallback)(void* pModule,
356 int32_t row_num,
357 uint8_t* row_buf);
358 };
359 class ICodec_TiffModule {
360 public:
361 virtual ~ICodec_TiffModule() {}
362
363 virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0;
364
365 virtual void GetFrames(void* ctx, int32_t& frames) = 0;
366
367 virtual FX_BOOL LoadFrameInfo(void* ctx,
368 int32_t frame,
369 FX_DWORD& width,
370 FX_DWORD& height,
371 FX_DWORD& comps,
372 FX_DWORD& bpc,
373 CFX_DIBAttribute* pAttribute = NULL) = 0;
374
375 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0;
376
377 virtual void DestroyDecoder(void* ctx) = 0;
378 };
379 #endif
227 380
228 class ICodec_Jbig2Module { 381 class ICodec_Jbig2Module {
229 public: 382 public:
230 virtual ~ICodec_Jbig2Module() {} 383 virtual ~ICodec_Jbig2Module() {}
231 384
232 virtual void* CreateJbig2Context() = 0; 385 virtual void* CreateJbig2Context() = 0;
233 386
234 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, 387 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context,
235 CFX_PrivateData* pPrivateData, 388 CFX_PrivateData* pPrivateData,
236 FX_DWORD width, 389 FX_DWORD width,
237 FX_DWORD height, 390 FX_DWORD height,
238 CPDF_StreamAcc* src_stream, 391 CPDF_StreamAcc* src_stream,
239 CPDF_StreamAcc* global_stream, 392 CPDF_StreamAcc* global_stream,
240 uint8_t* dest_buf, 393 uint8_t* dest_buf,
241 FX_DWORD dest_pitch, 394 FX_DWORD dest_pitch,
242 IFX_Pause* pPause) = 0; 395 IFX_Pause* pPause) = 0;
243 396
244 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, 397 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content,
245 IFX_Pause* pPause) = 0; 398 IFX_Pause* pPause) = 0;
246 virtual void DestroyJbig2Context(void* pJbig2Content) = 0; 399 virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
247 }; 400 };
401 #ifdef PDF_ENABLE_XFA
402 class ICodec_ProgressiveDecoder {
403 public:
404 virtual ~ICodec_ProgressiveDecoder() {}
405
406 virtual FXCODEC_STATUS LoadImageInfo(
407 IFX_FileRead* pFile,
408 FXCODEC_IMAGE_TYPE imageType = FXCODEC_IMAGE_UNKNOWN,
409 CFX_DIBAttribute* pAttribute = NULL) = 0;
410
411 virtual FXCODEC_IMAGE_TYPE GetType() = 0;
412
413 virtual int32_t GetWidth() = 0;
414
415 virtual int32_t GetHeight() = 0;
416
417 virtual int32_t GetNumComponents() = 0;
418
419 virtual int32_t GetBPC() = 0;
420
421 virtual void SetClipBox(FX_RECT* clip) = 0;
422
423 virtual FXCODEC_STATUS GetFrames(int32_t& frames,
424 IFX_Pause* pPause = NULL) = 0;
425
426 virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap,
427 int32_t start_x,
428 int32_t start_y,
429 int32_t size_x,
430 int32_t size_y,
431 int32_t frames = 0,
432 FX_BOOL bInterpol = TRUE) = 0;
433
434 virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0;
435 };
436 #endif
248 class ICodec_Jbig2Encoder { 437 class ICodec_Jbig2Encoder {
249 public: 438 public:
250 virtual ~ICodec_Jbig2Encoder() {} 439 virtual ~ICodec_Jbig2Encoder() {}
251 }; 440 };
252 class ICodec_IccModule { 441 class ICodec_IccModule {
253 public: 442 public:
254 typedef enum { 443 typedef enum {
255 IccCS_Unknown = 0, 444 IccCS_Unknown = 0,
256 IccCS_XYZ, 445 IccCS_XYZ,
257 IccCS_Lab, 446 IccCS_Lab,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 virtual void Translate(void* pTransform, 502 virtual void Translate(void* pTransform,
314 FX_FLOAT* pSrcValues, 503 FX_FLOAT* pSrcValues,
315 FX_FLOAT* pDestValues) = 0; 504 FX_FLOAT* pDestValues) = 0;
316 505
317 virtual void TranslateScanline(void* pTransform, 506 virtual void TranslateScanline(void* pTransform,
318 uint8_t* pDest, 507 uint8_t* pDest,
319 const uint8_t* pSrc, 508 const uint8_t* pSrc,
320 int pixels) = 0; 509 int pixels) = 0;
321 virtual void SetComponents(FX_DWORD nComponents) = 0; 510 virtual void SetComponents(FX_DWORD nComponents) = 0;
322 }; 511 };
512 #ifdef PDF_ENABLE_XFA
513
514 #endif
323 void AdobeCMYK_to_sRGB(FX_FLOAT c, 515 void AdobeCMYK_to_sRGB(FX_FLOAT c,
324 FX_FLOAT m, 516 FX_FLOAT m,
325 FX_FLOAT y, 517 FX_FLOAT y,
326 FX_FLOAT k, 518 FX_FLOAT k,
327 FX_FLOAT& R, 519 FX_FLOAT& R,
328 FX_FLOAT& G, 520 FX_FLOAT& G,
329 FX_FLOAT& B); 521 FX_FLOAT& B);
330 void AdobeCMYK_to_sRGB1(uint8_t c, 522 void AdobeCMYK_to_sRGB1(uint8_t c,
331 uint8_t m, 523 uint8_t m,
332 uint8_t y, 524 uint8_t y,
333 uint8_t k, 525 uint8_t k,
334 uint8_t& R, 526 uint8_t& R,
335 uint8_t& G, 527 uint8_t& G,
336 uint8_t& B); 528 uint8_t& B);
337 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]); 529 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]);
338 530
531 #ifdef PDF_ENABLE_XFA
532 class CFX_DIBAttribute {
533 public:
534 CFX_DIBAttribute();
535 ~CFX_DIBAttribute();
536
537 int32_t m_nXDPI;
538 int32_t m_nYDPI;
539 FX_FLOAT m_fAspectRatio;
540 FX_WORD m_wDPIUnit;
541 CFX_ByteString m_strAuthor;
542 uint8_t m_strTime[20];
543 int32_t m_nGifLeft;
544 int32_t m_nGifTop;
545 FX_DWORD* m_pGifLocalPalette;
546 FX_DWORD m_nGifLocalPalNum;
547 int32_t m_nBmpCompressType;
548 std::map<FX_DWORD, void*> m_Exif;
549 };
550
551 FX_BOOL FaxSkipEOL(const uint8_t* src_buf, int bitsize, int& bitpos);
Tom Sepez 2015/10/29 23:07:37 note: getting fixed.
552 FX_BOOL FaxGet1DLine(const uint8_t* src_buf,
553 int bitsize,
554 int& bitpos,
555 uint8_t* dest_buf,
556 int columns);
557 FX_BOOL FaxG4GetRow(const uint8_t* src_buf,
558 int bitsize,
559 int& bitpos,
560 uint8_t* dest_buf,
561 const uint8_t* ref_buf,
562 int columns);
563 #endif
339 void FaxG4Decode(const uint8_t* src_buf, 564 void FaxG4Decode(const uint8_t* src_buf,
340 FX_DWORD src_size, 565 FX_DWORD src_size,
341 int* pbitpos, 566 int* pbitpos,
342 uint8_t* dest_buf, 567 uint8_t* dest_buf,
343 int width, 568 int width,
344 int height, 569 int height,
345 int pitch); 570 int pitch);
346 571
347 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_ 572 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698