| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 if (cinfo.next_scanline == row) { | 214 if (cinfo.next_scanline == row) { |
| 215 dest_buf = | 215 dest_buf = |
| 216 FX_Realloc(uint8_t, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE); | 216 FX_Realloc(uint8_t, dest_buf, dest_buf_length + JPEG_BLOCK_SIZE); |
| 217 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; | 217 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; |
| 218 dest_buf_length += JPEG_BLOCK_SIZE; | 218 dest_buf_length += JPEG_BLOCK_SIZE; |
| 219 dest.free_in_buffer += JPEG_BLOCK_SIZE; | 219 dest.free_in_buffer += JPEG_BLOCK_SIZE; |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 jpeg_finish_compress(&cinfo); | 222 jpeg_finish_compress(&cinfo); |
| 223 jpeg_destroy_compress(&cinfo); | 223 jpeg_destroy_compress(&cinfo); |
| 224 if (line_buf) { | 224 FX_Free(line_buf); |
| 225 FX_Free(line_buf); | |
| 226 } | |
| 227 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; | 225 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; |
| 228 } | 226 } |
| 229 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, | 227 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, |
| 230 FX_DWORD src_size, | 228 FX_DWORD src_size, |
| 231 int& width, | 229 int& width, |
| 232 int& height, | 230 int& height, |
| 233 int& num_components, | 231 int& num_components, |
| 234 int& bits_per_components, | 232 int& bits_per_components, |
| 235 FX_BOOL& color_transform, | 233 FX_BOOL& color_transform, |
| 236 uint8_t** icc_buf_ptr, | 234 uint8_t** icc_buf_ptr, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); | 336 FXSYS_memset(&cinfo, 0, sizeof(cinfo)); |
| 339 FXSYS_memset(&jerr, 0, sizeof(jerr)); | 337 FXSYS_memset(&jerr, 0, sizeof(jerr)); |
| 340 FXSYS_memset(&src, 0, sizeof(src)); | 338 FXSYS_memset(&src, 0, sizeof(src)); |
| 341 m_nDefaultScaleDenom = 1; | 339 m_nDefaultScaleDenom = 1; |
| 342 } | 340 } |
| 343 CCodec_JpegDecoder::~CCodec_JpegDecoder() { | 341 CCodec_JpegDecoder::~CCodec_JpegDecoder() { |
| 344 if (m_pExtProvider) { | 342 if (m_pExtProvider) { |
| 345 m_pExtProvider->DestroyDecoder(m_pExtContext); | 343 m_pExtProvider->DestroyDecoder(m_pExtContext); |
| 346 return; | 344 return; |
| 347 } | 345 } |
| 348 if (m_pScanlineBuf) { | 346 FX_Free(m_pScanlineBuf); |
| 349 FX_Free(m_pScanlineBuf); | |
| 350 } | |
| 351 if (m_bInited) { | 347 if (m_bInited) { |
| 352 jpeg_destroy_decompress(&cinfo); | 348 jpeg_destroy_decompress(&cinfo); |
| 353 } | 349 } |
| 354 } | 350 } |
| 355 FX_BOOL CCodec_JpegDecoder::InitDecode() { | 351 FX_BOOL CCodec_JpegDecoder::InitDecode() { |
| 356 cinfo.err = &jerr; | 352 cinfo.err = &jerr; |
| 357 cinfo.client_data = &m_JmpBuf; | 353 cinfo.client_data = &m_JmpBuf; |
| 358 if (setjmp(m_JmpBuf) == -1) { | 354 if (setjmp(m_JmpBuf) == -1) { |
| 359 return FALSE; | 355 return FALSE; |
| 360 } | 356 } |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 } | 708 } |
| 713 if (avail_buf_ptr != NULL) { | 709 if (avail_buf_ptr != NULL) { |
| 714 *avail_buf_ptr = NULL; | 710 *avail_buf_ptr = NULL; |
| 715 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 711 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
| 716 *avail_buf_ptr = | 712 *avail_buf_ptr = |
| 717 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; | 713 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; |
| 718 } | 714 } |
| 719 } | 715 } |
| 720 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 716 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
| 721 } | 717 } |
| OLD | NEW |