| 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 "codec_int.h" | 7 #include "codec_int.h" |
| 8 | 8 |
| 9 #include <algorithm> |
| 9 #include <memory> | 10 #include <memory> |
| 10 | 11 |
| 11 #include "core/include/fxcodec/fx_codec.h" | 12 #include "core/include/fxcodec/fx_codec.h" |
| 12 #include "core/include/fxcodec/fx_codec_flate.h" | 13 #include "core/include/fxcodec/fx_codec_flate.h" |
| 13 #include "third_party/zlib_v128/zlib.h" | 14 #include "third_party/zlib_v128/zlib.h" |
| 14 | 15 |
| 15 extern "C" { | 16 extern "C" { |
| 16 static void* my_alloc_func(void* opaque, | 17 static void* my_alloc_func(void* opaque, |
| 17 unsigned int items, | 18 unsigned int items, |
| 18 unsigned int size) { | 19 unsigned int size) { |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 559 } |
| 559 return TRUE; | 560 return TRUE; |
| 560 } | 561 } |
| 561 | 562 |
| 562 void TIFF_PredictLine(uint8_t* dest_buf, | 563 void TIFF_PredictLine(uint8_t* dest_buf, |
| 563 FX_DWORD row_size, | 564 FX_DWORD row_size, |
| 564 int BitsPerComponent, | 565 int BitsPerComponent, |
| 565 int Colors, | 566 int Colors, |
| 566 int Columns) { | 567 int Columns) { |
| 567 if (BitsPerComponent == 1) { | 568 if (BitsPerComponent == 1) { |
| 568 int row_bits = FX_MIN(BitsPerComponent * Colors * Columns, row_size * 8); | 569 int row_bits = std::min(BitsPerComponent * Colors * Columns, |
| 570 pdfium::base::checked_cast<int>(row_size * 8)); |
| 569 int index_pre = 0; | 571 int index_pre = 0; |
| 570 int col_pre = 0; | 572 int col_pre = 0; |
| 571 for (int i = 1; i < row_bits; i++) { | 573 for (int i = 1; i < row_bits; i++) { |
| 572 int col = i % 8; | 574 int col = i % 8; |
| 573 int index = i / 8; | 575 int index = i / 8; |
| 574 if (((dest_buf[index] >> (7 - col)) & 1) ^ | 576 if (((dest_buf[index] >> (7 - col)) & 1) ^ |
| 575 ((dest_buf[index_pre] >> (7 - col_pre)) & 1)) { | 577 ((dest_buf[index_pre] >> (7 - col_pre)) & 1)) { |
| 576 dest_buf[index] |= 1 << (7 - col); | 578 dest_buf[index] |= 1 << (7 - col); |
| 577 } else { | 579 } else { |
| 578 dest_buf[index] &= ~(1 << (7 - col)); | 580 dest_buf[index] &= ~(1 << (7 - col)); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 FX_DWORD src_size, | 998 FX_DWORD src_size, |
| 997 uint8_t*& dest_buf, | 999 uint8_t*& dest_buf, |
| 998 FX_DWORD& dest_size) { | 1000 FX_DWORD& dest_size) { |
| 999 dest_size = src_size + src_size / 1000 + 12; | 1001 dest_size = src_size + src_size / 1000 + 12; |
| 1000 dest_buf = FX_Alloc(uint8_t, dest_size); | 1002 dest_buf = FX_Alloc(uint8_t, dest_size); |
| 1001 unsigned long temp_size = dest_size; | 1003 unsigned long temp_size = dest_size; |
| 1002 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); | 1004 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); |
| 1003 dest_size = (FX_DWORD)temp_size; | 1005 dest_size = (FX_DWORD)temp_size; |
| 1004 return TRUE; | 1006 return TRUE; |
| 1005 } | 1007 } |
| OLD | NEW |