| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "codec_int.h" | 8 #include "codec_int.h" |
| 9 | 9 |
| 10 CCodec_Jbig2Context::CCodec_Jbig2Context() { | 10 CCodec_Jbig2Context::CCodec_Jbig2Context() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 44 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 45 m_pJbig2Context->m_width = width; | 45 m_pJbig2Context->m_width = width; |
| 46 m_pJbig2Context->m_height = height; | 46 m_pJbig2Context->m_height = height; |
| 47 m_pJbig2Context->m_src_buf = (unsigned char*)src_buf; | 47 m_pJbig2Context->m_src_buf = (unsigned char*)src_buf; |
| 48 m_pJbig2Context->m_src_size = src_size; | 48 m_pJbig2Context->m_src_size = src_size; |
| 49 m_pJbig2Context->m_global_data = global_data; | 49 m_pJbig2Context->m_global_data = global_data; |
| 50 m_pJbig2Context->m_global_size = global_size; | 50 m_pJbig2Context->m_global_size = global_size; |
| 51 m_pJbig2Context->m_dest_buf = dest_buf; | 51 m_pJbig2Context->m_dest_buf = dest_buf; |
| 52 m_pJbig2Context->m_dest_pitch = dest_pitch; | 52 m_pJbig2Context->m_dest_pitch = dest_pitch; |
| 53 m_pJbig2Context->m_pPause = pPause; | 53 m_pJbig2Context->m_pPause = pPause; |
| 54 m_pJbig2Context->m_bFileReader = FALSE; | |
| 55 FXSYS_memset(dest_buf, 0, height * dest_pitch); | 54 FXSYS_memset(dest_buf, 0, height * dest_pitch); |
| 56 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext( | 55 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext( |
| 57 global_data, global_size, src_buf, src_size, &m_SymbolDictCache, pPause); | 56 global_data, global_size, src_buf, src_size, &m_SymbolDictCache, pPause); |
| 58 if (!m_pJbig2Context->m_pContext) { | 57 if (!m_pJbig2Context->m_pContext) { |
| 59 return FXCODEC_STATUS_ERROR; | 58 return FXCODEC_STATUS_ERROR; |
| 60 } | 59 } |
| 61 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, | 60 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, |
| 62 dest_pitch, pPause); | 61 dest_pitch, pPause); |
| 63 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == | 62 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == |
| 64 FXCODEC_STATUS_DECODE_FINISH) { | 63 FXCODEC_STATUS_DECODE_FINISH) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 76 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 78 } | 77 } |
| 79 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, | 78 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, |
| 80 IFX_Pause* pPause) { | 79 IFX_Pause* pPause) { |
| 81 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 80 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 82 int ret = m_pJbig2Context->m_pContext->Continue(pPause); | 81 int ret = m_pJbig2Context->m_pContext->Continue(pPause); |
| 83 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != | 82 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != |
| 84 FXCODEC_STATUS_DECODE_FINISH) { | 83 FXCODEC_STATUS_DECODE_FINISH) { |
| 85 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 84 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 86 } | 85 } |
| 87 if (m_pJbig2Context->m_bFileReader) { | |
| 88 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | |
| 89 m_pJbig2Context->m_pContext = NULL; | |
| 90 if (ret != JBIG2_SUCCESS) { | |
| 91 FX_Free(m_pJbig2Context->m_src_buf); | |
| 92 m_pJbig2Context->m_src_buf = NULL; | |
| 93 return FXCODEC_STATUS_ERROR; | |
| 94 } | |
| 95 delete m_pJbig2Context->m_dest_image; | |
| 96 FX_Free(m_pJbig2Context->m_src_buf); | |
| 97 return FXCODEC_STATUS_DECODE_FINISH; | |
| 98 } | |
| 99 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 86 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 100 m_pJbig2Context->m_pContext = NULL; | 87 m_pJbig2Context->m_pContext = NULL; |
| 101 if (ret != JBIG2_SUCCESS) { | 88 if (ret != JBIG2_SUCCESS) { |
| 102 return FXCODEC_STATUS_ERROR; | 89 return FXCODEC_STATUS_ERROR; |
| 103 } | 90 } |
| 104 int dword_size = | 91 int dword_size = |
| 105 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; | 92 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; |
| 106 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; | 93 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; |
| 107 for (int i = 0; i < dword_size; i++) { | 94 for (int i = 0; i < dword_size; i++) { |
| 108 dword_buf[i] = ~dword_buf[i]; | 95 dword_buf[i] = ~dword_buf[i]; |
| 109 } | 96 } |
| 110 return FXCODEC_STATUS_DECODE_FINISH; | 97 return FXCODEC_STATUS_DECODE_FINISH; |
| 111 } | 98 } |
| OLD | NEW |