| 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 "../../fx_zlib.h" | 7 #include "../../fx_zlib.h" |
| 8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
| 9 #include "codec_int.h" | 9 #include "codec_int.h" |
| 10 extern "C" | 10 extern "C" |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 FX_LPBYTE scan_line = data_buf + row * row_size; | 517 FX_LPBYTE scan_line = data_buf + row * row_size; |
| 518 if ((row + 1) * row_size > (int)data_size) { | 518 if ((row + 1) * row_size > (int)data_size) { |
| 519 row_size = last_row_size; | 519 row_size = last_row_size; |
| 520 } | 520 } |
| 521 TIFF_PredictorEncodeLine(scan_line, row_size, BitsPerComponent, Colors,
Columns); | 521 TIFF_PredictorEncodeLine(scan_line, row_size, BitsPerComponent, Colors,
Columns); |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerCompon
ent, int Colors, int Columns) | 524 static void TIFF_PredictLine(FX_LPBYTE dest_buf, int row_size, int BitsPerCompon
ent, int Colors, int Columns) |
| 525 { | 525 { |
| 526 if (BitsPerComponent == 1) { | 526 if (BitsPerComponent == 1) { |
| 527 int row_bits = BitsPerComponent * Colors * Columns; | 527 int row_bits = FX_MIN(BitsPerComponent * Colors * Columns, row_size * 8)
; |
| 528 for(int i = 1; i < row_bits; i ++) { | 528 for(int i = 1; i < row_bits; i ++) { |
| 529 int col = i % 8; | 529 int col = i % 8; |
| 530 int index = i / 8; | 530 int index = i / 8; |
| 531 int index_pre = (col == 0) ? (index - 1) : index; | 531 if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[(i-1)/8] >> (7
- (i-1)%8)) & 1) ) { |
| 532 int col_pre = (col == 0) ? 8 : col; | |
| 533 if( ((dest_buf[index] >> (7 - col)) & 1) ^ ((dest_buf[index_pre] >>
(8 - col_pre)) & 1) ) { | |
| 534 dest_buf[index] |= 1 << (7 - col); | 532 dest_buf[index] |= 1 << (7 - col); |
| 535 } else { | 533 } else { |
| 536 dest_buf[index] &= ~(1 << (7 - col)); | 534 dest_buf[index] &= ~(1 << (7 - col)); |
| 537 } | 535 } |
| 538 } | 536 } |
| 539 return; | 537 return; |
| 540 } | 538 } |
| 541 int BytesPerPixel = BitsPerComponent * Colors / 8; | 539 int BytesPerPixel = BitsPerComponent * Colors / 8; |
| 542 if (BitsPerComponent == 16) { | 540 if (BitsPerComponent == 16) { |
| 543 for (int i = BytesPerPixel; i < row_size; i += 2) { | 541 for (int i = BytesPerPixel; i < row_size; i += 2) { |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 dest_size = src_size + src_size / 1000 + 12; | 933 dest_size = src_size + src_size / 1000 + 12; |
| 936 dest_buf = FX_Alloc( FX_BYTE, dest_size); | 934 dest_buf = FX_Alloc( FX_BYTE, dest_size); |
| 937 if (dest_buf == NULL) { | 935 if (dest_buf == NULL) { |
| 938 return FALSE; | 936 return FALSE; |
| 939 } | 937 } |
| 940 unsigned long temp_size = dest_size; | 938 unsigned long temp_size = dest_size; |
| 941 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); | 939 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); |
| 942 dest_size = (FX_DWORD)temp_size; | 940 dest_size = (FX_DWORD)temp_size; |
| 943 return TRUE; | 941 return TRUE; |
| 944 } | 942 } |
| OLD | NEW |