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 "codec_int.h" | 9 #include "codec_int.h" |
10 #include "core/include/fxcodec/fx_codec.h" | 10 #include "core/include/fxcodec/fx_codec.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; | 223 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; |
224 dest_buf_length += JPEG_BLOCK_SIZE; | 224 dest_buf_length += JPEG_BLOCK_SIZE; |
225 dest.free_in_buffer += JPEG_BLOCK_SIZE; | 225 dest.free_in_buffer += JPEG_BLOCK_SIZE; |
226 } | 226 } |
227 } | 227 } |
228 jpeg_finish_compress(&cinfo); | 228 jpeg_finish_compress(&cinfo); |
229 jpeg_destroy_compress(&cinfo); | 229 jpeg_destroy_compress(&cinfo); |
230 FX_Free(line_buf); | 230 FX_Free(line_buf); |
231 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; | 231 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; |
232 } | 232 } |
| 233 |
233 #ifdef PDF_ENABLE_XFA | 234 #ifdef PDF_ENABLE_XFA |
234 static void _JpegLoadAttribute(struct jpeg_decompress_struct* pInfo, | 235 static void _JpegLoadAttribute(struct jpeg_decompress_struct* pInfo, |
235 CFX_DIBAttribute* pAttribute) { | 236 CFX_DIBAttribute* pAttribute) { |
236 if (pInfo == NULL || pAttribute == NULL) { | 237 if (pInfo == NULL || pAttribute == NULL) { |
237 return; | 238 return; |
238 } | 239 } |
239 if (pAttribute) { | 240 if (pAttribute) { |
240 pAttribute->m_nXDPI = pInfo->X_density; | 241 pAttribute->m_nXDPI = pInfo->X_density; |
241 pAttribute->m_nYDPI = pInfo->Y_density; | 242 pAttribute->m_nYDPI = pInfo->Y_density; |
242 pAttribute->m_wDPIUnit = pInfo->density_unit; | 243 pAttribute->m_wDPIUnit = pInfo->density_unit; |
243 } | 244 } |
244 } | 245 } |
245 #endif | 246 #endif // PDF_ENABLE_XFA |
| 247 |
246 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, | 248 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, |
247 FX_DWORD src_size, | 249 FX_DWORD src_size, |
248 int& width, | 250 int& width, |
249 int& height, | 251 int& height, |
250 int& num_components, | 252 int& num_components, |
251 int& bits_per_components, | 253 int& bits_per_components, |
252 FX_BOOL& color_transform, | 254 FX_BOOL& color_transform, |
253 uint8_t** icc_buf_ptr, | 255 uint8_t** icc_buf_ptr, |
254 FX_DWORD* icc_length) { | 256 FX_DWORD* icc_length) { |
255 _JpegScanSOI(src_buf, src_size); | 257 _JpegScanSOI(src_buf, src_size); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 p->m_SkipSize -= src_size; | 624 p->m_SkipSize -= src_size; |
623 return; | 625 return; |
624 } | 626 } |
625 src_size -= p->m_SkipSize; | 627 src_size -= p->m_SkipSize; |
626 src_buf += p->m_SkipSize; | 628 src_buf += p->m_SkipSize; |
627 p->m_SkipSize = 0; | 629 p->m_SkipSize = 0; |
628 } | 630 } |
629 p->m_SrcMgr.next_input_byte = src_buf; | 631 p->m_SrcMgr.next_input_byte = src_buf; |
630 p->m_SrcMgr.bytes_in_buffer = src_size; | 632 p->m_SrcMgr.bytes_in_buffer = src_size; |
631 } | 633 } |
| 634 |
| 635 #ifdef PDF_ENABLE_XFA |
632 int CCodec_JpegModule::ReadHeader(void* pContext, | 636 int CCodec_JpegModule::ReadHeader(void* pContext, |
633 int* width, | 637 int* width, |
634 int* height, | 638 int* height, |
635 #ifndef PDF_ENABLE_XFA | |
636 int* nComps) { | |
637 #else | |
638 int* nComps, | 639 int* nComps, |
639 CFX_DIBAttribute* pAttribute) { | 640 CFX_DIBAttribute* pAttribute) { |
640 #endif | 641 #else // PDF_ENABLE_XFA |
| 642 int CCodec_JpegModule::ReadHeader(void* pContext, |
| 643 int* width, |
| 644 int* height, |
| 645 int* nComps) { |
| 646 #endif // PDF_ENABLE_XFA |
641 FXJPEG_Context* p = (FXJPEG_Context*)pContext; | 647 FXJPEG_Context* p = (FXJPEG_Context*)pContext; |
642 if (setjmp(p->m_JumpMark) == -1) { | 648 if (setjmp(p->m_JumpMark) == -1) { |
643 return 1; | 649 return 1; |
644 } | 650 } |
645 int ret = jpeg_read_header(&p->m_Info, true); | 651 int ret = jpeg_read_header(&p->m_Info, true); |
646 if (ret == JPEG_SUSPENDED) { | 652 if (ret == JPEG_SUSPENDED) { |
647 return 2; | 653 return 2; |
648 } | 654 } |
649 if (ret != JPEG_HEADER_OK) { | 655 if (ret != JPEG_HEADER_OK) { |
650 return 1; | 656 return 1; |
(...skipping 27 matching lines...) Expand all Loading... |
678 uint8_t** avail_buf_ptr) { | 684 uint8_t** avail_buf_ptr) { |
679 if (avail_buf_ptr != NULL) { | 685 if (avail_buf_ptr != NULL) { |
680 *avail_buf_ptr = NULL; | 686 *avail_buf_ptr = NULL; |
681 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 687 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
682 *avail_buf_ptr = | 688 *avail_buf_ptr = |
683 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; | 689 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; |
684 } | 690 } |
685 } | 691 } |
686 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 692 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
687 } | 693 } |
OLD | NEW |