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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_func.cpp

Issue 1861403002: Rename FX_SAFE_DWORD to FX_SAFE_UINT32 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months 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/fdrm/crypto/fx_crypt_sha.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('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 "core/fpdfapi/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 CPDF_Array* pEncode = pDict->GetArrayBy("Encode"); 534 CPDF_Array* pEncode = pDict->GetArrayBy("Encode");
535 CPDF_Array* pDecode = pDict->GetArrayBy("Decode"); 535 CPDF_Array* pDecode = pDict->GetArrayBy("Decode");
536 m_nBitsPerSample = pDict->GetIntegerBy("BitsPerSample"); 536 m_nBitsPerSample = pDict->GetIntegerBy("BitsPerSample");
537 if (m_nBitsPerSample > 32) { 537 if (m_nBitsPerSample > 32) {
538 return FALSE; 538 return FALSE;
539 } 539 }
540 m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample); 540 m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
541 m_pSampleStream = new CPDF_StreamAcc; 541 m_pSampleStream = new CPDF_StreamAcc;
542 m_pSampleStream->LoadAllData(pStream, FALSE); 542 m_pSampleStream->LoadAllData(pStream, FALSE);
543 m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs); 543 m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs);
544 FX_SAFE_DWORD nTotalSampleBits = 1; 544 FX_SAFE_UINT32 nTotalSampleBits = 1;
545 for (uint32_t i = 0; i < m_nInputs; i++) { 545 for (uint32_t i = 0; i < m_nInputs; i++) {
546 m_pEncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0; 546 m_pEncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0;
547 if (!pSize && i == 0) 547 if (!pSize && i == 0)
548 m_pEncodeInfo[i].sizes = pDict->GetIntegerBy("Size"); 548 m_pEncodeInfo[i].sizes = pDict->GetIntegerBy("Size");
549 nTotalSampleBits *= m_pEncodeInfo[i].sizes; 549 nTotalSampleBits *= m_pEncodeInfo[i].sizes;
550 if (pEncode) { 550 if (pEncode) {
551 m_pEncodeInfo[i].encode_min = pEncode->GetFloatAt(i * 2); 551 m_pEncodeInfo[i].encode_min = pEncode->GetFloatAt(i * 2);
552 m_pEncodeInfo[i].encode_max = pEncode->GetFloatAt(i * 2 + 1); 552 m_pEncodeInfo[i].encode_max = pEncode->GetFloatAt(i * 2 + 1);
553 } else { 553 } else {
554 m_pEncodeInfo[i].encode_min = 0; 554 m_pEncodeInfo[i].encode_min = 0;
555 if (m_pEncodeInfo[i].sizes == 1) 555 if (m_pEncodeInfo[i].sizes == 1)
556 m_pEncodeInfo[i].encode_max = 1; 556 m_pEncodeInfo[i].encode_max = 1;
557 else 557 else
558 m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes - 1; 558 m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes - 1;
559 } 559 }
560 } 560 }
561 nTotalSampleBits *= m_nBitsPerSample; 561 nTotalSampleBits *= m_nBitsPerSample;
562 nTotalSampleBits *= m_nOutputs; 562 nTotalSampleBits *= m_nOutputs;
563 FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits; 563 FX_SAFE_UINT32 nTotalSampleBytes = nTotalSampleBits;
564 nTotalSampleBytes += 7; 564 nTotalSampleBytes += 7;
565 nTotalSampleBytes /= 8; 565 nTotalSampleBytes /= 8;
566 if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 || 566 if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
567 nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) { 567 nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
568 return FALSE; 568 return FALSE;
569 } 569 }
570 m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs); 570 m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs);
571 for (uint32_t i = 0; i < m_nOutputs; i++) { 571 for (uint32_t i = 0; i < m_nOutputs; i++) {
572 if (pDecode) { 572 if (pDecode) {
573 m_pDecodeInfo[i].decode_min = pDecode->GetFloatAt(2 * i); 573 m_pDecodeInfo[i].decode_min = pDecode->GetFloatAt(2 * i);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (m_pRanges) { 905 if (m_pRanges) {
906 for (uint32_t i = 0; i < m_nOutputs; i++) { 906 for (uint32_t i = 0; i < m_nOutputs; i++) {
907 if (results[i] < m_pRanges[i * 2]) 907 if (results[i] < m_pRanges[i * 2])
908 results[i] = m_pRanges[i * 2]; 908 results[i] = m_pRanges[i * 2];
909 else if (results[i] > m_pRanges[i * 2 + 1]) 909 else if (results[i] > m_pRanges[i * 2 + 1])
910 results[i] = m_pRanges[i * 2 + 1]; 910 results[i] = m_pRanges[i * 2 + 1];
911 } 911 }
912 } 912 }
913 return TRUE; 913 return TRUE;
914 } 914 }
OLDNEW
« no previous file with comments | « core/fdrm/crypto/fx_crypt_sha.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698