| 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 "core/include/fxcodec/fx_codec.h" | 7 #include "core/include/fxcodec/fx_codec.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 int height, | 287 int height, |
| 288 int nComps, | 288 int nComps, |
| 289 int bpc) { | 289 int bpc) { |
| 290 m_pSrcBuf = src_buf; | 290 m_pSrcBuf = src_buf; |
| 291 m_SrcSize = src_size; | 291 m_SrcSize = src_size; |
| 292 m_OutputWidth = m_OrigWidth = width; | 292 m_OutputWidth = m_OrigWidth = width; |
| 293 m_OutputHeight = m_OrigHeight = height; | 293 m_OutputHeight = m_OrigHeight = height; |
| 294 m_nComps = nComps; | 294 m_nComps = nComps; |
| 295 m_bpc = bpc; | 295 m_bpc = bpc; |
| 296 // Aligning the pitch to 4 bytes requires an integer overflow check. | 296 // Aligning the pitch to 4 bytes requires an integer overflow check. |
| 297 FX_SAFE_DWORD pitch = width; | 297 FX_SAFE_UINT32 pitch = width; |
| 298 pitch *= nComps; | 298 pitch *= nComps; |
| 299 pitch *= bpc; | 299 pitch *= bpc; |
| 300 pitch += 31; | 300 pitch += 31; |
| 301 pitch /= 32; | 301 pitch /= 32; |
| 302 pitch *= 4; | 302 pitch *= 4; |
| 303 if (!pitch.IsValid()) { | 303 if (!pitch.IsValid()) { |
| 304 return FALSE; | 304 return FALSE; |
| 305 } | 305 } |
| 306 m_Pitch = pitch.ValueOrDie(); | 306 m_Pitch = pitch.ValueOrDie(); |
| 307 // Overflow should already have been checked before this is called. | 307 // Overflow should already have been checked before this is called. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 int nComps, | 405 int nComps, |
| 406 int bpc) { | 406 int bpc) { |
| 407 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; | 407 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; |
| 408 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 408 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
| 409 bpc)) { | 409 bpc)) { |
| 410 delete pRLScanlineDecoder; | 410 delete pRLScanlineDecoder; |
| 411 return NULL; | 411 return NULL; |
| 412 } | 412 } |
| 413 return pRLScanlineDecoder; | 413 return pRLScanlineDecoder; |
| 414 } | 414 } |
| OLD | NEW |