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 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 7 #ifndef CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 8 #define CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
9 | 9 |
10 #include <limits.h> | 10 #include <limits.h> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 FX_DWORD* icc_length); | 177 FX_DWORD* icc_length); |
178 FX_BOOL Encode(const CFX_DIBSource* pSource, | 178 FX_BOOL Encode(const CFX_DIBSource* pSource, |
179 uint8_t*& dest_buf, | 179 uint8_t*& dest_buf, |
180 FX_STRSIZE& dest_size, | 180 FX_STRSIZE& dest_size, |
181 int quality, | 181 int quality, |
182 const uint8_t* icc_buf, | 182 const uint8_t* icc_buf, |
183 FX_DWORD icc_length); | 183 FX_DWORD icc_length); |
184 virtual void* Start(); | 184 virtual void* Start(); |
185 virtual void Finish(void* pContext); | 185 virtual void Finish(void* pContext); |
186 virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); | 186 virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); |
| 187 #ifndef PDF_ENABLE_XFA |
187 virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps); | 188 virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps); |
| 189 #else |
| 190 virtual int ReadHeader(void* pContext, |
| 191 int* width, |
| 192 int* height, |
| 193 int* nComps, |
| 194 CFX_DIBAttribute* pAttribute = NULL); |
| 195 #endif |
188 virtual int StartScanline(void* pContext, int down_scale); | 196 virtual int StartScanline(void* pContext, int down_scale); |
189 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf); | 197 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf); |
190 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); | 198 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); |
191 | 199 |
192 protected: | 200 protected: |
193 IFX_JpegProvider* m_pExtProvider; | 201 IFX_JpegProvider* m_pExtProvider; |
194 }; | 202 }; |
| 203 #ifdef PDF_ENABLE_XFA |
| 204 #define PNG_ERROR_SIZE 256 |
| 205 class CCodec_PngModule : public ICodec_PngModule { |
| 206 public: |
| 207 CCodec_PngModule() { FXSYS_memset(m_szLastError, '\0', PNG_ERROR_SIZE); } |
| 208 |
| 209 virtual void* Start(void* pModule); |
| 210 virtual void Finish(void* pContext); |
| 211 virtual FX_BOOL Input(void* pContext, |
| 212 const uint8_t* src_buf, |
| 213 FX_DWORD src_size, |
| 214 CFX_DIBAttribute* pAttribute); |
| 215 |
| 216 protected: |
| 217 FX_CHAR m_szLastError[PNG_ERROR_SIZE]; |
| 218 }; |
| 219 class CCodec_GifModule : public ICodec_GifModule { |
| 220 public: |
| 221 CCodec_GifModule() { FXSYS_memset(m_szLastError, '\0', 256); } |
| 222 virtual void* Start(void* pModule); |
| 223 virtual void Finish(void* pContext); |
| 224 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); |
| 225 virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); |
| 226 |
| 227 virtual int32_t ReadHeader(void* pContext, |
| 228 int* width, |
| 229 int* height, |
| 230 int* pal_num, |
| 231 void** pal_pp, |
| 232 int* bg_index, |
| 233 CFX_DIBAttribute* pAttribute); |
| 234 |
| 235 virtual int32_t LoadFrameInfo(void* pContext, int* frame_num); |
| 236 |
| 237 virtual int32_t LoadFrame(void* pContext, |
| 238 int frame_num, |
| 239 CFX_DIBAttribute* pAttribute); |
| 240 |
| 241 protected: |
| 242 FX_CHAR m_szLastError[256]; |
| 243 }; |
| 244 class CCodec_BmpModule : public ICodec_BmpModule { |
| 245 public: |
| 246 CCodec_BmpModule() { FXSYS_memset(m_szLastError, '\0', 256); } |
| 247 virtual void* Start(void* pModule); |
| 248 virtual void Finish(void* pContext); |
| 249 virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr); |
| 250 virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size); |
| 251 virtual int32_t ReadHeader(void* pContext, |
| 252 int32_t* width, |
| 253 int32_t* height, |
| 254 FX_BOOL* tb_flag, |
| 255 int32_t* components, |
| 256 int32_t* pal_num, |
| 257 FX_DWORD** pal_pp, |
| 258 CFX_DIBAttribute* pAttribute); |
| 259 virtual int32_t LoadImage(void* pContext); |
| 260 |
| 261 protected: |
| 262 FX_CHAR m_szLastError[256]; |
| 263 }; |
| 264 #endif |
195 class CCodec_IccModule : public ICodec_IccModule { | 265 class CCodec_IccModule : public ICodec_IccModule { |
196 public: | 266 public: |
197 virtual IccCS GetProfileCS(const uint8_t* pProfileData, | 267 virtual IccCS GetProfileCS(const uint8_t* pProfileData, |
198 unsigned int dwProfileSize); | 268 unsigned int dwProfileSize); |
199 virtual IccCS GetProfileCS(IFX_FileRead* pFile); | 269 virtual IccCS GetProfileCS(IFX_FileRead* pFile); |
200 virtual void* CreateTransform( | 270 virtual void* CreateTransform( |
201 ICodec_IccModule::IccParam* pInputParam, | 271 ICodec_IccModule::IccParam* pInputParam, |
202 ICodec_IccModule::IccParam* pOutputParam, | 272 ICodec_IccModule::IccParam* pOutputParam, |
203 ICodec_IccModule::IccParam* pProofParam = NULL, | 273 ICodec_IccModule::IccParam* pProofParam = NULL, |
204 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, | 274 FX_DWORD dwIntent = Icc_INTENT_PERCEPTUAL, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 FX_DWORD* width, | 330 FX_DWORD* width, |
261 FX_DWORD* height, | 331 FX_DWORD* height, |
262 FX_DWORD* components) override; | 332 FX_DWORD* components) override; |
263 bool Decode(CJPX_Decoder* pDecoder, | 333 bool Decode(CJPX_Decoder* pDecoder, |
264 uint8_t* dest_data, | 334 uint8_t* dest_data, |
265 int pitch, | 335 int pitch, |
266 const std::vector<uint8_t>& offsets) override; | 336 const std::vector<uint8_t>& offsets) override; |
267 void DestroyDecoder(CJPX_Decoder* pDecoder) override; | 337 void DestroyDecoder(CJPX_Decoder* pDecoder) override; |
268 }; | 338 }; |
269 | 339 |
| 340 #ifdef PDF_ENABLE_XFA |
| 341 class CCodec_TiffModule : public ICodec_TiffModule { |
| 342 public: |
| 343 // ICodec_TiffModule |
| 344 void* CreateDecoder(IFX_FileRead* file_ptr) override; |
| 345 void GetFrames(void* ctx, int32_t& frames) override; |
| 346 FX_BOOL LoadFrameInfo(void* ctx, |
| 347 int32_t frame, |
| 348 FX_DWORD& width, |
| 349 FX_DWORD& height, |
| 350 FX_DWORD& comps, |
| 351 FX_DWORD& bpc, |
| 352 CFX_DIBAttribute* pAttribute = NULL) override; |
| 353 FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) override; |
| 354 void DestroyDecoder(void* ctx) override; |
| 355 |
| 356 protected: |
| 357 ~CCodec_TiffModule() override {} |
| 358 }; |
| 359 |
| 360 #endif |
270 class CCodec_Jbig2Context { | 361 class CCodec_Jbig2Context { |
271 public: | 362 public: |
272 CCodec_Jbig2Context(); | 363 CCodec_Jbig2Context(); |
273 ~CCodec_Jbig2Context() {} | 364 ~CCodec_Jbig2Context() {} |
274 | 365 |
275 FX_DWORD m_width; | 366 FX_DWORD m_width; |
276 FX_DWORD m_height; | 367 FX_DWORD m_height; |
277 CPDF_StreamAcc* m_pGlobalStream; | 368 CPDF_StreamAcc* m_pGlobalStream; |
278 CPDF_StreamAcc* m_pSrcStream; | 369 CPDF_StreamAcc* m_pSrcStream; |
279 uint8_t* m_dest_buf; | 370 uint8_t* m_dest_buf; |
(...skipping 15 matching lines...) Expand all Loading... |
295 FX_DWORD height, | 386 FX_DWORD height, |
296 CPDF_StreamAcc* src_stream, | 387 CPDF_StreamAcc* src_stream, |
297 CPDF_StreamAcc* global_stream, | 388 CPDF_StreamAcc* global_stream, |
298 uint8_t* dest_buf, | 389 uint8_t* dest_buf, |
299 FX_DWORD dest_pitch, | 390 FX_DWORD dest_pitch, |
300 IFX_Pause* pPause) override; | 391 IFX_Pause* pPause) override; |
301 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, | 392 FXCODEC_STATUS ContinueDecode(void* pJbig2Context, |
302 IFX_Pause* pPause) override; | 393 IFX_Pause* pPause) override; |
303 void DestroyJbig2Context(void* pJbig2Context) override; | 394 void DestroyJbig2Context(void* pJbig2Context) override; |
304 }; | 395 }; |
| 396 #ifndef PDF_ENABLE_XFA |
305 | 397 |
| 398 #endif |
306 struct DecodeData { | 399 struct DecodeData { |
307 public: | 400 public: |
308 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) | 401 DecodeData(unsigned char* src_data, OPJ_SIZE_T src_size) |
309 : src_data(src_data), src_size(src_size), offset(0) {} | 402 : src_data(src_data), src_size(src_size), offset(0) {} |
310 unsigned char* src_data; | 403 unsigned char* src_data; |
311 OPJ_SIZE_T src_size; | 404 OPJ_SIZE_T src_size; |
312 OPJ_SIZE_T offset; | 405 OPJ_SIZE_T offset; |
313 }; | 406 }; |
314 | 407 |
315 void sycc420_to_rgb(opj_image_t* img); | 408 void sycc420_to_rgb(opj_image_t* img); |
316 | 409 |
317 /* Wrappers for C-style callbacks. */ | 410 /* Wrappers for C-style callbacks. */ |
318 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, | 411 OPJ_SIZE_T opj_read_from_memory(void* p_buffer, |
319 OPJ_SIZE_T nb_bytes, | 412 OPJ_SIZE_T nb_bytes, |
320 void* p_user_data); | 413 void* p_user_data); |
321 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, | 414 OPJ_SIZE_T opj_write_from_memory(void* p_buffer, |
322 OPJ_SIZE_T nb_bytes, | 415 OPJ_SIZE_T nb_bytes, |
323 void* p_user_data); | 416 void* p_user_data); |
324 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 417 OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
325 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); | 418 OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data); |
326 | 419 |
327 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ | 420 #endif // CORE_SRC_FXCODEC_CODEC_CODEC_INT_H_ |
OLD | NEW |