Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jpeg.cpp

Issue 1471323004: Inflict PPDF_ENABLE_XFA ifdefs on XFA core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "codec_int.h" 9 #include "codec_int.h"
10 #include "core/include/fxcodec/fx_codec.h" 10 #include "core/include/fxcodec/fx_codec.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer; 223 dest.next_output_byte = dest_buf + dest_buf_length - dest.free_in_buffer;
224 dest_buf_length += JPEG_BLOCK_SIZE; 224 dest_buf_length += JPEG_BLOCK_SIZE;
225 dest.free_in_buffer += JPEG_BLOCK_SIZE; 225 dest.free_in_buffer += JPEG_BLOCK_SIZE;
226 } 226 }
227 } 227 }
228 jpeg_finish_compress(&cinfo); 228 jpeg_finish_compress(&cinfo);
229 jpeg_destroy_compress(&cinfo); 229 jpeg_destroy_compress(&cinfo);
230 FX_Free(line_buf); 230 FX_Free(line_buf);
231 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer; 231 dest_size = dest_buf_length - (FX_STRSIZE)dest.free_in_buffer;
232 } 232 }
233 #ifdef PDF_ENABLE_XFA
233 static void _JpegLoadAttribute(struct jpeg_decompress_struct* pInfo, 234 static void _JpegLoadAttribute(struct jpeg_decompress_struct* pInfo,
234 CFX_DIBAttribute* pAttribute) { 235 CFX_DIBAttribute* pAttribute) {
235 if (pInfo == NULL || pAttribute == NULL) { 236 if (pInfo == NULL || pAttribute == NULL) {
236 return; 237 return;
237 } 238 }
238 if (pAttribute) { 239 if (pAttribute) {
239 pAttribute->m_nXDPI = pInfo->X_density; 240 pAttribute->m_nXDPI = pInfo->X_density;
240 pAttribute->m_nYDPI = pInfo->Y_density; 241 pAttribute->m_nYDPI = pInfo->Y_density;
241 pAttribute->m_wDPIUnit = pInfo->density_unit; 242 pAttribute->m_wDPIUnit = pInfo->density_unit;
242 } 243 }
243 } 244 }
245 #endif
244 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, 246 static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf,
245 FX_DWORD src_size, 247 FX_DWORD src_size,
246 int& width, 248 int& width,
247 int& height, 249 int& height,
248 int& num_components, 250 int& num_components,
249 int& bits_per_components, 251 int& bits_per_components,
250 FX_BOOL& color_transform, 252 FX_BOOL& color_transform,
251 uint8_t** icc_buf_ptr, 253 uint8_t** icc_buf_ptr,
252 FX_DWORD* icc_length) { 254 FX_DWORD* icc_length) {
253 _JpegScanSOI(src_buf, src_size); 255 _JpegScanSOI(src_buf, src_size);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 src_size -= p->m_SkipSize; 625 src_size -= p->m_SkipSize;
624 src_buf += p->m_SkipSize; 626 src_buf += p->m_SkipSize;
625 p->m_SkipSize = 0; 627 p->m_SkipSize = 0;
626 } 628 }
627 p->m_SrcMgr.next_input_byte = src_buf; 629 p->m_SrcMgr.next_input_byte = src_buf;
628 p->m_SrcMgr.bytes_in_buffer = src_size; 630 p->m_SrcMgr.bytes_in_buffer = src_size;
629 } 631 }
630 int CCodec_JpegModule::ReadHeader(void* pContext, 632 int CCodec_JpegModule::ReadHeader(void* pContext,
631 int* width, 633 int* width,
632 int* height, 634 int* height,
635 #ifndef PDF_ENABLE_XFA
636 int* nComps) {
637 #else
633 int* nComps, 638 int* nComps,
634 CFX_DIBAttribute* pAttribute) { 639 CFX_DIBAttribute* pAttribute) {
640 #endif
635 FXJPEG_Context* p = (FXJPEG_Context*)pContext; 641 FXJPEG_Context* p = (FXJPEG_Context*)pContext;
636 if (setjmp(p->m_JumpMark) == -1) { 642 if (setjmp(p->m_JumpMark) == -1) {
637 return 1; 643 return 1;
638 } 644 }
639 int ret = jpeg_read_header(&p->m_Info, true); 645 int ret = jpeg_read_header(&p->m_Info, true);
640 if (ret == JPEG_SUSPENDED) { 646 if (ret == JPEG_SUSPENDED) {
641 return 2; 647 return 2;
642 } 648 }
643 if (ret != JPEG_HEADER_OK) { 649 if (ret != JPEG_HEADER_OK) {
644 return 1; 650 return 1;
645 } 651 }
646 *width = p->m_Info.image_width; 652 *width = p->m_Info.image_width;
647 *height = p->m_Info.image_height; 653 *height = p->m_Info.image_height;
648 *nComps = p->m_Info.num_components; 654 *nComps = p->m_Info.num_components;
655 #ifdef PDF_ENABLE_XFA
649 _JpegLoadAttribute(&p->m_Info, pAttribute); 656 _JpegLoadAttribute(&p->m_Info, pAttribute);
657 #endif
650 return 0; 658 return 0;
651 } 659 }
652 int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) { 660 int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) {
653 FXJPEG_Context* p = (FXJPEG_Context*)pContext; 661 FXJPEG_Context* p = (FXJPEG_Context*)pContext;
654 if (setjmp(p->m_JumpMark) == -1) { 662 if (setjmp(p->m_JumpMark) == -1) {
655 return 0; 663 return 0;
656 } 664 }
657 p->m_Info.scale_denom = down_scale; 665 p->m_Info.scale_denom = down_scale;
658 return jpeg_start_decompress(&p->m_Info); 666 return jpeg_start_decompress(&p->m_Info);
659 } 667 }
(...skipping 10 matching lines...) Expand all
670 uint8_t** avail_buf_ptr) { 678 uint8_t** avail_buf_ptr) {
671 if (avail_buf_ptr != NULL) { 679 if (avail_buf_ptr != NULL) {
672 *avail_buf_ptr = NULL; 680 *avail_buf_ptr = NULL;
673 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { 681 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
674 *avail_buf_ptr = 682 *avail_buf_ptr =
675 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; 683 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
676 } 684 }
677 } 685 }
678 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; 686 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
679 } 687 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698