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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 FX_DWORD* width, | 257 FX_DWORD* width, |
258 FX_DWORD* height, | 258 FX_DWORD* height, |
259 FX_DWORD* components) override; | 259 FX_DWORD* components) override; |
260 FX_BOOL Decode(CJPX_Decoder* pDecoder, | 260 FX_BOOL Decode(CJPX_Decoder* pDecoder, |
261 uint8_t* dest_data, | 261 uint8_t* dest_data, |
262 int pitch, | 262 int pitch, |
263 uint8_t* offsets) override; | 263 uint8_t* offsets) override; |
264 void DestroyDecoder(CJPX_Decoder* pDecoder) override; | 264 void DestroyDecoder(CJPX_Decoder* pDecoder) override; |
265 }; | 265 }; |
266 | 266 |
267 class CPDF_Jbig2Interface : public CJBig2_Module { | |
268 public: | |
269 virtual void* JBig2_Malloc(FX_DWORD dwSize) { | |
270 return FX_Alloc(uint8_t, dwSize); | |
271 } | |
272 virtual void* JBig2_Malloc2(FX_DWORD num, FX_DWORD dwSize) { | |
273 if (dwSize && num >= UINT_MAX / dwSize) { | |
274 return NULL; | |
275 } | |
276 return FX_Alloc(uint8_t, num * dwSize); | |
277 } | |
278 virtual void* JBig2_Malloc3(FX_DWORD num, FX_DWORD dwSize, FX_DWORD dwSize2) { | |
279 if (dwSize2 && dwSize >= UINT_MAX / dwSize2) { | |
280 return NULL; | |
281 } | |
282 FX_DWORD size = dwSize2 * dwSize; | |
283 if (size && num >= UINT_MAX / size) { | |
284 return NULL; | |
285 } | |
286 return FX_Alloc(uint8_t, num * size); | |
287 } | |
288 virtual void* JBig2_Realloc(void* pMem, FX_DWORD dwSize) { | |
289 return FX_Realloc(uint8_t, pMem, dwSize); | |
290 } | |
291 virtual void JBig2_Free(void* pMem) { FX_Free(pMem); } | |
292 }; | |
293 | |
294 class CCodec_Jbig2Context { | 267 class CCodec_Jbig2Context { |
295 public: | 268 public: |
296 CCodec_Jbig2Context(); | 269 CCodec_Jbig2Context(); |
297 ~CCodec_Jbig2Context() {} | 270 ~CCodec_Jbig2Context() {} |
298 | 271 |
299 FX_DWORD m_width; | 272 FX_DWORD m_width; |
300 FX_DWORD m_height; | 273 FX_DWORD m_height; |
301 uint8_t* m_src_buf; | 274 uint8_t* m_src_buf; |
302 FX_DWORD m_src_size; | 275 FX_DWORD m_src_size; |
303 const uint8_t* m_global_data; | 276 const uint8_t* m_global_data; |
(...skipping 20 matching lines...) Expand all Loading... |
324 const uint8_t* global_data, | 297 const uint8_t* global_data, |
325 FX_DWORD global_size, | 298 FX_DWORD global_size, |
326 uint8_t* dest_buf, | 299 uint8_t* dest_buf, |
327 FX_DWORD dest_pitch, | 300 FX_DWORD dest_pitch, |
328 IFX_Pause* pPause) override; | 301 IFX_Pause* pPause) override; |
329 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, | 302 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, |
330 IFX_Pause* pPause) override; | 303 IFX_Pause* pPause) override; |
331 void DestroyJbig2Context(void* pJbig2Context) override; | 304 void DestroyJbig2Context(void* pJbig2Context) override; |
332 | 305 |
333 private: | 306 private: |
334 CPDF_Jbig2Interface m_Module; | |
335 std::list<CJBig2_CachePair> m_SymbolDictCache; | 307 std::list<CJBig2_CachePair> m_SymbolDictCache; |
336 }; | 308 }; |
337 | 309 |
338 struct DecodeData { | 310 struct DecodeData { |
339 public: | 311 public: |
340 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) | 312 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) |
341 : src_data(src_data), src_size(src_size), offset(0) {} | 313 : src_data(src_data), src_size(src_size), offset(0) {} |
342 unsigned char* src_data; | 314 unsigned char* src_data; |
343 OPJ_SIZE_T src_size; | 315 OPJ_SIZE_T src_size; |
344 OPJ_SIZE_T offset; | 316 OPJ_SIZE_T offset; |
345 }; | 317 }; |
346 | 318 |
347 /* Wrappers for C-style callbacks. */ | 319 /* Wrappers for C-style callbacks. */ |
348 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, | 320 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, |
349 OPJ_SIZE_T nb_bytes, | 321 OPJ_SIZE_T nb_bytes, |
350 void* p_user_data); | 322 void* p_user_data); |
351 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, | 323 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, |
352 OPJ_SIZE_T nb_bytes, | 324 OPJ_SIZE_T nb_bytes, |
353 void* p_user_data); | 325 void* p_user_data); |
354 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 326 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
355 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 327 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
356 | 328 |
357 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 329 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
OLD | NEW |