| 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 <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "core/fxcodec/codec/codec_int.h" | 9 #include "core/fxcodec/codec/codec_int.h" |
| 10 #include "core/fxcodec/include/fx_codec.h" | 10 #include "core/fxcodec/include/fx_codec.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void* CCodec_Jbig2Module::CreateJbig2Context() { | 62 void* CCodec_Jbig2Module::CreateJbig2Context() { |
| 63 return new CCodec_Jbig2Context(); | 63 return new CCodec_Jbig2Context(); |
| 64 } | 64 } |
| 65 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { | 65 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { |
| 66 if (pJbig2Content) { | 66 if (pJbig2Content) { |
| 67 CJBig2_Context::DestroyContext( | 67 CJBig2_Context::DestroyContext( |
| 68 ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); | 68 ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); |
| 69 delete (CCodec_Jbig2Context*)pJbig2Content; | 69 delete (CCodec_Jbig2Context*)pJbig2Content; |
| 70 } | 70 } |
| 71 pJbig2Content = NULL; | 71 pJbig2Content = nullptr; |
| 72 } | 72 } |
| 73 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( | 73 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode( |
| 74 void* pJbig2Context, | 74 void* pJbig2Context, |
| 75 std::unique_ptr<CFX_Deletable>* pContextHolder, | 75 std::unique_ptr<CFX_Deletable>* pContextHolder, |
| 76 uint32_t width, | 76 uint32_t width, |
| 77 uint32_t height, | 77 uint32_t height, |
| 78 CPDF_StreamAcc* src_stream, | 78 CPDF_StreamAcc* src_stream, |
| 79 CPDF_StreamAcc* global_stream, | 79 CPDF_StreamAcc* global_stream, |
| 80 uint8_t* dest_buf, | 80 uint8_t* dest_buf, |
| 81 uint32_t dest_pitch, | 81 uint32_t dest_pitch, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 98 global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(), | 98 global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(), |
| 99 pPause); | 99 pPause); |
| 100 if (!m_pJbig2Context->m_pContext) { | 100 if (!m_pJbig2Context->m_pContext) { |
| 101 return FXCODEC_STATUS_ERROR; | 101 return FXCODEC_STATUS_ERROR; |
| 102 } | 102 } |
| 103 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, | 103 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, |
| 104 dest_pitch, pPause); | 104 dest_pitch, pPause); |
| 105 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == | 105 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == |
| 106 FXCODEC_STATUS_DECODE_FINISH) { | 106 FXCODEC_STATUS_DECODE_FINISH) { |
| 107 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 107 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 108 m_pJbig2Context->m_pContext = NULL; | 108 m_pJbig2Context->m_pContext = nullptr; |
| 109 if (ret != JBIG2_SUCCESS) { | 109 if (ret != JBIG2_SUCCESS) { |
| 110 return FXCODEC_STATUS_ERROR; | 110 return FXCODEC_STATUS_ERROR; |
| 111 } | 111 } |
| 112 int dword_size = height * dest_pitch / 4; | 112 int dword_size = height * dest_pitch / 4; |
| 113 uint32_t* dword_buf = (uint32_t*)dest_buf; | 113 uint32_t* dword_buf = (uint32_t*)dest_buf; |
| 114 for (int i = 0; i < dword_size; i++) { | 114 for (int i = 0; i < dword_size; i++) { |
| 115 dword_buf[i] = ~dword_buf[i]; | 115 dword_buf[i] = ~dword_buf[i]; |
| 116 } | 116 } |
| 117 return FXCODEC_STATUS_DECODE_FINISH; | 117 return FXCODEC_STATUS_DECODE_FINISH; |
| 118 } | 118 } |
| 119 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 119 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 120 } | 120 } |
| 121 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, | 121 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, |
| 122 IFX_Pause* pPause) { | 122 IFX_Pause* pPause) { |
| 123 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 123 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 124 int ret = m_pJbig2Context->m_pContext->Continue(pPause); | 124 int ret = m_pJbig2Context->m_pContext->Continue(pPause); |
| 125 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != | 125 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != |
| 126 FXCODEC_STATUS_DECODE_FINISH) { | 126 FXCODEC_STATUS_DECODE_FINISH) { |
| 127 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 127 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
| 128 } | 128 } |
| 129 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 129 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 130 m_pJbig2Context->m_pContext = NULL; | 130 m_pJbig2Context->m_pContext = nullptr; |
| 131 if (ret != JBIG2_SUCCESS) { | 131 if (ret != JBIG2_SUCCESS) { |
| 132 return FXCODEC_STATUS_ERROR; | 132 return FXCODEC_STATUS_ERROR; |
| 133 } | 133 } |
| 134 int dword_size = | 134 int dword_size = |
| 135 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; | 135 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; |
| 136 uint32_t* dword_buf = (uint32_t*)m_pJbig2Context->m_dest_buf; | 136 uint32_t* dword_buf = (uint32_t*)m_pJbig2Context->m_dest_buf; |
| 137 for (int i = 0; i < dword_size; i++) { | 137 for (int i = 0; i < dword_size; i++) { |
| 138 dword_buf[i] = ~dword_buf[i]; | 138 dword_buf[i] = ~dword_buf[i]; |
| 139 } | 139 } |
| 140 return FXCODEC_STATUS_DECODE_FINISH; | 140 return FXCODEC_STATUS_DECODE_FINISH; |
| 141 } | 141 } |
| OLD | NEW |