| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "codec_int.h" | 8 #include "codec_int.h" |
| 9 const uint8_t OneLeadPos[256] = { | 9 const uint8_t OneLeadPos[256] = { |
| 10 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, | 10 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 _FaxFillBits(dest_buf, columns, startpos, startpos + run_len); | 448 _FaxFillBits(dest_buf, columns, startpos, startpos + run_len); |
| 449 } | 449 } |
| 450 startpos += run_len; | 450 startpos += run_len; |
| 451 if (startpos >= columns) { | 451 if (startpos >= columns) { |
| 452 break; | 452 break; |
| 453 } | 453 } |
| 454 color = !color; | 454 color = !color; |
| 455 } | 455 } |
| 456 return TRUE; | 456 return TRUE; |
| 457 } | 457 } |
| 458 |
| 458 class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { | 459 class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { |
| 459 public: | 460 public: |
| 460 CCodec_FaxDecoder(); | 461 CCodec_FaxDecoder(); |
| 461 virtual ~CCodec_FaxDecoder(); | 462 ~CCodec_FaxDecoder() override; |
| 463 |
| 462 FX_BOOL Create(const uint8_t* src_buf, | 464 FX_BOOL Create(const uint8_t* src_buf, |
| 463 FX_DWORD src_size, | 465 FX_DWORD src_size, |
| 464 int width, | 466 int width, |
| 465 int height, | 467 int height, |
| 466 int K, | 468 int K, |
| 467 FX_BOOL EndOfLine, | 469 FX_BOOL EndOfLine, |
| 468 FX_BOOL EncodedByteAlign, | 470 FX_BOOL EncodedByteAlign, |
| 469 FX_BOOL BlackIs1, | 471 FX_BOOL BlackIs1, |
| 470 int Columns, | 472 int Columns, |
| 471 int Rows); | 473 int Rows); |
| 472 virtual void v_DownScale(int dest_width, int dest_height) {} | 474 |
| 473 virtual FX_BOOL v_Rewind(); | 475 // CCodec_ScanlineDecoder |
| 474 virtual uint8_t* v_GetNextLine(); | 476 void v_DownScale(int dest_width, int dest_height) override {} |
| 475 virtual FX_DWORD GetSrcOffset(); | 477 FX_BOOL v_Rewind() override; |
| 478 uint8_t* v_GetNextLine() override; |
| 479 FX_DWORD GetSrcOffset() override; |
| 480 |
| 476 int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack; | 481 int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack; |
| 477 int bitpos; | 482 int bitpos; |
| 478 const uint8_t* m_pSrcBuf; | 483 const uint8_t* m_pSrcBuf; |
| 479 FX_DWORD m_SrcSize; | 484 FX_DWORD m_SrcSize; |
| 480 uint8_t* m_pScanlineBuf; | 485 uint8_t* m_pScanlineBuf; |
| 481 uint8_t* m_pRefBuf; | 486 uint8_t* m_pRefBuf; |
| 482 }; | 487 }; |
| 488 |
| 483 CCodec_FaxDecoder::CCodec_FaxDecoder() { | 489 CCodec_FaxDecoder::CCodec_FaxDecoder() { |
| 484 m_pScanlineBuf = NULL; | 490 m_pScanlineBuf = NULL; |
| 485 m_pRefBuf = NULL; | 491 m_pRefBuf = NULL; |
| 486 } | 492 } |
| 487 CCodec_FaxDecoder::~CCodec_FaxDecoder() { | 493 CCodec_FaxDecoder::~CCodec_FaxDecoder() { |
| 488 if (m_pScanlineBuf) { | 494 if (m_pScanlineBuf) { |
| 489 FX_Free(m_pScanlineBuf); | 495 FX_Free(m_pScanlineBuf); |
| 490 } | 496 } |
| 491 if (m_pRefBuf) { | 497 if (m_pRefBuf) { |
| 492 FX_Free(m_pRefBuf); | 498 FX_Free(m_pRefBuf); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 FX_BOOL EndOfLine, | 816 FX_BOOL EndOfLine, |
| 811 FX_BOOL EncodedByteAlign, | 817 FX_BOOL EncodedByteAlign, |
| 812 FX_BOOL BlackIs1, | 818 FX_BOOL BlackIs1, |
| 813 int Columns, | 819 int Columns, |
| 814 int Rows) { | 820 int Rows) { |
| 815 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; | 821 CCodec_FaxDecoder* pDecoder = new CCodec_FaxDecoder; |
| 816 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, | 822 pDecoder->Create(src_buf, src_size, width, height, K, EndOfLine, |
| 817 EncodedByteAlign, BlackIs1, Columns, Rows); | 823 EncodedByteAlign, BlackIs1, Columns, Rows); |
| 818 return pDecoder; | 824 return pDecoder; |
| 819 } | 825 } |
| OLD | NEW |