| 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 <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "core/fxcodec/codec/codec_int.h" | 13 #include "core/fxcodec/codec/codec_int.h" |
| 13 #include "core/fxcrt/include/fx_ext.h" | 14 #include "core/fxcrt/include/fx_ext.h" |
| 14 #include "core/fxcrt/include/fx_safe_types.h" | 15 #include "core/fxcrt/include/fx_safe_types.h" |
| 15 #include "third_party/base/logging.h" | 16 #include "third_party/base/logging.h" |
| 16 | 17 |
| 17 CCodec_ModuleMgr::CCodec_ModuleMgr() | 18 CCodec_ModuleMgr::CCodec_ModuleMgr() |
| 18 : m_pBasicModule(new CCodec_BasicModule), | 19 : m_pBasicModule(new CCodec_BasicModule), |
| 19 m_pFaxModule(new CCodec_FaxModule), | 20 m_pFaxModule(new CCodec_FaxModule), |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 uint8_t count = 257 - m_Operator; | 391 uint8_t count = 257 - m_Operator; |
| 391 FXSYS_assert((uint32_t)count >= used_bytes); | 392 FXSYS_assert((uint32_t)count >= used_bytes); |
| 392 if (used_bytes == count) { | 393 if (used_bytes == count) { |
| 393 m_SrcOffset++; | 394 m_SrcOffset++; |
| 394 GetNextOperator(); | 395 GetNextOperator(); |
| 395 return; | 396 return; |
| 396 } | 397 } |
| 397 count -= used_bytes; | 398 count -= used_bytes; |
| 398 m_Operator = 257 - count; | 399 m_Operator = 257 - count; |
| 399 } | 400 } |
| 400 ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder( | 401 |
| 402 CCodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder( |
| 401 const uint8_t* src_buf, | 403 const uint8_t* src_buf, |
| 402 uint32_t src_size, | 404 uint32_t src_size, |
| 403 int width, | 405 int width, |
| 404 int height, | 406 int height, |
| 405 int nComps, | 407 int nComps, |
| 406 int bpc) { | 408 int bpc) { |
| 407 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; | 409 std::unique_ptr<CCodec_RLScanlineDecoder> pRLScanlineDecoder( |
| 410 new CCodec_RLScanlineDecoder); |
| 408 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, | 411 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, |
| 409 bpc)) { | 412 bpc)) { |
| 410 delete pRLScanlineDecoder; | 413 return nullptr; |
| 411 return NULL; | |
| 412 } | 414 } |
| 413 return pRLScanlineDecoder; | 415 |
| 416 return pRLScanlineDecoder.release(); |
| 414 } | 417 } |
| OLD | NEW |