| 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 <setjmp.h> | 7 #include <setjmp.h> |
| 8 | 8 |
| 9 #include "core/fxcodec/codec/codec_int.h" | 9 #include "core/fxcodec/codec/codec_int.h" |
| 10 #include "core/fxcodec/fx_codec.h" | 10 #include "core/fxcodec/fx_codec.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 442 |
| 443 *width = ctx->m_Info.image_width; | 443 *width = ctx->m_Info.image_width; |
| 444 *height = ctx->m_Info.image_height; | 444 *height = ctx->m_Info.image_height; |
| 445 *nComps = ctx->m_Info.num_components; | 445 *nComps = ctx->m_Info.num_components; |
| 446 #ifdef PDF_ENABLE_XFA | 446 #ifdef PDF_ENABLE_XFA |
| 447 JpegLoadAttribute(&ctx->m_Info, pAttribute); | 447 JpegLoadAttribute(&ctx->m_Info, pAttribute); |
| 448 #endif | 448 #endif |
| 449 return 0; | 449 return 0; |
| 450 } | 450 } |
| 451 | 451 |
| 452 int CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) { | 452 FX_BOOL CCodec_JpegModule::StartScanline(FXJPEG_Context* ctx, int down_scale) { |
| 453 if (setjmp(ctx->m_JumpMark) == -1) | 453 if (setjmp(ctx->m_JumpMark) == -1) |
| 454 return 0; | 454 return FALSE; |
| 455 | 455 |
| 456 ctx->m_Info.scale_denom = down_scale; | 456 ctx->m_Info.scale_denom = down_scale; |
| 457 return jpeg_start_decompress(&ctx->m_Info); | 457 return !!jpeg_start_decompress(&ctx->m_Info); |
| 458 } | 458 } |
| 459 | 459 |
| 460 FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, | 460 FX_BOOL CCodec_JpegModule::ReadScanline(FXJPEG_Context* ctx, |
| 461 unsigned char* dest_buf) { | 461 unsigned char* dest_buf) { |
| 462 if (setjmp(ctx->m_JumpMark) == -1) | 462 if (setjmp(ctx->m_JumpMark) == -1) |
| 463 return FALSE; | 463 return FALSE; |
| 464 | 464 |
| 465 int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); | 465 int nlines = jpeg_read_scanlines(&ctx->m_Info, &dest_buf, 1); |
| 466 return nlines == 1; | 466 return nlines == 1; |
| 467 } | 467 } |
| 468 | 468 |
| 469 uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, | 469 uint32_t CCodec_JpegModule::GetAvailInput(FXJPEG_Context* ctx, |
| 470 uint8_t** avail_buf_ptr) { | 470 uint8_t** avail_buf_ptr) { |
| 471 if (avail_buf_ptr) { | 471 if (avail_buf_ptr) { |
| 472 *avail_buf_ptr = nullptr; | 472 *avail_buf_ptr = nullptr; |
| 473 if (ctx->m_SrcMgr.bytes_in_buffer > 0) { | 473 if (ctx->m_SrcMgr.bytes_in_buffer > 0) { |
| 474 *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; | 474 *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer; | 477 return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer; |
| 478 } | 478 } |
| OLD | NEW |