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 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 dword_buf[i] = ~dword_buf[i]; | 45 dword_buf[i] = ~dword_buf[i]; |
46 } | 46 } |
47 return TRUE; | 47 return TRUE; |
48 } | 48 } |
49 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, | 49 FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, |
50 FX_DWORD& width, FX_DWORD& height, FX_DWORD&
pitch, FX_LPBYTE& dest_buf) | 50 FX_DWORD& width, FX_DWORD& height, FX_DWORD&
pitch, FX_LPBYTE& dest_buf) |
51 { | 51 { |
52 CJBig2_Context* pContext = NULL; | 52 CJBig2_Context* pContext = NULL; |
53 CJBig2_Image* dest_image = NULL; | 53 CJBig2_Image* dest_image = NULL; |
54 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); | 54 FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize(); |
55 FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size); | 55 FX_LPBYTE src_buf = FX_Alloc(uint8_t, src_size); |
56 int ret = 0; | 56 int ret = 0; |
57 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { | 57 if(!file_ptr->ReadBlock(src_buf, 0, src_size)) { |
58 goto failed; | 58 goto failed; |
59 } | 59 } |
60 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si
ze, JBIG2_FILE_STREAM, &m_SymbolDictCache); | 60 pContext = CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_si
ze, JBIG2_FILE_STREAM, &m_SymbolDictCache); |
61 if(pContext == NULL) { | 61 if(pContext == NULL) { |
62 goto failed; | 62 goto failed; |
63 } | 63 } |
64 ret = pContext->getFirstPage(&dest_image, NULL); | 64 ret = pContext->getFirstPage(&dest_image, NULL); |
65 CJBig2_Context::DestroyContext(pContext); | 65 CJBig2_Context::DestroyContext(pContext); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
* file_ptr, | 122 FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead
* file_ptr, |
123 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf,
IFX_Pause* pPause) | 123 FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, FX_LPBYTE& dest_buf,
IFX_Pause* pPause) |
124 { | 124 { |
125 if(!pJbig2Context) { | 125 if(!pJbig2Context) { |
126 return FXCODEC_STATUS_ERR_PARAMS; | 126 return FXCODEC_STATUS_ERR_PARAMS; |
127 } | 127 } |
128 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; | 128 CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context; |
129 m_pJbig2Context->m_bFileReader = TRUE; | 129 m_pJbig2Context->m_bFileReader = TRUE; |
130 m_pJbig2Context->m_dest_image = NULL; | 130 m_pJbig2Context->m_dest_image = NULL; |
131 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); | 131 m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize(); |
132 m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size); | 132 m_pJbig2Context->m_src_buf = FX_Alloc(uint8_t, m_pJbig2Context->m_src_size); |
133 int ret = 0; | 133 int ret = 0; |
134 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex
t->m_src_size)) { | 134 if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Contex
t->m_src_size)) { |
135 goto failed; | 135 goto failed; |
136 } | 136 } |
137 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, NULL,
0, m_pJbig2Context->m_src_buf, m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM,
&m_SymbolDictCache, pPause); | 137 m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(&m_Module, NULL,
0, m_pJbig2Context->m_src_buf, m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM,
&m_SymbolDictCache, pPause); |
138 if(m_pJbig2Context->m_pContext == NULL) { | 138 if(m_pJbig2Context->m_pContext == NULL) { |
139 goto failed; | 139 goto failed; |
140 } | 140 } |
141 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima
ge, pPause); | 141 ret = m_pJbig2Context->m_pContext->getFirstPage(&m_pJbig2Context->m_dest_ima
ge, pPause); |
142 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO
DE_TOBECONTINUE) { | 142 if(m_pJbig2Context->m_pContext->GetProcessiveStatus() == FXCODEC_STATUS_DECO
DE_TOBECONTINUE) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 dword_buf[i] = ~dword_buf[i]; | 197 dword_buf[i] = ~dword_buf[i]; |
198 } | 198 } |
199 return FXCODEC_STATUS_DECODE_FINISH; | 199 return FXCODEC_STATUS_DECODE_FINISH; |
200 } | 200 } |
201 } | 201 } |
202 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); | 202 return m_pJbig2Context->m_pContext->GetProcessiveStatus(); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 | 206 |
OLD | NEW |