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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 } | 708 } |
709 if (ret != JPEG_HEADER_OK) { | 709 if (ret != JPEG_HEADER_OK) { |
710 return 1; | 710 return 1; |
711 } | 711 } |
712 *width = p->m_Info.image_width; | 712 *width = p->m_Info.image_width; |
713 *height = p->m_Info.image_height; | 713 *height = p->m_Info.image_height; |
714 *nComps = p->m_Info.num_components; | 714 *nComps = p->m_Info.num_components; |
715 _JpegLoadAttribute(&p->m_Info, pAttribute); | 715 _JpegLoadAttribute(&p->m_Info, pAttribute); |
716 return 0; | 716 return 0; |
717 } | 717 } |
718 FX_BOOL CCodec_JpegModule::StartScanline(void* pContext, int down_scale) | 718 int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) |
719 { | 719 { |
720 if (m_pExtProvider) { | 720 if (m_pExtProvider) { |
721 return m_pExtProvider->StartScanline(pContext, down_scale); | 721 return m_pExtProvider->StartScanline(pContext, down_scale); |
722 } | 722 } |
723 FXJPEG_Context* p = (FXJPEG_Context*)pContext; | 723 FXJPEG_Context* p = (FXJPEG_Context*)pContext; |
724 if (setjmp(p->m_JumpMark) == -1) { | 724 if (setjmp(p->m_JumpMark) == -1) { |
725 return FALSE; | 725 return 0; |
726 } | 726 } |
727 p->m_Info.scale_denom = down_scale; | 727 p->m_Info.scale_denom = down_scale; |
728 return jpeg_start_decompress(&p->m_Info); | 728 return jpeg_start_decompress(&p->m_Info); |
729 } | 729 } |
730 FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, unsigned char* dest_buf) | 730 FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, unsigned char* dest_buf) |
731 { | 731 { |
732 if (m_pExtProvider) { | 732 if (m_pExtProvider) { |
733 return m_pExtProvider->ReadScanline(pContext, dest_buf); | 733 return m_pExtProvider->ReadScanline(pContext, dest_buf); |
734 } | 734 } |
735 FXJPEG_Context* p = (FXJPEG_Context*)pContext; | 735 FXJPEG_Context* p = (FXJPEG_Context*)pContext; |
736 if (setjmp(p->m_JumpMark) == -1) { | 736 if (setjmp(p->m_JumpMark) == -1) { |
737 return FALSE; | 737 return FALSE; |
738 } | 738 } |
739 int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1); | 739 int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1); |
740 return nlines == 1; | 740 return nlines == 1; |
741 } | 741 } |
742 FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext, uint8_t** avail_buf_pt
r) | 742 FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext, uint8_t** avail_buf_pt
r) |
743 { | 743 { |
744 if (m_pExtProvider) { | 744 if (m_pExtProvider) { |
745 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); | 745 return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr); |
746 } | 746 } |
747 if(avail_buf_ptr != NULL) { | 747 if(avail_buf_ptr != NULL) { |
748 *avail_buf_ptr = NULL; | 748 *avail_buf_ptr = NULL; |
749 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { | 749 if(((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { |
750 *avail_buf_ptr = (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.nex
t_input_byte; | 750 *avail_buf_ptr = (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.nex
t_input_byte; |
751 } | 751 } |
752 } | 752 } |
753 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; | 753 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; |
754 } | 754 } |
OLD | NEW |