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/include/fxcodec/fx_codec.h" | 10 #include "core/include/fxcodec/fx_codec.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { | 51 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { |
52 if (pJbig2Content) { | 52 if (pJbig2Content) { |
53 CJBig2_Context::DestroyContext( | 53 CJBig2_Context::DestroyContext( |
54 ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); | 54 ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); |
55 delete (CCodec_Jbig2Context*)pJbig2Content; | 55 delete (CCodec_Jbig2Context*)pJbig2Content; |
56 } | 56 } |
57 pJbig2Content = NULL; | 57 pJbig2Content = NULL; |
58 } | 58 } |
59 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, | 59 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, |
60 CFX_PrivateData* pPrivateData, | 60 CFX_PrivateData* pPrivateData, |
61 FX_DWORD width, | 61 uint32_t width, |
62 FX_DWORD height, | 62 uint32_t height, |
63 CPDF_StreamAcc* src_stream, | 63 CPDF_StreamAcc* src_stream, |
64 CPDF_StreamAcc* global_stream, | 64 CPDF_StreamAcc* global_stream, |
65 uint8_t* dest_buf, | 65 uint8_t* dest_buf, |
66 FX_DWORD dest_pitch, | 66 uint32_t dest_pitch, |
67 IFX_Pause* pPause) { | 67 IFX_Pause* pPause) { |
68 if (!pJbig2Context) { | 68 if (!pJbig2Context) { |
69 return FXCODEC_STATUS_ERR_PARAMS; | 69 return FXCODEC_STATUS_ERR_PARAMS; |
70 } | 70 } |
71 JBig2DocumentContext* pJBig2DocumentContext = | 71 JBig2DocumentContext* pJBig2DocumentContext = |
72 GetJBig2DocumentContext(this, pPrivateData); | 72 GetJBig2DocumentContext(this, pPrivateData); |
73 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 73 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
74 m_pJbig2Context->m_width = width; | 74 m_pJbig2Context->m_width = width; |
75 m_pJbig2Context->m_height = height; | 75 m_pJbig2Context->m_height = height; |
76 m_pJbig2Context->m_pSrcStream = src_stream; | 76 m_pJbig2Context->m_pSrcStream = src_stream; |
(...skipping 11 matching lines...) Expand all Loading... |
88 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, | 88 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height, |
89 dest_pitch, pPause); | 89 dest_pitch, pPause); |
90 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == | 90 if (m_pJbig2Context->m_pContext->GetProcessingStatus() == |
91 FXCODEC_STATUS_DECODE_FINISH) { | 91 FXCODEC_STATUS_DECODE_FINISH) { |
92 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 92 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
93 m_pJbig2Context->m_pContext = NULL; | 93 m_pJbig2Context->m_pContext = NULL; |
94 if (ret != JBIG2_SUCCESS) { | 94 if (ret != JBIG2_SUCCESS) { |
95 return FXCODEC_STATUS_ERROR; | 95 return FXCODEC_STATUS_ERROR; |
96 } | 96 } |
97 int dword_size = height * dest_pitch / 4; | 97 int dword_size = height * dest_pitch / 4; |
98 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; | 98 uint32_t* dword_buf = (uint32_t*)dest_buf; |
99 for (int i = 0; i < dword_size; i++) { | 99 for (int i = 0; i < dword_size; i++) { |
100 dword_buf[i] = ~dword_buf[i]; | 100 dword_buf[i] = ~dword_buf[i]; |
101 } | 101 } |
102 return FXCODEC_STATUS_DECODE_FINISH; | 102 return FXCODEC_STATUS_DECODE_FINISH; |
103 } | 103 } |
104 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 104 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
105 } | 105 } |
106 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, | 106 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, |
107 IFX_Pause* pPause) { | 107 IFX_Pause* pPause) { |
108 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 108 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
109 int ret = m_pJbig2Context->m_pContext->Continue(pPause); | 109 int ret = m_pJbig2Context->m_pContext->Continue(pPause); |
110 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != | 110 if (m_pJbig2Context->m_pContext->GetProcessingStatus() != |
111 FXCODEC_STATUS_DECODE_FINISH) { | 111 FXCODEC_STATUS_DECODE_FINISH) { |
112 return m_pJbig2Context->m_pContext->GetProcessingStatus(); | 112 return m_pJbig2Context->m_pContext->GetProcessingStatus(); |
113 } | 113 } |
114 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | 114 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
115 m_pJbig2Context->m_pContext = NULL; | 115 m_pJbig2Context->m_pContext = NULL; |
116 if (ret != JBIG2_SUCCESS) { | 116 if (ret != JBIG2_SUCCESS) { |
117 return FXCODEC_STATUS_ERROR; | 117 return FXCODEC_STATUS_ERROR; |
118 } | 118 } |
119 int dword_size = | 119 int dword_size = |
120 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; | 120 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; |
121 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; | 121 uint32_t* dword_buf = (uint32_t*)m_pJbig2Context->m_dest_buf; |
122 for (int i = 0; i < dword_size; i++) { | 122 for (int i = 0; i < dword_size; i++) { |
123 dword_buf[i] = ~dword_buf[i]; | 123 dword_buf[i] = ~dword_buf[i]; |
124 } | 124 } |
125 return FXCODEC_STATUS_DECODE_FINISH; | 125 return FXCODEC_STATUS_DECODE_FINISH; |
126 } | 126 } |
OLD | NEW |