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 CCodec_Jbig2Context::CCodec_Jbig2Context() | 9 CCodec_Jbig2Context::CCodec_Jbig2Context() { |
10 { | 10 FXSYS_memset32(this, 0, sizeof(CCodec_Jbig2Context)); |
11 FXSYS_memset32(this, 0, sizeof(CCodec_Jbig2Context)); | 11 } |
12 } | 12 CCodec_Jbig2Module::~CCodec_Jbig2Module() { |
13 CCodec_Jbig2Module::~CCodec_Jbig2Module() | 13 } |
14 { | 14 void* CCodec_Jbig2Module::CreateJbig2Context() { |
15 } | 15 return FX_NEW CCodec_Jbig2Context(); |
16 void* CCodec_Jbig2Module::CreateJbig2Context() | 16 } |
17 { | 17 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) { |
18 return FX_NEW CCodec_Jbig2Context(); | 18 if (pJbig2Content) { |
19 } | 19 CJBig2_Context::DestroyContext( |
20 void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) | 20 ((CCodec_Jbig2Context*)pJbig2Content)->m_pContext); |
21 { | 21 delete (CCodec_Jbig2Context*)pJbig2Content; |
22 if(pJbig2Content) { | 22 } |
23 CJBig2_Context::DestroyContext(((CCodec_Jbig2Context*)pJbig2Content)->m_
pContext); | 23 pJbig2Content = NULL; |
24 delete (CCodec_Jbig2Context*)pJbig2Content; | 24 } |
25 } | 25 FX_BOOL CCodec_Jbig2Module::Decode(FX_DWORD width, |
26 pJbig2Content = NULL; | 26 FX_DWORD height, |
27 } | 27 FX_LPCBYTE src_buf, |
28 FX_BOOL CCodec_Jbig2Module::Decode(FX_DWORD width, FX_DWORD height, FX_LPCBYTE s
rc_buf, FX_DWORD src_size, | 28 FX_DWORD src_size, |
29 FX_LPCBYTE global_data, FX_DWORD global_size,
FX_LPBYTE dest_buf, FX_DWORD dest_pitch) | 29 FX_LPCBYTE global_data, |
30 { | 30 FX_DWORD global_size, |
31 FXSYS_memset32(dest_buf, 0, height * dest_pitch); | 31 FX_LPBYTE dest_buf, |
32 CJBig2_Context* pContext = CJBig2_Context::CreateContext(&m_Module, | 32 FX_DWORD dest_pitch) { |
33 (FX_LPBYTE)global_data, global_size, (FX_LPBYTE)s
rc_buf, src_size, JBIG2_EMBED_STREAM); | 33 FXSYS_memset32(dest_buf, 0, height * dest_pitch); |
34 if (pContext == NULL) { | 34 CJBig2_Context* pContext = |
35 return FALSE; | 35 CJBig2_Context::CreateContext(&m_Module, |
36 } | 36 (FX_LPBYTE)global_data, |
37 int ret = pContext->getFirstPage(dest_buf, width, height, dest_pitch, NULL); | 37 global_size, |
38 CJBig2_Context::DestroyContext(pContext); | 38 (FX_LPBYTE)src_buf, |
| 39 src_size, |
| 40 JBIG2_EMBED_STREAM); |
| 41 if (pContext == NULL) { |
| 42 return FALSE; |
| 43 } |
| 44 int ret = pContext->getFirstPage(dest_buf, width, height, dest_pitch, NULL); |
| 45 CJBig2_Context::DestroyContext(pContext); |
| 46 if (ret != JBIG2_SUCCESS) { |
| 47 return FALSE; |
| 48 } |
| 49 int dword_size = height * dest_pitch / 4; |
| 50 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; |
| 51 for (int i = 0; i < dword_size; i++) { |
| 52 dword_buf[i] = ~dword_buf[i]; |
| 53 } |
| 54 return TRUE; |
| 55 } |
| 56 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, |
| 57 FX_DWORD& width, |
| 58 FX_DWORD& height, |
| 59 FX_DWORD& pitch, |
| 60 FX_LPBYTE& dest_buf) { |
| 61 CJBig2_Context* pContext = NULL; |
| 62 CJBig2_Image* dest_image = NULL; |
| 63 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); |
| 64 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); |
| 65 if (src_buf == NULL) { |
| 66 return FALSE; |
| 67 } |
| 68 int ret = 0; |
| 69 if (!file_ptr->ReadBlock(src_buf, 0, src_size)) { |
| 70 goto failed; |
| 71 } |
| 72 pContext = CJBig2_Context::CreateContext( |
| 73 &m_Module, NULL, 0, src_buf, src_size, JBIG2_FILE_STREAM); |
| 74 if (pContext == NULL) { |
| 75 goto failed; |
| 76 } |
| 77 ret = pContext->getFirstPage(&dest_image, NULL); |
| 78 CJBig2_Context::DestroyContext(pContext); |
| 79 if (ret != JBIG2_SUCCESS) { |
| 80 goto failed; |
| 81 } |
| 82 width = (FX_DWORD)dest_image->m_nWidth; |
| 83 height = (FX_DWORD)dest_image->m_nHeight; |
| 84 pitch = (FX_DWORD)dest_image->m_nStride; |
| 85 dest_buf = dest_image->m_pData; |
| 86 dest_image->m_bNeedFree = FALSE; |
| 87 delete dest_image; |
| 88 FX_Free(src_buf); |
| 89 return TRUE; |
| 90 failed: |
| 91 if (src_buf) { |
| 92 FX_Free(src_buf); |
| 93 } |
| 94 return FALSE; |
| 95 } |
| 96 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, |
| 97 FX_DWORD width, |
| 98 FX_DWORD height, |
| 99 FX_LPCBYTE src_buf, |
| 100 FX_DWORD src_size, |
| 101 FX_LPCBYTE global_data, |
| 102 FX_DWORD global_size, |
| 103 FX_LPBYTE dest_buf, |
| 104 FX_DWORD dest_pitch, |
| 105 IFX_Pause* pPause) { |
| 106 if (!pJbig2Context) { |
| 107 return FXCODEC_STATUS_ERR_PARAMS; |
| 108 } |
| 109 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 110 m_pJbig2Context->m_width = width; |
| 111 m_pJbig2Context->m_height = height; |
| 112 m_pJbig2Context->m_src_buf = (unsigned char*)src_buf; |
| 113 m_pJbig2Context->m_src_size = src_size; |
| 114 m_pJbig2Context->m_global_data = global_data; |
| 115 m_pJbig2Context->m_global_size = global_size; |
| 116 m_pJbig2Context->m_dest_buf = dest_buf; |
| 117 m_pJbig2Context->m_dest_pitch = dest_pitch; |
| 118 m_pJbig2Context->m_pPause = pPause; |
| 119 m_pJbig2Context->m_bFileReader = FALSE; |
| 120 FXSYS_memset32(dest_buf, 0, height * dest_pitch); |
| 121 m_pJbig2Context->m_pContext = |
| 122 CJBig2_Context::CreateContext(&m_Module, |
| 123 (FX_LPBYTE)global_data, |
| 124 global_size, |
| 125 (FX_LPBYTE)src_buf, |
| 126 src_size, |
| 127 JBIG2_EMBED_STREAM, |
| 128 pPause); |
| 129 if (!m_pJbig2Context->m_pContext) { |
| 130 return FXCODEC_STATUS_ERROR; |
| 131 } |
| 132 int ret = m_pJbig2Context->m_pContext->getFirstPage( |
| 133 dest_buf, width, height, dest_pitch, pPause); |
| 134 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() == |
| 135 FXCODEC_STATUS_DECODE_FINISH) { |
| 136 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 137 m_pJbig2Context->m_pContext = NULL; |
39 if (ret != JBIG2_SUCCESS) { | 138 if (ret != JBIG2_SUCCESS) { |
40 return FALSE; | 139 return FXCODEC_STATUS_ERROR; |
41 } | 140 } |
42 int dword_size = height * dest_pitch / 4; | 141 int dword_size = height * dest_pitch / 4; |
43 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; | 142 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; |
44 for (int i = 0; i < dword_size; i ++) { | 143 for (int i = 0; i < dword_size; i++) { |
45 dword_buf[i] = ~dword_buf[i]; | 144 dword_buf[i] = ~dword_buf[i]; |
46 } | 145 } |
47 return TRUE; | 146 return FXCODEC_STATUS_DECODE_FINISH; |
48 } | 147 } |
49 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, | 148 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); |
50 FX_DWORD& width, FX_DWORD& height, FX_DWORD&
pitch, FX_LPBYTE& dest_buf) | 149 } |
51 { | 150 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, |
52 CJBig2_Context* pContext = NULL; | 151 IFX_FileRead* file_ptr, |
53 CJBig2_Image* dest_image = NULL; | 152 FX_DWORD& width, |
54 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); | 153 FX_DWORD& height, |
55 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); | 154 FX_DWORD& pitch, |
56 if (src_buf == NULL) { | 155 FX_LPBYTE& dest_buf, |
57 return FALSE; | 156 IFX_Pause* pPause) { |
58 } | 157 if (!pJbig2Context) { |
59 int ret = 0; | 158 return FXCODEC_STATUS_ERR_PARAMS; |
60 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { | 159 } |
61 goto failed; | 160 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
62 } | 161 m_pJbig2Context->m_bFileReader = TRUE; |
63 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si
ze, JBIG2_FILE_STREAM); | 162 m_pJbig2Context->m_dest_image = NULL; |
64 if(pContext == NULL) { | 163 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); |
65 goto failed; | 164 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); |
66 } | 165 if (m_pJbig2Context->m_src_buf == NULL) { |
67 ret = pContext->getFirstPage(&dest_image, NULL); | 166 return FXCODEC_STATUS_ERR_MEMORY; |
68 CJBig2_Context::DestroyContext(pContext); | 167 } |
69 if (ret != JBIG2_SUCCESS) { | 168 int ret = 0; |
70 goto failed; | 169 if (!file_ptr->ReadBlock( |
71 } | 170 (void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Context->m_src_size)) { |
72 width = (FX_DWORD)dest_image->m_nWidth; | 171 goto failed; |
73 height = (FX_DWORD)dest_image->m_nHeight; | 172 } |
74 pitch = (FX_DWORD)dest_image->m_nStride; | 173 m_pJbig2Context->m_pContext = |
75 dest_buf = dest_image->m_pData; | 174 CJBig2_Context::CreateContext(&m_Module, |
76 dest_image->m_bNeedFree = FALSE; | 175 NULL, |
77 delete dest_image; | 176 0, |
78 FX_Free(src_buf); | 177 m_pJbig2Context->m_src_buf, |
79 return TRUE; | 178 m_pJbig2Context->m_src_size, |
80 failed: | 179 JBIG2_FILE_STREAM, |
81 if(src_buf) { | 180 pPause); |
82 FX_Free(src_buf); | 181 if (m_pJbig2Context->m_pContext == NULL) { |
83 } | 182 goto failed; |
84 return FALSE; | 183 } |
85 } | 184 ret = m_pJbig2Context->m_pContext->getFirstPage( |
86 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, FX_DWORD wid
th, FX_DWORD height, FX_LPCBYTE src_buf, FX_DWORD src_size, | 185 &m_pJbig2Context->m_dest_image, pPause); |
87 FX_LPCBYTE global_data, FX_DWORD global_size, FX_LPBYTE dest_buf, FX_DWO
RD dest_pitch, IFX_Pause* pPause) | 186 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() == |
88 { | 187 FXCODEC_STATUS_DECODE_TOBECONTINUE) { |
89 if(!pJbig2Context) { | |
90 return FXCODEC_STATUS_ERR_PARAMS; | |
91 } | |
92 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | |
93 m_pJbig2Context->m_width = width; | |
94 m_pJbig2Context->m_height = height; | |
95 m_pJbig2Context->m_src_buf = (unsigned char *)src_buf; | |
96 m_pJbig2Context->m_src_size = src_size; | |
97 m_pJbig2Context->m_global_data = global_data; | |
98 m_pJbig2Context->m_global_size = global_size; | |
99 m_pJbig2Context->m_dest_buf = dest_buf; | |
100 m_pJbig2Context->m_dest_pitch = dest_pitch; | |
101 m_pJbig2Context->m_pPause = pPause; | |
102 m_pJbig2Context->m_bFileReader = FALSE; | |
103 FXSYS_memset32(dest_buf, 0, height * dest_pitch); | |
104 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, | |
105 (FX_LPBYTE)global_data, global_size, (FX_LPBYT
E)src_buf, src_size, JBIG2_EMBED_STREAM, pPause); | |
106 if(!m_pJbig2Context->m_pContext) { | |
107 return FXCODEC_STATUS_ERROR; | |
108 } | |
109 int ret = m_pJbig2Context->m_pContext->getFirstPage(dest_buf, width, height,
dest_pitch, pPause); | |
110 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO
DE_FINISH) { | |
111 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | |
112 m_pJbig2Context->m_pContext = NULL; | |
113 if (ret != JBIG2_SUCCESS) { | |
114 return FXCODEC_STATUS_ERROR; | |
115 } | |
116 int dword_size = height * dest_pitch / 4; | |
117 FX_DWORD* dword_buf = (FX_DWORD*)dest_buf; | |
118 for (int i = 0; i < dword_size; i ++) { | |
119 dword_buf[i] = ~dword_buf[i]; | |
120 } | |
121 return FXCODEC_STATUS_DECODE_FINISH; | |
122 } | |
123 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); | |
124 } | |
125 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
* file_ptr, | |
126 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf,
IFX_Pause* pPause) | |
127 { | |
128 if(!pJbig2Context) { | |
129 return FXCODEC_STATUS_ERR_PARAMS; | |
130 } | |
131 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | |
132 m_pJbig2Context->m_bFileReader = TRUE; | |
133 m_pJbig2Context->m_dest_image = NULL; | |
134 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); | |
135 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); | |
136 if (m_pJbig2Context->m_src_buf == NULL) { | |
137 return FXCODEC_STATUS_ERR_MEMORY; | |
138 } | |
139 int ret = 0; | |
140 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex
t->m_src_size)) { | |
141 goto failed; | |
142 } | |
143 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, NULL,
0, m_pJbig2Context->m_src_buf, m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM,
pPause); | |
144 if(m_pJbig2Context->m_pContext == NULL) { | |
145 goto failed; | |
146 } | |
147 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima
ge, pPause); | |
148 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO
DE_TOBECONTINUE) { | |
149 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth; | |
150 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight; | |
151 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride; | |
152 dest_buf = m_pJbig2Context->m_dest_image->m_pData; | |
153 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE; | |
154 return FXCODEC_STATUS_DECODE_TOBECONTINUE; | |
155 } | |
156 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | |
157 m_pJbig2Context->m_pContext = NULL; | |
158 if (ret != JBIG2_SUCCESS) { | |
159 goto failed; | |
160 } | |
161 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth; | 188 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth; |
162 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight; | 189 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight; |
163 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride; | 190 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride; |
164 dest_buf = m_pJbig2Context->m_dest_image->m_pData; | 191 dest_buf = m_pJbig2Context->m_dest_image->m_pData; |
165 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE; | 192 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE; |
166 delete m_pJbig2Context->m_dest_image; | 193 return FXCODEC_STATUS_DECODE_TOBECONTINUE; |
| 194 } |
| 195 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 196 m_pJbig2Context->m_pContext = NULL; |
| 197 if (ret != JBIG2_SUCCESS) { |
| 198 goto failed; |
| 199 } |
| 200 width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth; |
| 201 height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight; |
| 202 pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride; |
| 203 dest_buf = m_pJbig2Context->m_dest_image->m_pData; |
| 204 m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE; |
| 205 delete m_pJbig2Context->m_dest_image; |
| 206 FX_Free(m_pJbig2Context->m_src_buf); |
| 207 return FXCODEC_STATUS_DECODE_FINISH; |
| 208 failed: |
| 209 if (m_pJbig2Context->m_src_buf) { |
167 FX_Free(m_pJbig2Context->m_src_buf); | 210 FX_Free(m_pJbig2Context->m_src_buf); |
168 return FXCODEC_STATUS_DECODE_FINISH; | 211 } |
169 failed: | 212 m_pJbig2Context->m_src_buf = NULL; |
170 if(m_pJbig2Context->m_src_buf) { | 213 return FXCODEC_STATUS_ERROR; |
171 FX_Free(m_pJbig2Context->m_src_buf); | 214 } |
| 215 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, |
| 216 IFX_Pause* pPause) { |
| 217 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
| 218 int ret = m_pJbig2Context->m_pContext->Continue(pPause); |
| 219 if (m_pJbig2Context->m_pContext->GetProcessiveStatus() == |
| 220 FXCODEC_STATUS_DECODE_FINISH) { |
| 221 if (m_pJbig2Context->m_bFileReader) { |
| 222 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 223 m_pJbig2Context->m_pContext = NULL; |
| 224 if (ret != JBIG2_SUCCESS) { |
| 225 if (m_pJbig2Context->m_src_buf) { |
| 226 FX_Free(m_pJbig2Context->m_src_buf); |
| 227 } |
| 228 m_pJbig2Context->m_src_buf = NULL; |
| 229 return FXCODEC_STATUS_ERROR; |
| 230 } |
| 231 delete m_pJbig2Context->m_dest_image; |
| 232 FX_Free(m_pJbig2Context->m_src_buf); |
| 233 return FXCODEC_STATUS_DECODE_FINISH; |
| 234 } else { |
| 235 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); |
| 236 m_pJbig2Context->m_pContext = NULL; |
| 237 if (ret != JBIG2_SUCCESS) { |
| 238 return FXCODEC_STATUS_ERROR; |
| 239 } |
| 240 int dword_size = |
| 241 m_pJbig2Context->m_height * m_pJbig2Context->m_dest_pitch / 4; |
| 242 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; |
| 243 for (int i = 0; i < dword_size; i++) { |
| 244 dword_buf[i] = ~dword_buf[i]; |
| 245 } |
| 246 return FXCODEC_STATUS_DECODE_FINISH; |
172 } | 247 } |
173 m_pJbig2Context->m_src_buf = NULL; | 248 } |
174 return FXCODEC_STATUS_ERROR; | 249 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); |
175 } | 250 } |
176 FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context, IFX_Pause
* pPause) | |
177 { | |
178 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | |
179 int ret = m_pJbig2Context->m_pContext->Continue(pPause); | |
180 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO
DE_FINISH) { | |
181 if(m_pJbig2Context->m_bFileReader) { | |
182 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | |
183 m_pJbig2Context->m_pContext = NULL; | |
184 if (ret != JBIG2_SUCCESS) { | |
185 if(m_pJbig2Context->m_src_buf) { | |
186 FX_Free(m_pJbig2Context->m_src_buf); | |
187 } | |
188 m_pJbig2Context->m_src_buf = NULL; | |
189 return FXCODEC_STATUS_ERROR; | |
190 } | |
191 delete m_pJbig2Context->m_dest_image; | |
192 FX_Free(m_pJbig2Context->m_src_buf); | |
193 return FXCODEC_STATUS_DECODE_FINISH; | |
194 } else { | |
195 CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext); | |
196 m_pJbig2Context->m_pContext = NULL; | |
197 if (ret != JBIG2_SUCCESS) { | |
198 return FXCODEC_STATUS_ERROR; | |
199 } | |
200 int dword_size = m_pJbig2Context->m_height * m_pJbig2Context->m_dest
_pitch / 4; | |
201 FX_DWORD* dword_buf = (FX_DWORD*)m_pJbig2Context->m_dest_buf; | |
202 for (int i = 0; i < dword_size; i ++) { | |
203 dword_buf[i] = ~dword_buf[i]; | |
204 } | |
205 return FXCODEC_STATUS_DECODE_FINISH; | |
206 } | |
207 } | |
208 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); | |
209 } | |
210 | |
211 | |
212 | |
OLD | NEW |