Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: core/fpdfapi/parser/fpdf_parser_decode.cpp

Issue 2572843002: Return unique_ptr<>s from fxcodec/ (Closed)
Patch Set: std::move it Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fpdfapi/parser/fpdf_parser_decode.h" 7 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 238 }
239 FXSYS_memset(dest_buf + dest_count, fill, 257 - src_buf[i]); 239 FXSYS_memset(dest_buf + dest_count, fill, 257 - src_buf[i]);
240 dest_count += 257 - src_buf[i]; 240 dest_count += 257 - src_buf[i];
241 i += 2; 241 i += 2;
242 } 242 }
243 } 243 }
244 244
245 return std::min(i + 1, src_size); 245 return std::min(i + 1, src_size);
246 } 246 }
247 247
248 CCodec_ScanlineDecoder* FPDFAPI_CreateFaxDecoder( 248 std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder(
249 const uint8_t* src_buf, 249 const uint8_t* src_buf,
250 uint32_t src_size, 250 uint32_t src_size,
251 int width, 251 int width,
252 int height, 252 int height,
253 const CPDF_Dictionary* pParams) { 253 const CPDF_Dictionary* pParams) {
254 int K = 0; 254 int K = 0;
255 bool EndOfLine = false; 255 bool EndOfLine = false;
256 bool ByteAlign = false; 256 bool ByteAlign = false;
257 bool BlackIs1 = false; 257 bool BlackIs1 = false;
258 int Columns = 1728; 258 int Columns = 1728;
259 int Rows = 0; 259 int Rows = 0;
260 if (pParams) { 260 if (pParams) {
261 K = pParams->GetIntegerFor("K"); 261 K = pParams->GetIntegerFor("K");
262 EndOfLine = !!pParams->GetIntegerFor("EndOfLine"); 262 EndOfLine = !!pParams->GetIntegerFor("EndOfLine");
263 ByteAlign = !!pParams->GetIntegerFor("EncodedByteAlign"); 263 ByteAlign = !!pParams->GetIntegerFor("EncodedByteAlign");
264 BlackIs1 = !!pParams->GetIntegerFor("BlackIs1"); 264 BlackIs1 = !!pParams->GetIntegerFor("BlackIs1");
265 Columns = pParams->GetIntegerFor("Columns", 1728); 265 Columns = pParams->GetIntegerFor("Columns", 1728);
266 Rows = pParams->GetIntegerFor("Rows"); 266 Rows = pParams->GetIntegerFor("Rows");
267 if (Rows > USHRT_MAX) { 267 if (Rows > USHRT_MAX) {
268 Rows = 0; 268 Rows = 0;
269 } 269 }
270 } 270 }
271 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder( 271 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder(
272 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, 272 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1,
273 Columns, Rows); 273 Columns, Rows);
274 } 274 }
275 275
276 CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( 276 std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder(
277 const uint8_t* src_buf, 277 const uint8_t* src_buf,
278 uint32_t src_size, 278 uint32_t src_size,
279 int width, 279 int width,
280 int height, 280 int height,
281 int nComps, 281 int nComps,
282 int bpc, 282 int bpc,
283 const CPDF_Dictionary* pParams) { 283 const CPDF_Dictionary* pParams) {
284 int predictor = 0; 284 int predictor = 0;
285 int Colors = 0, BitsPerComponent = 0, Columns = 0; 285 int Colors = 0, BitsPerComponent = 0, Columns = 0;
286 if (pParams) { 286 if (pParams) {
287 predictor = pParams->GetIntegerFor("Predictor"); 287 predictor = pParams->GetIntegerFor("Predictor");
288 Colors = pParams->GetIntegerFor("Colors", 1); 288 Colors = pParams->GetIntegerFor("Colors", 1);
289 BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); 289 BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8);
290 Columns = pParams->GetIntegerFor("Columns", 1); 290 Columns = pParams->GetIntegerFor("Columns", 1);
291 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { 291 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns))
292 return nullptr; 292 return nullptr;
293 }
294 } 293 }
295 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder( 294 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder(
296 src_buf, src_size, width, height, nComps, bpc, predictor, Colors, 295 src_buf, src_size, width, height, nComps, bpc, predictor, Colors,
297 BitsPerComponent, Columns); 296 BitsPerComponent, Columns);
298 } 297 }
299 298
300 uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW, 299 uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW,
301 const uint8_t* src_buf, 300 const uint8_t* src_buf,
302 uint32_t src_size, 301 uint32_t src_size,
303 CPDF_Dictionary* pParams, 302 CPDF_Dictionary* pParams,
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 uint32_t src_size, 566 uint32_t src_size,
568 uint8_t*& dest_buf, 567 uint8_t*& dest_buf,
569 uint32_t& dest_size) { 568 uint32_t& dest_size) {
570 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); 569 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule();
571 if (pEncoders) { 570 if (pEncoders) {
572 return pEncoders->GetFlateModule()->FlateOrLZWDecode( 571 return pEncoders->GetFlateModule()->FlateOrLZWDecode(
573 false, src_buf, src_size, false, 0, 0, 0, 0, 0, dest_buf, dest_size); 572 false, src_buf, src_size, false, 0, 0, 0, 0, 0, dest_buf, dest_size);
574 } 573 }
575 return 0; 574 return 0;
576 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698