| 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 #include <setjmp.h> | 7 #include <setjmp.h> |
| 8 | 8 |
| 9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
| 10 #include "../../../include/fxcrt/fx_safe_types.h" | 10 #include "../../../include/fxcrt/fx_safe_types.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 bits_per_components = cinfo.data_precision; | 280 bits_per_components = cinfo.data_precision; |
| 281 if (icc_buf_ptr != NULL) { | 281 if (icc_buf_ptr != NULL) { |
| 282 *icc_buf_ptr = NULL; | 282 *icc_buf_ptr = NULL; |
| 283 } | 283 } |
| 284 if (icc_length != NULL) { | 284 if (icc_length != NULL) { |
| 285 *icc_length = 0; | 285 *icc_length = 0; |
| 286 } | 286 } |
| 287 jpeg_destroy_decompress(&cinfo); | 287 jpeg_destroy_decompress(&cinfo); |
| 288 return TRUE; | 288 return TRUE; |
| 289 } | 289 } |
| 290 |
| 290 class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { | 291 class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { |
| 291 public: | 292 public: |
| 292 CCodec_JpegDecoder(); | 293 CCodec_JpegDecoder(); |
| 293 ~CCodec_JpegDecoder(); | 294 ~CCodec_JpegDecoder() override; |
| 295 |
| 294 FX_BOOL Create(const uint8_t* src_buf, | 296 FX_BOOL Create(const uint8_t* src_buf, |
| 295 FX_DWORD src_size, | 297 FX_DWORD src_size, |
| 296 int width, | 298 int width, |
| 297 int height, | 299 int height, |
| 298 int nComps, | 300 int nComps, |
| 299 FX_BOOL ColorTransform, | 301 FX_BOOL ColorTransform, |
| 300 IFX_JpegProvider* pJP); | 302 IFX_JpegProvider* pJP); |
| 301 virtual void Destroy() { delete this; } | 303 void Destroy() { delete this; } |
| 302 virtual void v_DownScale(int dest_width, int dest_height); | 304 |
| 303 virtual FX_BOOL v_Rewind(); | 305 // CCodec_ScanlineDecoder |
| 304 virtual uint8_t* v_GetNextLine(); | 306 void v_DownScale(int dest_width, int dest_height) override; |
| 305 virtual FX_DWORD GetSrcOffset(); | 307 FX_BOOL v_Rewind() override; |
| 308 uint8_t* v_GetNextLine() override; |
| 309 FX_DWORD GetSrcOffset() override; |
| 310 |
| 311 FX_BOOL InitDecode(); |
| 312 |
| 306 jmp_buf m_JmpBuf; | 313 jmp_buf m_JmpBuf; |
| 307 struct jpeg_decompress_struct cinfo; | 314 struct jpeg_decompress_struct cinfo; |
| 308 struct jpeg_error_mgr jerr; | 315 struct jpeg_error_mgr jerr; |
| 309 struct jpeg_source_mgr src; | 316 struct jpeg_source_mgr src; |
| 310 const uint8_t* m_SrcBuf; | 317 const uint8_t* m_SrcBuf; |
| 311 FX_DWORD m_SrcSize; | 318 FX_DWORD m_SrcSize; |
| 312 uint8_t* m_pScanlineBuf; | 319 uint8_t* m_pScanlineBuf; |
| 313 FX_BOOL InitDecode(); | 320 |
| 314 FX_BOOL m_bInited, m_bStarted, m_bJpegTransform; | 321 FX_BOOL m_bInited; |
| 322 FX_BOOL m_bStarted; |
| 323 FX_BOOL m_bJpegTransform; |
| 315 | 324 |
| 316 protected: | 325 protected: |
| 317 IFX_JpegProvider* m_pExtProvider; | 326 IFX_JpegProvider* m_pExtProvider; |
| 318 void* m_pExtContext; | 327 void* m_pExtContext; |
| 319 FX_DWORD m_nDefaultScaleDenom; | 328 FX_DWORD m_nDefaultScaleDenom; |
| 320 }; | 329 }; |
| 330 |
| 321 CCodec_JpegDecoder::CCodec_JpegDecoder() { | 331 CCodec_JpegDecoder::CCodec_JpegDecoder() { |
| 322 m_pScanlineBuf = NULL; | 332 m_pScanlineBuf = NULL; |
| 323 m_DownScale = 1; | 333 m_DownScale = 1; |
| 324 m_bStarted = FALSE; | 334 m_bStarted = FALSE; |
| 325 m_bInited = FALSE; | 335 m_bInited = FALSE; |
| 326 m_pExtProvider = NULL; | 336 m_pExtProvider = NULL; |
| 327 m_pExtContext = NULL; | 337 m_pExtContext = NULL; |
| 328 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); | 338 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); |
| 329 FXSYS_memset(&jerr, 0, sizeof(jerr)); | 339 FXSYS_memset(&jerr, 0, sizeof(jerr)); |
| 330 FXSYS_memset(&src, 0, sizeof(src)); | 340 FXSYS_memset(&src, 0, sizeof(src)); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 } | 712 } |
| 703 if (avail_buf_ptr != NULL) { | 713 if (avail_buf_ptr != NULL) { |
| 704 *avail_buf_ptr = NULL; | 714 *avail_buf_ptr = NULL; |
| 705 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 715 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
| 706 *avail_buf_ptr = | 716 *avail_buf_ptr = |
| 707 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; | 717 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; |
| 708 } | 718 } |
| 709 } | 719 } |
| 710 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 720 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
| 711 } | 721 } |
| OLD | NEW |