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 <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "../../../include/fpdfapi/fpdf_page.h" | 9 #include "../../../include/fpdfapi/fpdf_page.h" |
10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 FX_SAFE_INT32 bitpos = pos; | 560 FX_SAFE_INT32 bitpos = pos; |
561 bitpos *= m_nBitsPerSample; | 561 bitpos *= m_nBitsPerSample; |
562 bitpos *= m_nOutputs; | 562 bitpos *= m_nOutputs; |
563 if (!bitpos.IsValid()) { | 563 if (!bitpos.IsValid()) { |
564 return FALSE; | 564 return FALSE; |
565 } | 565 } |
566 FX_LPCBYTE pSampleData = m_pSampleStream->GetData(); | 566 FX_LPCBYTE pSampleData = m_pSampleStream->GetData(); |
567 if (pSampleData == NULL) { | 567 if (pSampleData == NULL) { |
568 return FALSE; | 568 return FALSE; |
569 } | 569 } |
570 FX_SAFE_INT32 bitpos1 = m_nOutputs - 1 > 0 ? m_nOutputs - 1 : 0; | 570 FX_SAFE_INT32 bitpos1 = m_nOutputs - 1 > 0 ? m_nOutputs - 1 : 0; |
Tom Sepez
2015/02/12 18:06:46
Looking at the original code, I don't remember why
jun_fang
2015/02/12 18:13:35
This judge is used to ensure 'bitpos.ValueOrDie()
| |
571 bitpos1 *= m_nBitsPerSample; | 571 bitpos1 *= m_nBitsPerSample; |
572 bitpos1 += bitpos.ValueOrDie(); | 572 bitpos1 += bitpos.ValueOrDie(); |
573 if (!bitpos1.IsValid()) { | 573 if (!bitpos1.IsValid()) { |
574 return FALSE; | 574 return FALSE; |
575 } | 575 } |
576 for (int j = 0; j < m_nOutputs; j ++) { | 576 for (int j = 0; j < m_nOutputs; j ++) { |
577 FX_DWORD sample = _GetBits32(pSampleData, bitpos.ValueOrDie() + j * m_nB itsPerSample, m_nBitsPerSample); | 577 FX_DWORD sample = _GetBits32(pSampleData, bitpos.ValueOrDie() + j * m_nB itsPerSample, m_nBitsPerSample); |
578 FX_FLOAT encoded = (FX_FLOAT)sample; | 578 FX_FLOAT encoded = (FX_FLOAT)sample; |
579 for (int i = 0; i < m_nInputs; i ++) { | 579 for (int i = 0; i < m_nInputs; i ++) { |
580 if (index[i] == m_pEncodeInfo[i].sizes - 1) { | 580 if (index[i] == m_pEncodeInfo[i].sizes - 1) { |
581 if (index[i] == 0) { | 581 if (index[i] == 0) { |
582 encoded = encoded_input[i] * (FX_FLOAT)sample; | 582 encoded = encoded_input[i] * (FX_FLOAT)sample; |
583 } | 583 } |
584 } else { | 584 } else { |
585 FX_SAFE_INT32 bitpos2 = blocksize[i]; | 585 FX_SAFE_INT32 bitpos2 = blocksize[i]; |
586 bitpos2 += 1; | 586 bitpos2 += pos; |
587 bitpos2 *= m_nOutputs; | |
588 bitpos2 += j; | |
587 bitpos2 *= m_nBitsPerSample; | 589 bitpos2 *= m_nBitsPerSample; |
588 bitpos2 *= m_nOutputs; | |
589 bitpos2 += bitpos.ValueOrDie(); | |
590 if (!bitpos2.IsValid()) { | 590 if (!bitpos2.IsValid()) { |
591 return FALSE; | 591 return FALSE; |
592 } | 592 } |
593 FX_DWORD sample1 = _GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample); | 593 FX_DWORD sample1 = _GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample); |
594 encoded += (encoded_input[i] - index[i]) * ((FX_FLOAT)sample1 - (FX_FLOAT)sample); | 594 encoded += (encoded_input[i] - index[i]) * ((FX_FLOAT)sample1 - (FX_FLOAT)sample); |
595 } | 595 } |
596 } | 596 } |
597 results[j] = PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax, | 597 results[j] = PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax, |
598 m_pDecodeInfo[j].decode_min, m_pDecodeInfo[ j].decode_max); | 598 m_pDecodeInfo[j].decode_min, m_pDecodeInfo[ j].decode_max); |
599 } | 599 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 for (int i = 0; i < m_nOutputs; i ++) { | 898 for (int i = 0; i < m_nOutputs; i ++) { |
899 if (results[i] < m_pRanges[i * 2]) { | 899 if (results[i] < m_pRanges[i * 2]) { |
900 results[i] = m_pRanges[i * 2]; | 900 results[i] = m_pRanges[i * 2]; |
901 } else if (results[i] > m_pRanges[i * 2 + 1]) { | 901 } else if (results[i] > m_pRanges[i * 2 + 1]) { |
902 results[i] = m_pRanges[i * 2 + 1]; | 902 results[i] = m_pRanges[i * 2 + 1]; |
903 } | 903 } |
904 } | 904 } |
905 } | 905 } |
906 return TRUE; | 906 return TRUE; |
907 } | 907 } |
OLD | NEW |