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

Side by Side Diff: core/src/fxcodec/codec/codec_int.h

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 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
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_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>
11 #include <list> 11 #include <list>
12 12
13 #include "../../../../third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T. 13 #include "../../../../third_party/libopenjpeg20/openjpeg.h" // For OPJ_SIZE_T.
14 #include "../../../include/fxcodec/fx_codec.h" 14 #include "../../../include/fxcodec/fx_codec.h"
15 #include "../jbig2/JBig2_Context.h" 15 #include "../jbig2/JBig2_Context.h"
16 16
17 class CCodec_BasicModule : public ICodec_BasicModule 17 class CCodec_BasicModule : public ICodec_BasicModule {
18 { 18 public:
19 public: 19 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf,
20 virtual FX_BOOL» RunLengthEncode(const uint8_t* src_buf, FX_DWORD src_siz e, uint8_t*& dest_buf, 20 FX_DWORD src_size,
21 uint8_t*& dest_buf,
22 FX_DWORD& dest_size);
23 virtual FX_BOOL A85Encode(const uint8_t* src_buf,
24 FX_DWORD src_size,
25 uint8_t*& dest_buf,
26 FX_DWORD& dest_size);
27 virtual ICodec_ScanlineDecoder* CreateRunLengthDecoder(const uint8_t* src_buf,
28 FX_DWORD src_size,
29 int width,
30 int height,
31 int nComps,
32 int bpc);
33 };
34 struct CCodec_ImageDataCache {
35 int m_Width, m_Height;
36 int m_nCachedLines;
37 uint8_t m_Data;
38 };
39 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder {
40 public:
41 CCodec_ScanlineDecoder();
42
43 virtual ~CCodec_ScanlineDecoder();
44
45 virtual FX_DWORD GetSrcOffset() { return -1; }
46
47 virtual void DownScale(int dest_width, int dest_height);
48
49 uint8_t* GetScanline(int line);
50
51 FX_BOOL SkipToScanline(int line, IFX_Pause* pPause);
52
53 int GetWidth() { return m_OutputWidth; }
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) {
65 FX_Free(m_pDataCache);
66 }
67 m_pDataCache = NULL;
68 }
69
70 protected:
71 int m_OrigWidth;
72
73 int m_OrigHeight;
74
75 int m_DownScale;
76
77 int m_OutputWidth;
78
79 int m_OutputHeight;
80
81 int m_nComps;
82
83 int m_bpc;
84
85 int m_Pitch;
86
87 FX_BOOL m_bColorTransformed;
88
89 uint8_t* ReadNextLine();
90
91 virtual FX_BOOL v_Rewind() = 0;
92
93 virtual uint8_t* v_GetNextLine() = 0;
94
95 virtual void v_DownScale(int dest_width, int dest_height) = 0;
96
97 int m_NextLine;
98
99 uint8_t* m_pLastScanline;
100
101 CCodec_ImageDataCache* m_pDataCache;
102 };
103 class CCodec_FaxModule : public ICodec_FaxModule {
104 public:
105 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
106 FX_DWORD src_size,
107 int width,
108 int height,
109 int K,
110 FX_BOOL EndOfLine,
111 FX_BOOL EncodedByteAlign,
112 FX_BOOL BlackIs1,
113 int Columns,
114 int Rows);
115 FX_BOOL Encode(const uint8_t* src_buf,
116 int width,
117 int height,
118 int pitch,
119 uint8_t*& dest_buf,
120 FX_DWORD& dest_size);
121 };
122 class CCodec_FlateModule : public ICodec_FlateModule {
123 public:
124 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
125 FX_DWORD src_size,
126 int width,
127 int height,
128 int nComps,
129 int bpc,
130 int predictor,
131 int Colors,
132 int BitsPerComponent,
133 int Columns);
134 virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW,
135 const uint8_t* src_buf,
136 FX_DWORD src_size,
137 FX_BOOL bEarlyChange,
138 int predictor,
139 int Colors,
140 int BitsPerComponent,
141 int Columns,
142 FX_DWORD estimated_size,
143 uint8_t*& dest_buf,
21 FX_DWORD& dest_size); 144 FX_DWORD& dest_size);
22 virtual FX_BOOL» A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uin t8_t*& dest_buf, 145 virtual FX_BOOL Encode(const uint8_t* src_buf,
23 FX_DWORD& dest_size); 146 FX_DWORD src_size,
24 virtual ICodec_ScanlineDecoder*» CreateRunLengthDecoder(const uint8_t* sr c_buf, FX_DWORD src_size, int width, int height, 147 int predictor,
25 int nComps, int bpc); 148 int Colors,
26 }; 149 int BitsPerComponent,
27 struct CCodec_ImageDataCache { 150 int Columns,
28 int»» » m_Width, m_Height; 151 uint8_t*& dest_buf,
29 int»» » m_nCachedLines; 152 FX_DWORD& dest_size);
30 uint8_t» » m_Data; 153 virtual FX_BOOL Encode(const uint8_t* src_buf,
31 }; 154 FX_DWORD src_size,
32 class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder 155 uint8_t*& dest_buf,
33 { 156 FX_DWORD& dest_size);
34 public: 157 };
35 158 class CCodec_JpegModule : public ICodec_JpegModule {
36 CCodec_ScanlineDecoder(); 159 public:
37 160 CCodec_JpegModule() : m_pExtProvider(NULL) {}
38 virtual ~CCodec_ScanlineDecoder(); 161 void SetPovider(IFX_JpegProvider* pJP) { m_pExtProvider = pJP; }
39 162 ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
40 virtual FX_DWORD» GetSrcOffset() 163 FX_DWORD src_size,
41 { 164 int width,
42 return -1; 165 int height,
166 int nComps,
167 FX_BOOL ColorTransform);
168 FX_BOOL LoadInfo(const uint8_t* src_buf,
169 FX_DWORD src_size,
170 int& width,
171 int& height,
172 int& num_components,
173 int& bits_per_components,
174 FX_BOOL& color_transform,
175 uint8_t** icc_buf_ptr,
176 FX_DWORD* icc_length);
177 FX_BOOL Encode(const CFX_DIBSource* pSource,
178 uint8_t*& dest_buf,
179 FX_STRSIZE& dest_size,
180 int quality,
181 const uint8_t* icc_buf,
182 FX_DWORD icc_length);
183 virtual void* Start();
184 virtual void Finish(void* pContext);
185 virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size);
186 virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps);
187 virtual int StartScanline(void* pContext, int down_scale);
188 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf);
189 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
190
191 protected:
192 IFX_JpegProvider* m_pExtProvider;
193 };
194 class CCodec_IccModule : public ICodec_IccModule {
195 public:
196 virtual IccCS GetProfileCS(const uint8_t* pProfileData,
197 unsigned int dwProfileSize);
198 virtual IccCS GetProfileCS(IFX_FileRead* pFile);
199 virtual void* CreateTransform(
200 ICodec_IccModule::IccParam* pInputParam,
201 ICodec_IccModule::IccParam* pOutputParam,
202 ICodec_IccModule::IccParam* pProofParam = NULL,
203 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL,
204 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT,
205 FX_DWORD dwPrfIntent = Icc_INTENT_ABSOLUTE_COLORIMETRIC,
206 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTPROOFING);
207 virtual void* CreateTransform_sRGB(const uint8_t* pProfileData,
208 FX_DWORD dwProfileSize,
209 int32_t& nComponents,
210 int32_t intent = 0,
211 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT);
212 virtual void* CreateTransform_CMYK(const uint8_t* pSrcProfileData,
213 FX_DWORD dwSrcProfileSize,
214 int32_t& nSrcComponents,
215 const uint8_t* pDstProfileData,
216 FX_DWORD dwDstProfileSize,
217 int32_t intent = 0,
218 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
219 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT);
220 virtual void DestroyTransform(void* pTransform);
221 virtual void Translate(void* pTransform,
222 FX_FLOAT* pSrcValues,
223 FX_FLOAT* pDestValues);
224 virtual void TranslateScanline(void* pTransform,
225 uint8_t* pDest,
226 const uint8_t* pSrc,
227 int pixels);
228 virtual void SetComponents(FX_DWORD nComponents) {
229 m_nComponents = nComponents;
230 }
231 virtual ~CCodec_IccModule();
232
233 protected:
234 CFX_MapByteStringToPtr m_MapTranform;
235 CFX_MapByteStringToPtr m_MapProfile;
236 FX_DWORD m_nComponents;
237 typedef enum {
238 Icc_CLASS_INPUT = 0,
239 Icc_CLASS_OUTPUT,
240 Icc_CLASS_PROOF,
241 Icc_CLASS_MAX
242 } Icc_CLASS;
243 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam,
244 Icc_CLASS ic,
245 CFX_BinaryBuf* pTransformKey);
246 };
247 class CCodec_JpxModule : public ICodec_JpxModule {
248 public:
249 CCodec_JpxModule();
250 void* CreateDecoder(const uint8_t* src_buf,
251 FX_DWORD src_size,
252 FX_BOOL useColorSpace = FALSE);
253 void GetImageInfo(void* ctx,
254 FX_DWORD& width,
255 FX_DWORD& height,
256 FX_DWORD& codestream_nComps,
257 FX_DWORD& output_nComps);
258 FX_BOOL Decode(void* ctx,
259 uint8_t* dest_data,
260 int pitch,
261 FX_BOOL bTranslateColor,
262 uint8_t* offsets);
263 void DestroyDecoder(void* ctx);
264 };
265 class CPDF_Jbig2Interface : public CJBig2_Module {
266 public:
267 virtual void* JBig2_Malloc(FX_DWORD dwSize) {
268 return FX_Alloc(uint8_t, dwSize);
269 }
270 virtual void* JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize) {
271 if (dwSize && num >= UINT_MAX / dwSize) {
272 return NULL;
43 } 273 }
44 274 return FX_Alloc(uint8_t, num * dwSize);
45 virtual void» » DownScale(int dest_width, int dest_height); 275 }
46 276 virtual void* JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2) {
47 uint8_t*» » » GetScanline(int line); 277 if (dwSize2 && dwSize >= UINT_MAX / dwSize2) {
48 278 return NULL;
49 FX_BOOL» » » » SkipToScanline(int line, IFX_Pause* pPau se);
50
51 int»» » » » GetWidth()
52 {
53 return m_OutputWidth;
54 } 279 }
55 280 FX_DWORD size = dwSize2 * dwSize;
56 int»» » » » GetHeight() 281 if (size && num >= UINT_MAX / size) {
57 { 282 return NULL;
58 return m_OutputHeight;
59 } 283 }
60 284 return FX_Alloc(uint8_t, num * size);
61 int CountComps() 285 }
62 { 286 virtual void* JBig2_Realloc(void* pMem, FX_DWORD dwSize) {
63 return m_nComps; 287 return FX_Realloc(uint8_t, pMem, dwSize);
64 } 288 }
65 289 virtual void JBig2_Free(void* pMem) { FX_Free(pMem); }
66 int GetBPC() 290 };
67 { 291 class CCodec_Jbig2Context {
68 return m_bpc; 292 public:
69 } 293 CCodec_Jbig2Context();
70 294 ~CCodec_Jbig2Context(){};
71 FX_BOOL IsColorTransformed() 295
72 { 296 FX_DWORD m_width;
73 return m_bColorTransformed; 297 FX_DWORD m_height;
74 } 298 uint8_t* m_src_buf;
75 299 FX_DWORD m_src_size;
76 void ClearImageData() 300 const uint8_t* m_global_data;
77 { 301 FX_DWORD m_global_size;
78 if (m_pDataCache) { 302 uint8_t* m_dest_buf;
79 FX_Free(m_pDataCache); 303 FX_DWORD m_dest_pitch;
80 } 304 FX_BOOL m_bFileReader;
81 m_pDataCache = NULL; 305 IFX_Pause* m_pPause;
82 } 306 CJBig2_Context* m_pContext;
83 protected: 307 CJBig2_Image* m_dest_image;
84 308 };
85 int m_OrigWidth; 309 class CCodec_Jbig2Module : public ICodec_Jbig2Module {
86 310 public:
87 int m_OrigHeight; 311 CCodec_Jbig2Module(){};
88 312 ~CCodec_Jbig2Module();
89 int m_DownScale; 313 FX_BOOL Decode(FX_DWORD width,
90 314 FX_DWORD height,
91 int m_OutputWidth; 315 const uint8_t* src_buf,
92 316 FX_DWORD src_size,
93 int m_OutputHeight; 317 const uint8_t* global_data,
94 318 FX_DWORD global_size,
95 int m_nComps; 319 uint8_t* dest_buf,
96 320 FX_DWORD dest_pitch);
97 int m_bpc; 321 FX_BOOL Decode(IFX_FileRead* file_ptr,
98 322 FX_DWORD& width,
99 int m_Pitch; 323 FX_DWORD& height,
100 324 FX_DWORD& pitch,
101 FX_BOOL m_bColorTransformed; 325 uint8_t*& dest_buf);
102 326 void* CreateJbig2Context();
103 uint8_t* ReadNextLine(); 327 FXCODEC_STATUS StartDecode(void* pJbig2Context,
104 328 FX_DWORD width,
105 virtual FX_BOOL v_Rewind() = 0; 329 FX_DWORD height,
106 330 const uint8_t* src_buf,
107 virtual uint8_t* v_GetNextLine() = 0; 331 FX_DWORD src_size,
108 332 const uint8_t* global_data,
109 virtual void v_DownScale(int dest_width, int dest_height) = 0 ; 333 FX_DWORD global_size,
110 334 uint8_t* dest_buf,
111 int m_NextLine; 335 FX_DWORD dest_pitch,
112 336 IFX_Pause* pPause);
113 uint8_t* m_pLastScanline; 337
114 338 FXCODEC_STATUS StartDecode(void* pJbig2Context,
115 CCodec_ImageDataCache* m_pDataCache; 339 IFX_FileRead* file_ptr,
116 }; 340 FX_DWORD& width,
117 class CCodec_FaxModule : public ICodec_FaxModule 341 FX_DWORD& height,
118 { 342 FX_DWORD& pitch,
119 public: 343 uint8_t*& dest_buf,
120 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX _DWORD src_size, int width, int height, 344 IFX_Pause* pPause);
121 int K, FX_BOOL EndOfLine, FX_BOOL EncodedByteAlign, FX_BOOL BlackIs1 , int Columns, int Rows); 345 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause);
122 FX_BOOL Encode(const uint8_t* src_buf, int width, int height, in t pitch, uint8_t*& dest_buf, FX_DWORD& dest_size); 346 void DestroyJbig2Context(void* pJbig2Context);
123 }; 347 CPDF_Jbig2Interface m_Module;
124 class CCodec_FlateModule : public ICodec_FlateModule 348 std::list<CJBig2_CachePair> m_SymbolDictCache;
125 { 349
126 public: 350 private:
127 virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX _DWORD src_size, int width, int height,
128 int nComps, int bpc, int predictor, int Colors, int BitsPerComponent , int Columns);
129 virtual FX_DWORD FlateOrLZWDecode(FX_BOOL bLZW, const uint8_t* src_buf, FX_D WORD src_size, FX_BOOL bEarlyChange,
130 int predictor, int Colors, int BitsPerComp onent, int Columns,
131 FX_DWORD estimated_size, uint8_t*& dest_bu f, FX_DWORD& dest_size);
132 virtual FX_BOOL Encode(const uint8_t* src_buf, FX_DWORD src_size,
133 int predictor, int Colors, int BitsPerComponent, int Columns,
134 uint8_t*& dest_buf, FX_DWORD& dest_size);
135 virtual FX_BOOL Encode(const uint8_t* src_buf, FX_DWORD src_size , uint8_t*& dest_buf, FX_DWORD& dest_size);
136 };
137 class CCodec_JpegModule : public ICodec_JpegModule
138 {
139 public:
140 CCodec_JpegModule() : m_pExtProvider(NULL) {}
141 void SetPovider(IFX_JpegProvider* pJP)
142 {
143 m_pExtProvider = pJP;
144 }
145 ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, FX_DWORD s rc_size,
146 int width, int height, int nComps, FX_ BOOL ColorTransform);
147 FX_BOOL LoadInfo(const uint8_t* src_buf, FX_DWORD src_size, int& width, int& height,
148 int& num_components, int& bits_per_components, FX_BOOL& color_transform,
149 uint8_t** icc_buf_ptr, FX_DWORD* icc_length);
150 FX_BOOL Encode(const CFX_DIBSource* pSource, uint8_t*& dest_buf, FX_STRSIZE& dest_size, int quality, const uint8_t* icc_buf, FX_DWORD icc_length );
151 virtual void* Start();
152 virtual void Finish(void* pContext);
153 virtual void Input(void* pContext, const uint8_t* src_buf, FX _DWORD src_size);
154 virtual int ReadHeader(void* pContext, int* width, int* heig ht, int* nComps);
155 virtual int StartScanline(void* pContext, int down_scale);
156 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf);
157 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
158 protected:
159 IFX_JpegProvider* m_pExtProvider;
160 };
161 class CCodec_IccModule : public ICodec_IccModule
162 {
163 public:
164 virtual IccCS GetProfileCS(const uint8_t* pProfileData , unsigned int dwProfileSize);
165 virtual IccCS GetProfileCS(IFX_FileRead* pFile);
166 virtual void* CreateTransform(ICodec_IccModule::IccParam* pInp utParam,
167 ICodec_IccModule::IccParam* pOutputP aram,
168 ICodec_IccModule::IccParam* pProofPa ram = NULL,
169 FX_DWORD dwIntent = Icc_INTENT_PERCE PTUAL,
170 FX_DWORD dwFlag = Icc_FLAGS_DEFAULT,
171 FX_DWORD dwPrfIntent = Icc_INTENT_AB SOLUTE_COLORIMETRIC,
172 FX_DWORD dwPrfFlag = Icc_FLAGS_SOFTP ROOFING
173 );
174 virtual void* CreateTransform_sRGB(const uint8_t* pProfileData , FX_DWORD dwProfileSize, int32_t& nComponents, int32_t intent = 0,
175 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT);
176 virtual void* CreateTransform_CMYK(const uint8_t* pSrcProfileD ata, FX_DWORD dwSrcProfileSize, int32_t& nSrcComponents,
177 const uint8_t* pDstProfileData, FX_DWORD dwDstProfileSize, int32_t i ntent = 0,
178 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT,
179 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT
180 );
181 virtual void DestroyTransform(void* pTransform);
182 virtual void Translate(void* pTransform, FX_FLOAT* pS rcValues, FX_FLOAT* pDestValues);
183 virtual void TranslateScanline(void* pTransform, uint 8_t* pDest, const uint8_t* pSrc, int pixels);
184 virtual void SetComponents(FX_DWORD nComponents) {m_n Components = nComponents;}
185 virtual ~CCodec_IccModule();
186 protected:
187 CFX_MapByteStringToPtr m_MapTranform;
188 CFX_MapByteStringToPtr m_MapProfile;
189 FX_DWORD m_nComponents;
190 typedef enum {
191 Icc_CLASS_INPUT = 0,
192 Icc_CLASS_OUTPUT,
193 Icc_CLASS_PROOF,
194 Icc_CLASS_MAX
195 } Icc_CLASS;
196 void* CreateProfile(ICodec_IccModule::IccParam* pIccParam, Icc _CLASS ic, CFX_BinaryBuf* pTransformKey);
197 };
198 class CCodec_JpxModule : public ICodec_JpxModule
199 {
200 public:
201 CCodec_JpxModule();
202 void* CreateDecoder(const uint8_t* src_buf, FX_DWORD src_size, FX_BOOL useColorSpace = FALSE);
203 void GetImageInfo(void* ctx, FX_DWORD& width, FX_DWORD& heigh t,
204 FX_DWORD& codestream_nComps, FX_DWORD& output_nComp s);
205 FX_BOOL Decode(void* ctx, uint8_t* dest_data, int pitch, FX_BOOL bTranslateColor, uint8_t* offsets);
206 void DestroyDecoder(void* ctx);
207 };
208 class CPDF_Jbig2Interface : public CJBig2_Module
209 {
210 public:
211 virtual void *JBig2_Malloc(FX_DWORD dwSize)
212 {
213 return FX_Alloc(uint8_t, dwSize);
214 }
215 virtual void *JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize)
216 {
217 if (dwSize && num >= UINT_MAX / dwSize) {
218 return NULL;
219 }
220 return FX_Alloc(uint8_t, num * dwSize);
221 }
222 virtual void *JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2)
223 {
224 if (dwSize2 && dwSize >= UINT_MAX / dwSize2) {
225 return NULL;
226 }
227 FX_DWORD size = dwSize2 * dwSize;
228 if (size && num >= UINT_MAX / size) {
229 return NULL;
230 }
231 return FX_Alloc(uint8_t, num * size);
232 }
233 virtual void *JBig2_Realloc(void* pMem, FX_DWORD dwSize)
234 {
235 return FX_Realloc(uint8_t, pMem, dwSize);
236 }
237 virtual void JBig2_Free(void* pMem)
238 {
239 FX_Free(pMem);
240 }
241 };
242 class CCodec_Jbig2Context
243 {
244 public:
245 CCodec_Jbig2Context();
246 ~CCodec_Jbig2Context() {};
247
248 FX_DWORD m_width;
249 FX_DWORD m_height;
250 uint8_t* m_src_buf;
251 FX_DWORD m_src_size;
252 const uint8_t* m_global_data;
253 FX_DWORD m_global_size;
254 uint8_t* m_dest_buf;
255 FX_DWORD m_dest_pitch;
256 FX_BOOL m_bFileReader;
257 IFX_Pause* m_pPause;
258 CJBig2_Context* m_pContext;
259 CJBig2_Image* m_dest_image;
260 };
261 class CCodec_Jbig2Module : public ICodec_Jbig2Module
262 {
263 public:
264 CCodec_Jbig2Module() {};
265 ~CCodec_Jbig2Module();
266 FX_BOOL Decode(FX_DWORD width, FX_DWORD height, const uint8_t* s rc_buf, FX_DWORD src_size,
267 const uint8_t* global_data, FX_DWORD global_size, uint8_t * dest_buf, FX_DWORD dest_pitch);
268 FX_BOOL Decode(IFX_FileRead* file_ptr,
269 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, uint8 _t*& dest_buf);
270 void* CreateJbig2Context();
271 FXCODEC_STATUS StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, FX_DWORD src_size,
272 const uint8_t* global_data, FX_DWORD global_ size, uint8_t* dest_buf, FX_DWORD dest_pitch, IFX_Pause* pPause);
273
274 FXCODEC_STATUS StartDecode(void* pJbig2Context, IFX_FileRead* f ile_ptr,
275 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, uint8_t*& dest_buf, IFX_Pause* pPause);
276 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* p Pause);
277 void DestroyJbig2Context(void* pJbig2Context) ;
278 CPDF_Jbig2Interface m_Module;
279 std::list<CJBig2_CachePair> m_SymbolDictCache;
280 private:
281 }; 351 };
282 352
283 struct DecodeData { 353 struct DecodeData {
284 public: 354 public:
285 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) : 355 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size)
286 src_data(src_data), src_size(src_size), offset(0) { 356 : src_data(src_data), src_size(src_size), offset(0) {}
287 } 357 unsigned char* src_data;
288 unsigned char* src_data; 358 OPJ_SIZE_T src_size;
289 OPJ_SIZE_T src_size; 359 OPJ_SIZE_T offset;
290 OPJ_SIZE_T offset;
291 }; 360 };
292 361
293 /* Wrappers for C-style callbacks. */ 362 /* Wrappers for C-style callbacks. */
294 OPJ_SIZE_T opj_read_from_memory (void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_u ser_data); 363 OPJ_SIZE_T opj_read_from_memory(void* p_buffer,
295 OPJ_SIZE_T opj_write_from_memory (void* p_buffer, OPJ_SIZE_T nb_bytes, void* p_u ser_data); 364 OPJ_SIZE_T nb_bytes,
296 OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T nb_bytes, void* p_user_data); 365 void* p_user_data);
297 OPJ_BOOL opj_seek_from_memory (OPJ_OFF_T nb_bytes, void* p_user_data); 366 OPJ_SIZE_T opj_write_from_memory(void* p_buffer,
367 OPJ_SIZE_T nb_bytes,
368 void* p_user_data);
369 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data);
370 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data);
298 371
299 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ 372 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698