| 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 "core/fxcodec/include/fx_codec.h" | 7 #include "core/fxcodec/include/fx_codec.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 uint8_t* m_pScanline; | 121 uint8_t* m_pScanline; |
| 122 const uint8_t* m_pSrcBuf; | 122 const uint8_t* m_pSrcBuf; |
| 123 uint32_t m_SrcSize; | 123 uint32_t m_SrcSize; |
| 124 uint32_t m_dwLineBytes; | 124 uint32_t m_dwLineBytes; |
| 125 uint32_t m_SrcOffset; | 125 uint32_t m_SrcOffset; |
| 126 FX_BOOL m_bEOD; | 126 FX_BOOL m_bEOD; |
| 127 uint8_t m_Operator; | 127 uint8_t m_Operator; |
| 128 }; | 128 }; |
| 129 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() | 129 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() |
| 130 : m_pScanline(NULL), | 130 : m_pScanline(nullptr), |
| 131 m_pSrcBuf(NULL), | 131 m_pSrcBuf(nullptr), |
| 132 m_SrcSize(0), | 132 m_SrcSize(0), |
| 133 m_dwLineBytes(0), | 133 m_dwLineBytes(0), |
| 134 m_SrcOffset(0), | 134 m_SrcOffset(0), |
| 135 m_bEOD(FALSE), | 135 m_bEOD(FALSE), |
| 136 m_Operator(0) {} | 136 m_Operator(0) {} |
| 137 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { | 137 CCodec_RLScanlineDecoder::~CCodec_RLScanlineDecoder() { |
| 138 FX_Free(m_pScanline); | 138 FX_Free(m_pScanline); |
| 139 } | 139 } |
| 140 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { | 140 FX_BOOL CCodec_RLScanlineDecoder::CheckDestSize() { |
| 141 uint32_t i = 0; | 141 uint32_t i = 0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 m_SrcOffset = 0; | 199 m_SrcOffset = 0; |
| 200 m_bEOD = FALSE; | 200 m_bEOD = FALSE; |
| 201 m_Operator = 0; | 201 m_Operator = 0; |
| 202 return TRUE; | 202 return TRUE; |
| 203 } | 203 } |
| 204 uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { | 204 uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine() { |
| 205 if (m_SrcOffset == 0) { | 205 if (m_SrcOffset == 0) { |
| 206 GetNextOperator(); | 206 GetNextOperator(); |
| 207 } else { | 207 } else { |
| 208 if (m_bEOD) { | 208 if (m_bEOD) { |
| 209 return NULL; | 209 return nullptr; |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 FXSYS_memset(m_pScanline, 0, m_Pitch); | 212 FXSYS_memset(m_pScanline, 0, m_Pitch); |
| 213 uint32_t col_pos = 0; | 213 uint32_t col_pos = 0; |
| 214 FX_BOOL eol = FALSE; | 214 FX_BOOL eol = FALSE; |
| 215 while (m_SrcOffset < m_SrcSize && !eol) { | 215 while (m_SrcOffset < m_SrcSize && !eol) { |
| 216 if (m_Operator < 128) { | 216 if (m_Operator < 128) { |
| 217 uint32_t copy_len = m_Operator + 1; | 217 uint32_t copy_len = m_Operator + 1; |
| 218 if (col_pos + copy_len >= m_dwLineBytes) { | 218 if (col_pos + copy_len >= m_dwLineBytes) { |
| 219 copy_len = m_dwLineBytes - col_pos; | 219 copy_len = m_dwLineBytes - col_pos; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 int bpc) { | 292 int bpc) { |
| 293 std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( | 293 std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( |
| 294 new CCodec_RLScanlineDecoder); | 294 new CCodec_RLScanlineDecoder); |
| 295 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 295 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
| 296 bpc)) { | 296 bpc)) { |
| 297 return nullptr; | 297 return nullptr; |
| 298 } | 298 } |
| 299 | 299 |
| 300 return pRLScanlineDecoder.release(); | 300 return pRLScanlineDecoder.release(); |
| 301 } | 301 } |
| OLD | NEW |