From 1934a24ffdd8cd27b67fda6dc81cd4420d024db0 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 29 Aug 2018 19:32:47 +0000 Subject: Use pdfium::span<> in fpdf_parser_decode.h helper functions. Change-Id: Ib0a2bd21fe4304163cf9c080e07475e7c033c299 Reviewed-on: https://pdfium-review.googlesource.com/41570 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- core/fpdfapi/page/cpdf_streamparser.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp index 3d086b37ff..0d45ed0323 100644 --- a/core/fpdfapi/page/cpdf_streamparser.cpp +++ b/core/fpdfapi/page/cpdf_streamparser.cpp @@ -61,8 +61,7 @@ uint32_t DecodeAllScanlines(std::unique_ptr pDecoder, return pDecoder->GetSrcOffset(); } -uint32_t DecodeInlineStream(const uint8_t* src_buf, - uint32_t limit, +uint32_t DecodeInlineStream(pdfium::span src_span, int width, int height, const ByteString& decoder, @@ -71,30 +70,29 @@ uint32_t DecodeInlineStream(const uint8_t* src_buf, uint32_t* dest_size) { if (decoder == "CCITTFaxDecode" || decoder == "CCF") { std::unique_ptr pDecoder = - CreateFaxDecoder({src_buf, limit}, width, height, pParam); + CreateFaxDecoder(src_span, width, height, pParam); return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); } if (decoder == "ASCII85Decode" || decoder == "A85") - return A85Decode(src_buf, limit, dest_buf, dest_size); + return A85Decode(src_span, dest_buf, dest_size); if (decoder == "ASCIIHexDecode" || decoder == "AHx") - return HexDecode(src_buf, limit, dest_buf, dest_size); + return HexDecode(src_span, dest_buf, dest_size); if (decoder == "FlateDecode" || decoder == "Fl") { - return FlateOrLZWDecode(false, src_buf, limit, pParam, *dest_size, dest_buf, + return FlateOrLZWDecode(false, src_span, pParam, *dest_size, dest_buf, dest_size); } if (decoder == "LZWDecode" || decoder == "LZW") { - return FlateOrLZWDecode(true, src_buf, limit, pParam, 0, dest_buf, - dest_size); + return FlateOrLZWDecode(true, src_span, pParam, 0, dest_buf, dest_size); } if (decoder == "DCTDecode" || decoder == "DCT") { std::unique_ptr pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( - {src_buf, limit}, width, height, 0, + src_span, width, height, 0, !pParam || pParam->GetIntegerFor("ColorTransform", 1)); return DecodeAllScanlines(std::move(pDecoder), dest_buf, dest_size); } if (decoder == "RunLengthDecode" || decoder == "RL") - return RunLengthDecode(src_buf, limit, dest_buf, dest_size); + return RunLengthDecode(src_span, dest_buf, dest_size); *dest_size = 0; *dest_buf = 0; return 0xFFFFFFFF; @@ -185,9 +183,8 @@ std::unique_ptr CPDF_StreamParser::ReadInlineStream( } else { uint8_t* pIgnore = nullptr; uint32_t dwDestSize = OrigSize; - dwStreamSize = - DecodeInlineStream(&m_pBuf[m_Pos], m_pBuf.size() - m_Pos, width, height, - Decoder, pParam, &pIgnore, &dwDestSize); + dwStreamSize = DecodeInlineStream(m_pBuf.subspan(m_Pos), width, height, + Decoder, pParam, &pIgnore, &dwDestSize); FX_Free(pIgnore); if (static_cast(dwStreamSize) < 0) return nullptr; -- cgit v1.2.3