summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-29 19:32:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-29 19:32:47 +0000
commit1934a24ffdd8cd27b67fda6dc81cd4420d024db0 (patch)
tree514e968715388b7a86ee66bc575d2e21f11fceb7 /core/fpdfapi/page
parentb2b1f55214688d5e3bfd5015e0a4829d2f314c27 (diff)
downloadpdfium-1934a24ffdd8cd27b67fda6dc81cd4420d024db0.tar.xz
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 <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp23
1 files changed, 10 insertions, 13 deletions
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<CCodec_ScanlineDecoder> pDecoder,
return pDecoder->GetSrcOffset();
}
-uint32_t DecodeInlineStream(const uint8_t* src_buf,
- uint32_t limit,
+uint32_t DecodeInlineStream(pdfium::span<const uint8_t> 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<CCodec_ScanlineDecoder> 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<CCodec_ScanlineDecoder> 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_Stream> 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<int>(dwStreamSize) < 0)
return nullptr;