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

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

Issue 1864153002: Move include/fxcodec to fxcodec/include (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 8 months 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/fxcodec/DEPS ('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
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_
8 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_
9
10 #include <map>
11 #include <memory>
12 #include <vector>
13
14 #include "core/fxcrt/include/fx_basic.h"
15 #include "core/fxcrt/include/fx_coordinates.h" // For FX_RECT.
16 #include "core/include/fxcodec/fx_codec_def.h"
17
18 class CFX_DIBSource;
19 class CJPX_Decoder;
20 class CPDF_ColorSpace;
21 class CPDF_StreamAcc;
22 class ICodec_BasicModule;
23 class ICodec_FaxModule;
24 class ICodec_FlateModule;
25 class ICodec_IccModule;
26 class ICodec_Jbig2Encoder;
27 class ICodec_Jbig2Module;
28 class ICodec_JpegModule;
29 class ICodec_JpxModule;
30 class ICodec_ScanlineDecoder;
31
32 #ifdef PDF_ENABLE_XFA
33 class ICodec_BmpModule;
34 class ICodec_GifModule;
35 class ICodec_PngModule;
36 class ICodec_ProgressiveDecoder;
37 class ICodec_TiffModule;
38 #endif // PDF_ENABLE_XFA
39
40 #ifdef PDF_ENABLE_XFA
41 class CFX_DIBAttribute {
42 public:
43 CFX_DIBAttribute();
44 ~CFX_DIBAttribute();
45
46 int32_t m_nXDPI;
47 int32_t m_nYDPI;
48 FX_FLOAT m_fAspectRatio;
49 uint16_t m_wDPIUnit;
50 CFX_ByteString m_strAuthor;
51 uint8_t m_strTime[20];
52 int32_t m_nGifLeft;
53 int32_t m_nGifTop;
54 uint32_t* m_pGifLocalPalette;
55 uint32_t m_nGifLocalPalNum;
56 int32_t m_nBmpCompressType;
57 std::map<uint32_t, void*> m_Exif;
58 };
59 #endif // PDF_ENABLE_XFA
60
61 class CCodec_ModuleMgr {
62 public:
63 CCodec_ModuleMgr();
64
65 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
66 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
67 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); }
68 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); }
69 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); }
70 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); }
71 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); }
72
73 #ifdef PDF_ENABLE_XFA
74 ICodec_ProgressiveDecoder* CreateProgressiveDecoder();
75 ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); }
76 ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); }
77 ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); }
78 ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); }
79 #endif // PDF_ENABLE_XFA
80
81 protected:
82 std::unique_ptr<ICodec_BasicModule> m_pBasicModule;
83 std::unique_ptr<ICodec_FaxModule> m_pFaxModule;
84 std::unique_ptr<ICodec_JpegModule> m_pJpegModule;
85 std::unique_ptr<ICodec_JpxModule> m_pJpxModule;
86 std::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module;
87 std::unique_ptr<ICodec_IccModule> m_pIccModule;
88 #ifdef PDF_ENABLE_XFA
89 std::unique_ptr<ICodec_PngModule> m_pPngModule;
90 std::unique_ptr<ICodec_GifModule> m_pGifModule;
91 std::unique_ptr<ICodec_BmpModule> m_pBmpModule;
92 std::unique_ptr<ICodec_TiffModule> m_pTiffModule;
93 #endif // PDF_ENABLE_XFA
94 std::unique_ptr<ICodec_FlateModule> m_pFlateModule;
95 };
96 class ICodec_BasicModule {
97 public:
98 virtual ~ICodec_BasicModule() {}
99 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
100 uint32_t src_size,
101 uint8_t*& dest_buf,
102 uint32_t& dest_size) = 0;
103 virtual FX_BOOL A85Encode(const uint8_t* src_buf,
104 uint32_t src_size,
105 uint8_t*& dest_buf,
106 uint32_t& dest_size) = 0;
107 virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
108 uint32_t src_size,
109 int width,
110 int height,
111 int nComps,
112 int bpc) = 0;
113 };
114
115 class ICodec_ScanlineDecoder {
116 public:
117 virtual ~ICodec_ScanlineDecoder() {}
118
119 virtual uint32_t GetSrcOffset() = 0;
120
121 virtual const uint8_t* GetScanline(int line) = 0;
122
123 virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) = 0;
124
125 virtual int GetWidth() = 0;
126
127 virtual int GetHeight() = 0;
128
129 virtual int CountComps() = 0;
130
131 virtual int GetBPC() = 0;
132 };
133
134 class ICodec_FlateModule {
135 public:
136 virtual ~ICodec_FlateModule() {}
137 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
138 uint32_t src_size,
139 int width,
140 int height,
141 int nComps,
142 int bpc,
143 int predictor,
144 int Colors,
145 int BitsPerComponent,
146 int Columns) = 0;
147 virtual uint32_t FlateOrLZWDecode(FX_BOOL bLZW,
148 const uint8_t* src_buf,
149 uint32_t src_size,
150 FX_BOOL bEarlyChange,
151 int predictor,
152 int Colors,
153 int BitsPerComponent,
154 int Columns,
155 uint32_t estimated_size,
156 uint8_t*& dest_buf,
157 uint32_t& dest_size) = 0;
158 virtual FX_BOOL Encode(const uint8_t* src_buf,
159 uint32_t src_size,
160 int predictor,
161 int Colors,
162 int BitsPerComponent,
163 int Columns,
164 uint8_t*& dest_buf,
165 uint32_t& dest_size) = 0;
166 virtual FX_BOOL Encode(const uint8_t* src_buf,
167 uint32_t src_size,
168 uint8_t*& dest_buf,
169 uint32_t& dest_size) = 0;
170 };
171 class ICodec_FaxModule {
172 public:
173 virtual ~ICodec_FaxModule() {}
174
175 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
176 uint32_t src_size,
177 int width,
178 int height,
179 int K,
180 FX_BOOL EndOfLine,
181 FX_BOOL EncodedByteAlign,
182 FX_BOOL BlackIs1,
183 int Columns,
184 int Rows) = 0;
185
186 virtual FX_BOOL Encode(const uint8_t* src_buf,
187 int width,
188 int height,
189 int pitch,
190 uint8_t*& dest_buf,
191 uint32_t& dest_size) = 0;
192 };
193 class ICodec_JpegModule {
194 public:
195 virtual ~ICodec_JpegModule() {}
196
197 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
198 uint32_t src_size,
199 int width,
200 int height,
201 int nComps,
202 FX_BOOL ColorTransform) = 0;
203
204 virtual FX_BOOL LoadInfo(const uint8_t* src_buf,
205 uint32_t src_size,
206 int& width,
207 int& height,
208 int& num_components,
209 int& bits_per_components,
210 FX_BOOL& color_transform,
211 uint8_t** icc_buf_ptr = NULL,
212 uint32_t* icc_length = NULL) = 0;
213
214 virtual FX_BOOL Encode(const class CFX_DIBSource* pSource,
215 uint8_t*& dest_buf,
216 FX_STRSIZE& dest_size,
217 int quality = 75,
218 const uint8_t* icc_buf = NULL,
219 uint32_t icc_length = 0) = 0;
220
221 virtual void* Start() = 0;
222
223 virtual void Finish(void* pContext) = 0;
224
225 virtual void Input(void* pContext,
226 const uint8_t* src_buf,
227 uint32_t src_size) = 0;
228
229 #ifdef PDF_ENABLE_XFA
230 virtual int ReadHeader(void* pContext,
231 int* width,
232 int* height,
233 int* nComps,
234 CFX_DIBAttribute* pAttribute) = 0;
235 #else // PDF_ENABLE_XFA
236 virtual int ReadHeader(void* pContext,
237 int* width,
238 int* height,
239 int* nComps) = 0;
240 #endif // PDF_ENABLE_XFA
241
242 virtual int StartScanline(void* pContext, int down_scale) = 0;
243
244 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0;
245
246 virtual uint32_t GetAvailInput(void* pContext,
247 uint8_t** avail_buf_ptr = NULL) = 0;
248 };
249
250 class ICodec_JpxModule {
251 public:
252 virtual ~ICodec_JpxModule() {}
253
254 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf,
255 uint32_t src_size,
256 CPDF_ColorSpace* cs) = 0;
257
258 virtual void GetImageInfo(CJPX_Decoder* pDecoder,
259 uint32_t* width,
260 uint32_t* height,
261 uint32_t* components) = 0;
262
263 virtual bool Decode(CJPX_Decoder* pDecoder,
264 uint8_t* dest_data,
265 int pitch,
266 const std::vector<uint8_t>& offsets) = 0;
267
268 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0;
269 };
270 #ifdef PDF_ENABLE_XFA
271 class ICodec_PngModule {
272 public:
273 virtual ~ICodec_PngModule() {}
274
275 virtual void* Start(void* pModule) = 0;
276
277 virtual void Finish(void* pContext) = 0;
278
279 virtual FX_BOOL Input(void* pContext,
280 const uint8_t* src_buf,
281 uint32_t src_size,
282 CFX_DIBAttribute* pAttribute) = 0;
283
284 FX_BOOL (*ReadHeaderCallback)(void* pModule,
285 int width,
286 int height,
287 int bpc,
288 int pass,
289 int* color_type,
290 double* gamma);
291
292 FX_BOOL (*AskScanlineBufCallback)(void* pModule, int line, uint8_t*& src_buf);
293
294 void (*FillScanlineBufCompletedCallback)(void* pModule, int pass, int line);
295 };
296 class ICodec_GifModule {
297 public:
298 virtual ~ICodec_GifModule() {}
299
300 virtual void* Start(void* pModule) = 0;
301
302 virtual void Finish(void* pContext) = 0;
303
304 virtual uint32_t GetAvailInput(void* pContext,
305 uint8_t** avail_buf_ptr = NULL) = 0;
306
307 virtual void Input(void* pContext,
308 const uint8_t* src_buf,
309 uint32_t src_size) = 0;
310
311 virtual int32_t ReadHeader(void* pContext,
312 int* width,
313 int* height,
314 int* pal_num,
315 void** pal_pp,
316 int* bg_index,
317 CFX_DIBAttribute* pAttribute) = 0;
318
319 virtual int32_t LoadFrameInfo(void* pContext, int* frame_num) = 0;
320
321 void (*RecordCurrentPositionCallback)(void* pModule, uint32_t& cur_pos);
322
323 uint8_t* (*AskLocalPaletteBufCallback)(void* pModule,
324 int32_t frame_num,
325 int32_t pal_size);
326
327 virtual int32_t LoadFrame(void* pContext,
328 int frame_num,
329 CFX_DIBAttribute* pAttribute) = 0;
330
331 FX_BOOL (*InputRecordPositionBufCallback)(void* pModule,
332 uint32_t rcd_pos,
333 const FX_RECT& img_rc,
334 int32_t pal_num,
335 void* pal_ptr,
336 int32_t delay_time,
337 FX_BOOL user_input,
338 int32_t trans_index,
339 int32_t disposal_method,
340 FX_BOOL interlace);
341
342 void (*ReadScanlineCallback)(void* pModule,
343 int32_t row_num,
344 uint8_t* row_buf);
345 };
346 class ICodec_BmpModule {
347 public:
348 virtual ~ICodec_BmpModule() {}
349
350 virtual void* Start(void* pModule) = 0;
351
352 virtual void Finish(void* pContext) = 0;
353
354 virtual uint32_t GetAvailInput(void* pContext,
355 uint8_t** avail_buf_ptr = NULL) = 0;
356
357 virtual void Input(void* pContext,
358 const uint8_t* src_buf,
359 uint32_t src_size) = 0;
360
361 virtual int32_t ReadHeader(void* pContext,
362 int32_t* width,
363 int32_t* height,
364 FX_BOOL* tb_flag,
365 int32_t* components,
366 int* pal_num,
367 uint32_t** pal_pp,
368 CFX_DIBAttribute* pAttribute) = 0;
369
370 virtual int32_t LoadImage(void* pContext) = 0;
371
372 FX_BOOL (*InputImagePositionBufCallback)(void* pModule, uint32_t rcd_pos);
373
374 void (*ReadScanlineCallback)(void* pModule,
375 int32_t row_num,
376 uint8_t* row_buf);
377 };
378 class ICodec_TiffModule {
379 public:
380 virtual ~ICodec_TiffModule() {}
381
382 virtual void* CreateDecoder(IFX_FileRead* file_ptr) = 0;
383
384 virtual void GetFrames(void* ctx, int32_t& frames) = 0;
385
386 virtual FX_BOOL LoadFrameInfo(void* ctx,
387 int32_t frame,
388 uint32_t& width,
389 uint32_t& height,
390 uint32_t& comps,
391 uint32_t& bpc,
392 CFX_DIBAttribute* pAttribute) = 0;
393
394 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0;
395
396 virtual void DestroyDecoder(void* ctx) = 0;
397 };
398 #endif
399
400 class ICodec_Jbig2Module {
401 public:
402 virtual ~ICodec_Jbig2Module() {}
403
404 virtual void* CreateJbig2Context() = 0;
405
406 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context,
407 CFX_PrivateData* pPrivateData,
408 uint32_t width,
409 uint32_t height,
410 CPDF_StreamAcc* src_stream,
411 CPDF_StreamAcc* global_stream,
412 uint8_t* dest_buf,
413 uint32_t dest_pitch,
414 IFX_Pause* pPause) = 0;
415
416 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content,
417 IFX_Pause* pPause) = 0;
418 virtual void DestroyJbig2Context(void* pJbig2Content) = 0;
419 };
420 #ifdef PDF_ENABLE_XFA
421 class ICodec_ProgressiveDecoder {
422 public:
423 virtual ~ICodec_ProgressiveDecoder() {}
424
425 virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile,
426 FXCODEC_IMAGE_TYPE imageType,
427 CFX_DIBAttribute* pAttribute) = 0;
428
429 virtual FXCODEC_IMAGE_TYPE GetType() const = 0;
430 virtual int32_t GetWidth() const = 0;
431 virtual int32_t GetHeight() const = 0;
432 virtual int32_t GetNumComponents() const = 0;
433 virtual int32_t GetBPC() const = 0;
434
435 virtual void SetClipBox(FX_RECT* clip) = 0;
436
437 virtual FXCODEC_STATUS GetFrames(int32_t& frames,
438 IFX_Pause* pPause = NULL) = 0;
439
440 virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap,
441 int32_t start_x,
442 int32_t start_y,
443 int32_t size_x,
444 int32_t size_y,
445 int32_t frames = 0,
446 FX_BOOL bInterpol = TRUE) = 0;
447
448 virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0;
449 };
450 #endif // PDF_ENABLE_XFA
451 class ICodec_Jbig2Encoder {
452 public:
453 virtual ~ICodec_Jbig2Encoder() {}
454 };
455
456 class ICodec_IccModule {
457 public:
458 enum IccCS {
459 IccCS_Unknown = 0,
460 IccCS_XYZ,
461 IccCS_Lab,
462 IccCS_Luv,
463 IccCS_YCbCr,
464 IccCS_Yxy,
465 IccCS_Hsv,
466 IccCS_Hls,
467 IccCS_Gray,
468 IccCS_Rgb,
469 IccCS_Cmyk,
470 IccCS_Cmy
471 };
472
473 struct IccParam {
474 uint32_t Version;
475 IccCS ColorSpace;
476 uint32_t dwProfileType;
477 uint32_t dwFormat;
478 uint8_t* pProfileData;
479 uint32_t dwProfileSize;
480 double Gamma;
481 };
482
483 virtual ~ICodec_IccModule() {}
484
485 virtual IccCS GetProfileCS(const uint8_t* pProfileData,
486 unsigned int dwProfileSize) = 0;
487
488 virtual IccCS GetProfileCS(IFX_FileRead* pFile) = 0;
489
490 virtual void* CreateTransform(
491 ICodec_IccModule::IccParam* pInputParam,
492 ICodec_IccModule::IccParam* pOutputParam,
493 ICodec_IccModule::IccParam* pProofParam = NULL,
494 uint32_t dwIntent = Icc_INTENT_PERCEPTUAL,
495 uint32_t dwFlag = Icc_FLAGS_DEFAULT,
496 uint32_t dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
497 uint32_t dwPrfFlag = Icc_FLAGS_SOFTPROOFING) = 0;
498
499 virtual void* CreateTransform_sRGB(
500 const uint8_t* pProfileData,
501 uint32_t dwProfileSize,
502 uint32_t& nComponents,
503 int32_t intent = 0,
504 uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT) = 0;
505
506 virtual void* CreateTransform_CMYK(
507 const uint8_t* pSrcProfileData,
508 uint32_t dwSrcProfileSize,
509 uint32_t& nSrcComponents,
510 const uint8_t* pDstProfileData,
511 uint32_t dwDstProfileSize,
512 int32_t intent = 0,
513 uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT,
514 uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) = 0;
515
516 virtual void DestroyTransform(void* pTransform) = 0;
517
518 virtual void Translate(void* pTransform,
519 FX_FLOAT* pSrcValues,
520 FX_FLOAT* pDestValues) = 0;
521
522 virtual void TranslateScanline(void* pTransform,
523 uint8_t* pDest,
524 const uint8_t* pSrc,
525 int pixels) = 0;
526 virtual void SetComponents(uint32_t nComponents) = 0;
527 };
528
529 void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels);
530 void sRGB_to_AdobeCMYK(FX_FLOAT R,
531 FX_FLOAT G,
532 FX_FLOAT B,
533 FX_FLOAT& c,
534 FX_FLOAT& m,
535 FX_FLOAT& y,
536 FX_FLOAT& k);
537 void AdobeCMYK_to_sRGB(FX_FLOAT c,
538 FX_FLOAT m,
539 FX_FLOAT y,
540 FX_FLOAT k,
541 FX_FLOAT& R,
542 FX_FLOAT& G,
543 FX_FLOAT& B);
544 void AdobeCMYK_to_sRGB1(uint8_t c,
545 uint8_t m,
546 uint8_t y,
547 uint8_t k,
548 uint8_t& R,
549 uint8_t& G,
550 uint8_t& B);
551 FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]);
552 void FaxG4Decode(const uint8_t* src_buf,
553 uint32_t src_size,
554 int* pbitpos,
555 uint8_t* dest_buf,
556 int width,
557 int height,
558 int pitch);
559
560 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_
OLDNEW
« no previous file with comments | « core/include/fxcodec/DEPS ('k') | core/include/fxcodec/fx_codec_def.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698