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 "../../../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../../../../third_party/zlib_v128/zlib.h" | 8 #include "../../../../third_party/zlib_v128/zlib.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 #include "../../../include/fxcodec/fx_codec_flate.h" | 10 #include "../../../include/fxcodec/fx_codec_flate.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 const int last_row_size = data_size % row_size; | 596 const int last_row_size = data_size % row_size; |
597 for (int row = 0; row < row_count; row++) { | 597 for (int row = 0; row < row_count; row++) { |
598 uint8_t* scan_line = data_buf + row * row_size; | 598 uint8_t* scan_line = data_buf + row * row_size; |
599 if ((row + 1) * row_size > (int)data_size) { | 599 if ((row + 1) * row_size > (int)data_size) { |
600 row_size = last_row_size; | 600 row_size = last_row_size; |
601 } | 601 } |
602 TIFF_PredictLine(scan_line, row_size, BitsPerComponent, Colors, Columns); | 602 TIFF_PredictLine(scan_line, row_size, BitsPerComponent, Colors, Columns); |
603 } | 603 } |
604 return TRUE; | 604 return TRUE; |
605 } | 605 } |
| 606 |
606 class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { | 607 class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { |
607 public: | 608 public: |
608 CCodec_FlateScanlineDecoder(); | 609 CCodec_FlateScanlineDecoder(); |
609 ~CCodec_FlateScanlineDecoder(); | 610 ~CCodec_FlateScanlineDecoder() override; |
| 611 |
610 void Create(const uint8_t* src_buf, | 612 void Create(const uint8_t* src_buf, |
611 FX_DWORD src_size, | 613 FX_DWORD src_size, |
612 int width, | 614 int width, |
613 int height, | 615 int height, |
614 int nComps, | 616 int nComps, |
615 int bpc, | 617 int bpc, |
616 int predictor, | 618 int predictor, |
617 int Colors, | 619 int Colors, |
618 int BitsPerComponent, | 620 int BitsPerComponent, |
619 int Columns); | 621 int Columns); |
620 virtual void Destroy() { delete this; } | 622 void Destroy() { delete this; } |
621 virtual void v_DownScale(int dest_width, int dest_height) {} | 623 |
622 virtual FX_BOOL v_Rewind(); | 624 // CCodec_ScanlineDecoder |
623 virtual uint8_t* v_GetNextLine(); | 625 void v_DownScale(int dest_width, int dest_height) override {} |
624 virtual FX_DWORD GetSrcOffset(); | 626 FX_BOOL v_Rewind() override; |
| 627 uint8_t* v_GetNextLine() override; |
| 628 FX_DWORD GetSrcOffset() override; |
| 629 |
625 void* m_pFlate; | 630 void* m_pFlate; |
626 const uint8_t* m_SrcBuf; | 631 const uint8_t* m_SrcBuf; |
627 FX_DWORD m_SrcSize; | 632 FX_DWORD m_SrcSize; |
628 uint8_t* m_pScanline; | 633 uint8_t* m_pScanline; |
629 uint8_t* m_pLastLine; | 634 uint8_t* m_pLastLine; |
630 uint8_t* m_pPredictBuffer; | 635 uint8_t* m_pPredictBuffer; |
631 uint8_t* m_pPredictRaw; | 636 uint8_t* m_pPredictRaw; |
632 int m_Predictor; | 637 int m_Predictor; |
633 int m_Colors, m_BitsPerComponent, m_Columns, m_PredictPitch, m_LeftOver; | 638 int m_Colors, m_BitsPerComponent, m_Columns, m_PredictPitch, m_LeftOver; |
634 }; | 639 }; |
| 640 |
635 CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { | 641 CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { |
636 m_pFlate = NULL; | 642 m_pFlate = NULL; |
637 m_pScanline = NULL; | 643 m_pScanline = NULL; |
638 m_pLastLine = NULL; | 644 m_pLastLine = NULL; |
639 m_pPredictBuffer = NULL; | 645 m_pPredictBuffer = NULL; |
640 m_pPredictRaw = NULL; | 646 m_pPredictRaw = NULL; |
641 m_LeftOver = 0; | 647 m_LeftOver = 0; |
642 } | 648 } |
643 CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() { | 649 CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() { |
644 if (m_pScanline) { | 650 if (m_pScanline) { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 FX_DWORD src_size, | 974 FX_DWORD src_size, |
969 uint8_t*& dest_buf, | 975 uint8_t*& dest_buf, |
970 FX_DWORD& dest_size) { | 976 FX_DWORD& dest_size) { |
971 dest_size = src_size + src_size / 1000 + 12; | 977 dest_size = src_size + src_size / 1000 + 12; |
972 dest_buf = FX_Alloc(uint8_t, dest_size); | 978 dest_buf = FX_Alloc(uint8_t, dest_size); |
973 unsigned long temp_size = dest_size; | 979 unsigned long temp_size = dest_size; |
974 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); | 980 FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size); |
975 dest_size = (FX_DWORD)temp_size; | 981 dest_size = (FX_DWORD)temp_size; |
976 return TRUE; | 982 return TRUE; |
977 } | 983 } |
OLD | NEW |