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

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

Issue 1461363002: Merge to XFA: Change |CCodec_ScanlineDecoder::m_Pitch| to FX_DWORD (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_flate.cpp ('k') | testing/resources/bug_555784.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 m_OutputHeight = m_OrigHeight = height; 420 m_OutputHeight = m_OrigHeight = height;
421 if (!InitDecode()) { 421 if (!InitDecode()) {
422 return FALSE; 422 return FALSE;
423 } 423 }
424 if (cinfo.num_components < nComps) { 424 if (cinfo.num_components < nComps) {
425 return FALSE; 425 return FALSE;
426 } 426 }
427 if ((int)cinfo.image_width < width) { 427 if ((int)cinfo.image_width < width) {
428 return FALSE; 428 return FALSE;
429 } 429 }
430 m_Pitch = (cinfo.image_width * cinfo.num_components + 3) / 4 * 4; 430 m_Pitch =
431 (static_cast<FX_DWORD>(cinfo.image_width) * cinfo.num_components + 3) /
432 4 * 4;
431 m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch); 433 m_pScanlineBuf = FX_Alloc(uint8_t, m_Pitch);
432 m_nComps = cinfo.num_components; 434 m_nComps = cinfo.num_components;
433 m_bpc = 8; 435 m_bpc = 8;
434 m_bColorTransformed = FALSE; 436 m_bColorTransformed = FALSE;
435 m_bStarted = FALSE; 437 m_bStarted = FALSE;
436 return TRUE; 438 return TRUE;
437 } 439 }
438 extern "C" { 440 extern "C" {
439 int32_t FX_GetDownsampleRatio(int32_t originWidth, 441 int32_t FX_GetDownsampleRatio(int32_t originWidth,
440 int32_t originHeight, 442 int32_t originHeight,
(...skipping 13 matching lines...) Expand all
454 } 456 }
455 return 1; 457 return 1;
456 } 458 }
457 } 459 }
458 void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) { 460 void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) {
459 int old_scale = m_DownScale; 461 int old_scale = m_DownScale;
460 m_DownScale = 462 m_DownScale =
461 FX_GetDownsampleRatio(m_OrigWidth, m_OrigHeight, dest_width, dest_height); 463 FX_GetDownsampleRatio(m_OrigWidth, m_OrigHeight, dest_width, dest_height);
462 m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale; 464 m_OutputWidth = (m_OrigWidth + m_DownScale - 1) / m_DownScale;
463 m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale; 465 m_OutputHeight = (m_OrigHeight + m_DownScale - 1) / m_DownScale;
464 m_Pitch = (m_OutputWidth * m_nComps + 3) / 4 * 4; 466 m_Pitch = (static_cast<FX_DWORD>(m_OutputWidth) * m_nComps + 3) / 4 * 4;
465 if (old_scale != m_DownScale) { 467 if (old_scale != m_DownScale) {
466 m_NextLine = -1; 468 m_NextLine = -1;
467 } 469 }
468 } 470 }
469 FX_BOOL CCodec_JpegDecoder::v_Rewind() { 471 FX_BOOL CCodec_JpegDecoder::v_Rewind() {
470 if (m_bStarted) { 472 if (m_bStarted) {
471 jpeg_destroy_decompress(&cinfo); 473 jpeg_destroy_decompress(&cinfo);
472 if (!InitDecode()) { 474 if (!InitDecode()) {
473 return FALSE; 475 return FALSE;
474 } 476 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 uint8_t** avail_buf_ptr) { 670 uint8_t** avail_buf_ptr) {
669 if (avail_buf_ptr != NULL) { 671 if (avail_buf_ptr != NULL) {
670 *avail_buf_ptr = NULL; 672 *avail_buf_ptr = NULL;
671 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { 673 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
672 *avail_buf_ptr = 674 *avail_buf_ptr =
673 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; 675 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
674 } 676 }
675 } 677 }
676 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; 678 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
677 } 679 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_flate.cpp ('k') | testing/resources/bug_555784.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698