summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r--core/fxcodec/codec/ccodec_flatemodule.cpp34
-rw-r--r--core/fxcodec/codec/ccodec_flatemodule.h3
-rw-r--r--core/fxcodec/codec/fx_codec_rle_unittest.cpp14
3 files changed, 25 insertions, 26 deletions
diff --git a/core/fxcodec/codec/ccodec_flatemodule.cpp b/core/fxcodec/codec/ccodec_flatemodule.cpp
index 0a4baea38f..81be9b02d7 100644
--- a/core/fxcodec/codec/ccodec_flatemodule.cpp
+++ b/core/fxcodec/codec/ccodec_flatemodule.cpp
@@ -781,17 +781,17 @@ std::unique_ptr<CCodec_ScanlineDecoder> CCodec_FlateModule::CreateDecoder(
BitsPerComponent, Columns);
}
-uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
- bool bEarlyChange,
- int predictor,
- int Colors,
- int BitsPerComponent,
- int Columns,
- uint32_t estimated_size,
- uint8_t** dest_buf,
- uint32_t* dest_size) {
+uint32_t CCodec_FlateModule::FlateOrLZWDecode(
+ bool bLZW,
+ pdfium::span<const uint8_t> src_span,
+ bool bEarlyChange,
+ int predictor,
+ int Colors,
+ int BitsPerComponent,
+ int Columns,
+ uint32_t estimated_size,
+ uint8_t** dest_buf,
+ uint32_t* dest_size) {
*dest_buf = nullptr;
uint32_t offset = 0;
PredictorType predictor_type = GetPredictor(predictor);
@@ -799,19 +799,19 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW,
if (bLZW) {
auto decoder = pdfium::MakeUnique<CLZWDecoder>();
*dest_size = 0xFFFFFFFF;
- offset = src_size;
- int err =
- decoder->Decode(nullptr, *dest_size, src_buf, offset, bEarlyChange);
+ offset = src_span.size();
+ int err = decoder->Decode(nullptr, *dest_size, src_span.data(), offset,
+ bEarlyChange);
if (err || *dest_size == 0 || *dest_size + 1 < *dest_size)
return FX_INVALID_OFFSET;
decoder = pdfium::MakeUnique<CLZWDecoder>();
*dest_buf = FX_Alloc(uint8_t, *dest_size + 1);
(*dest_buf)[*dest_size] = '\0';
- decoder->Decode(*dest_buf, *dest_size, src_buf, offset, bEarlyChange);
+ decoder->Decode(*dest_buf, *dest_size, src_span.data(), offset,
+ bEarlyChange);
} else {
- FlateUncompress(pdfium::make_span(src_buf, src_size), estimated_size,
- *dest_buf, *dest_size, offset);
+ FlateUncompress(src_span, estimated_size, *dest_buf, *dest_size, offset);
}
bool ret = false;
diff --git a/core/fxcodec/codec/ccodec_flatemodule.h b/core/fxcodec/codec/ccodec_flatemodule.h
index dab34be8a0..11281522e0 100644
--- a/core/fxcodec/codec/ccodec_flatemodule.h
+++ b/core/fxcodec/codec/ccodec_flatemodule.h
@@ -28,8 +28,7 @@ class CCodec_FlateModule {
int Columns);
uint32_t FlateOrLZWDecode(bool bLZW,
- const uint8_t* src_buf,
- uint32_t src_size,
+ pdfium::span<const uint8_t> src_buf,
bool bEarlyChange,
int predictor,
int Colors,
diff --git a/core/fxcodec/codec/fx_codec_rle_unittest.cpp b/core/fxcodec/codec/fx_codec_rle_unittest.cpp
index 7b0af90819..47067cb030 100644
--- a/core/fxcodec/codec/fx_codec_rle_unittest.cpp
+++ b/core/fxcodec/codec/fx_codec_rle_unittest.cpp
@@ -74,7 +74,7 @@ TEST(fxcodec, RLETestNormalInputs) {
pEncoders->RunLengthEncode(src_buf_1, src_size, &dest_buf, &dest_size));
uint8_t* decoded_buf = nullptr;
uint32_t decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_1[i], decoded_buf[i]) << " at " << i;
@@ -88,7 +88,7 @@ TEST(fxcodec, RLETestNormalInputs) {
pEncoders->RunLengthEncode(src_buf_2, src_size, &dest_buf, &dest_size));
decoded_buf = nullptr;
decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_2[i], decoded_buf[i]) << " at " << i;
@@ -102,7 +102,7 @@ TEST(fxcodec, RLETestNormalInputs) {
pEncoders->RunLengthEncode(src_buf_3, src_size, &dest_buf, &dest_size));
decoded_buf = nullptr;
decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_3[i], decoded_buf[i]) << " at " << i;
@@ -143,7 +143,7 @@ TEST(fxcodec, RLETestFullLengthInputs) {
pEncoders->RunLengthEncode(src_buf_1, src_size, &dest_buf, &dest_size));
uint8_t* decoded_buf = nullptr;
uint32_t decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_1[i], decoded_buf[i]) << " at " << i;
@@ -157,7 +157,7 @@ TEST(fxcodec, RLETestFullLengthInputs) {
pEncoders->RunLengthEncode(src_buf_2, src_size, &dest_buf, &dest_size));
decoded_buf = nullptr;
decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_2[i], decoded_buf[i]) << " at " << i;
@@ -171,7 +171,7 @@ TEST(fxcodec, RLETestFullLengthInputs) {
pEncoders->RunLengthEncode(src_buf_3, src_size, &dest_buf, &dest_size));
decoded_buf = nullptr;
decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_3[i], decoded_buf[i]) << " at " << i;
@@ -185,7 +185,7 @@ TEST(fxcodec, RLETestFullLengthInputs) {
pEncoders->RunLengthEncode(src_buf_4, src_size, &dest_buf, &dest_size));
decoded_buf = nullptr;
decoded_size = 0;
- RunLengthDecode(dest_buf, dest_size, &decoded_buf, &decoded_size);
+ RunLengthDecode({dest_buf, dest_size}, &decoded_buf, &decoded_size);
ASSERT_EQ(src_size, decoded_size);
for (uint32_t i = 0; i < src_size; i++)
EXPECT_EQ(src_buf_4[i], decoded_buf[i]) << " at " << i;