| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 m_pJbig2Context->m_bFileReader = FALSE; | 48 m_pJbig2Context->m_bFileReader = FALSE; |
| 49 FXSYS_memset(dest_buf, 0, height * dest_pitch); | 49 FXSYS_memset(dest_buf, 0, height * dest_pitch); |
| 50 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext( | 50 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext( |
| 51 global_data, global_size, src_buf, src_size, JBIG2_EMBED_STREAM, | 51 global_data, global_size, src_buf, src_size, JBIG2_EMBED_STREAM, |
| 52 &m_SymbolDictCache, pPause); | 52 &m_SymbolDictCache, pPause); |
| 53 if (!m_pJbig2Context->m_pContext) { | 53 if (!m_pJbig2Context->m_pContext) { |
| 54 return FXCODEC_STATUS_ERROR; | 54 return FXCODEC_STATUS_ERROR; |
| 55 } | 55 } |
| 56 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, | 56 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, |
| 57 dest_pitch, pPause); | 57 dest_pitch, pPause); |
| 58 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() == | 58 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == |
| 59 FXCODEC_STATUS_DECODE_FINISH) { | 59 FXCODEC_STATUS_DECODE_FINISH) { |
| 60 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 60 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 61 m_pJbig2Context->m_pContext = NULL; | 61 m_pJbig2Context->m_pContext = NULL; |
| 62 if (ret != JBIG2_SUCCESS) { | 62 if (ret != JBIG2_SUCCESS) { |
| 63 return FXCODEC_STATUS_ERROR; | 63 return FXCODEC_STATUS_ERROR; |
| 64 } | 64 } |
| 65 int dword_size = height * dest_pitch / 4; | 65 int dword_size = height * dest_pitch / 4; |
| 66 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; | 66 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; |
| 67 for (int i = 0; i < dword_size; i++) { | 67 for (int i = 0; i < dword_size; i++) { |
| 68 dword_buf[i] = ~dword_buf[i]; | 68 dword_buf[i] = ~dword_buf[i]; |
| 69 } | 69 } |
| 70 return FXCODEC_STATUS_DECODE_FINISH; | 70 return FXCODEC_STATUS_DECODE_FINISH; |
| 71 } | 71 } |
| 72 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); | 72 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 73 } | 73 } |
| 74 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, | 74 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, |
| 75 IFX_Pause* pPause) { | 75 IFX_Pause* pPause) { |
| 76 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 76 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 77 int ret = m_pJbig2Context->m_pContext->Continue(pPause); | 77 int ret = m_pJbig2Context->m_pContext->Continue(pPause); |
| 78 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() != | 78 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != |
| 79 FXCODEC_STATUS_DECODE_FINISH) { | 79 FXCODEC_STATUS_DECODE_FINISH) { |
| 80 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); | 80 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 81 } | 81 } |
| 82 if (m_pJbig2Context->m_bFileReader) { | 82 if (m_pJbig2Context->m_bFileReader) { |
| 83 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 83 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 84 m_pJbig2Context->m_pContext = NULL; | 84 m_pJbig2Context->m_pContext = NULL; |
| 85 if (ret != JBIG2_SUCCESS) { | 85 if (ret != JBIG2_SUCCESS) { |
| 86 FX_Free(m_pJbig2Context->m_src_buf); | 86 FX_Free(m_pJbig2Context->m_src_buf); |
| 87 m_pJbig2Context->m_src_buf = NULL; | 87 m_pJbig2Context->m_src_buf = NULL; |
| 88 return FXCODEC_STATUS_ERROR; | 88 return FXCODEC_STATUS_ERROR; |
| 89 } | 89 } |
| 90 delete m_pJbig2Context->m_dest_image; | 90 delete m_pJbig2Context->m_dest_image; |
| 91 FX_Free(m_pJbig2Context->m_src_buf); | 91 FX_Free(m_pJbig2Context->m_src_buf); |
| 92 return FXCODEC_STATUS_DECODE_FINISH; | 92 return FXCODEC_STATUS_DECODE_FINISH; |
| 93 } | 93 } |
| 94 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 94 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 95 m_pJbig2Context->m_pContext = NULL; | 95 m_pJbig2Context->m_pContext = NULL; |
| 96 if (ret != JBIG2_SUCCESS) { | 96 if (ret != JBIG2_SUCCESS) { |
| 97 return FXCODEC_STATUS_ERROR; | 97 return FXCODEC_STATUS_ERROR; |
| 98 } | 98 } |
| 99 int dword_size = | 99 int dword_size = |
| 100 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; | 100 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; |
| 101 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; | 101 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; |
| 102 for (int i = 0; i < dword_size; i++) { | 102 for (int i = 0; i < dword_size; i++) { |
| 103 dword_buf[i] = ~dword_buf[i]; | 103 dword_buf[i] = ~dword_buf[i]; |
| 104 } | 104 } |
| 105 return FXCODEC_STATUS_DECODE_FINISH; | 105 return FXCODEC_STATUS_DECODE_FINISH; |
| 106 } | 106 } |
| OLD | NEW |