Rename BmpModule to BmpDecoder.
Change-Id: I39ffe95b84ab00459848d9dc605039df7c7c0541
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69952
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index d380db8..70e71b7 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -90,10 +90,10 @@
]
if (pdf_enable_xfa_bmp) {
sources += [
+ "bmp/bmp_decoder.cpp",
+ "bmp/bmp_decoder.h",
"bmp/bmp_progressive_decoder.cpp",
"bmp/bmp_progressive_decoder.h",
- "bmp/bmpmodule.cpp",
- "bmp/bmpmodule.h",
"bmp/cfx_bmpcontext.cpp",
"bmp/cfx_bmpcontext.h",
"bmp/cfx_bmpdecompressor.cpp",
diff --git a/core/fxcodec/bmp/bmpmodule.cpp b/core/fxcodec/bmp/bmp_decoder.cpp
similarity index 81%
rename from core/fxcodec/bmp/bmpmodule.cpp
rename to core/fxcodec/bmp/bmp_decoder.cpp
index 68275ac..64cac78 100644
--- a/core/fxcodec/bmp/bmpmodule.cpp
+++ b/core/fxcodec/bmp/bmp_decoder.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/bmp/bmp_decoder.h"
#include <utility>
@@ -18,13 +18,13 @@
namespace fxcodec {
// static
-std::unique_ptr<ProgressiveDecoderIface::Context> BmpModule::StartDecode(
+std::unique_ptr<ProgressiveDecoderIface::Context> BmpDecoder::StartDecode(
Delegate* pDelegate) {
return pdfium::MakeUnique<CFX_BmpContext>(pDelegate);
}
// static
-BmpModule::Status BmpModule::ReadHeader(
+BmpDecoder::Status BmpDecoder::ReadHeader(
ProgressiveDecoderIface::Context* pContext,
int32_t* width,
int32_t* height,
@@ -53,21 +53,21 @@
}
// static
-BmpModule::Status BmpModule::LoadImage(
+BmpDecoder::Status BmpDecoder::LoadImage(
ProgressiveDecoderIface::Context* pContext) {
return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.DecodeImage();
}
// static
-FX_FILESIZE BmpModule::GetAvailInput(
+FX_FILESIZE BmpDecoder::GetAvailInput(
ProgressiveDecoderIface::Context* pContext) {
return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput();
}
// static
-bool BmpModule::Input(ProgressiveDecoderIface::Context* pContext,
- RetainPtr<CFX_CodecMemory> codec_memory,
- CFX_DIBAttribute*) {
+bool BmpDecoder::Input(ProgressiveDecoderIface::Context* pContext,
+ RetainPtr<CFX_CodecMemory> codec_memory,
+ CFX_DIBAttribute*) {
auto* ctx = static_cast<CFX_BmpContext*>(pContext);
ctx->m_Bmp.SetInputBuffer(std::move(codec_memory));
return true;
diff --git a/core/fxcodec/bmp/bmpmodule.h b/core/fxcodec/bmp/bmp_decoder.h
similarity index 84%
rename from core/fxcodec/bmp/bmpmodule.h
rename to core/fxcodec/bmp/bmp_decoder.h
index 08d2c7a..162c0b5 100644
--- a/core/fxcodec/bmp/bmpmodule.h
+++ b/core/fxcodec/bmp/bmp_decoder.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef CORE_FXCODEC_BMP_BMPMODULE_H_
-#define CORE_FXCODEC_BMP_BMPMODULE_H_
+#ifndef CORE_FXCODEC_BMP_BMP_DECODER_H_
+#define CORE_FXCODEC_BMP_BMP_DECODER_H_
#include <memory>
#include <vector>
@@ -21,7 +21,7 @@
class CFX_DIBAttribute;
-class BmpModule {
+class BmpDecoder {
public:
class Delegate {
public:
@@ -48,13 +48,13 @@
RetainPtr<CFX_CodecMemory> codec_memory,
CFX_DIBAttribute* pAttribute);
- BmpModule() = delete;
- BmpModule(const BmpModule&) = delete;
- BmpModule& operator=(const BmpModule&) = delete;
+ BmpDecoder() = delete;
+ BmpDecoder(const BmpDecoder&) = delete;
+ BmpDecoder& operator=(const BmpDecoder&) = delete;
};
} // namespace fxcodec
-using BmpModule = fxcodec::BmpModule;
+using BmpDecoder = fxcodec::BmpDecoder;
-#endif // CORE_FXCODEC_BMP_BMPMODULE_H_
+#endif // CORE_FXCODEC_BMP_BMP_DECODER_H_
diff --git a/core/fxcodec/bmp/bmp_progressive_decoder.cpp b/core/fxcodec/bmp/bmp_progressive_decoder.cpp
index 6af9d64..3b453de 100644
--- a/core/fxcodec/bmp/bmp_progressive_decoder.cpp
+++ b/core/fxcodec/bmp/bmp_progressive_decoder.cpp
@@ -6,7 +6,7 @@
#include "core/fxcodec/bmp/bmp_progressive_decoder.h"
-#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/bmp/bmp_decoder.h"
#include "core/fxcodec/cfx_codec_memory.h"
namespace fxcodec {
@@ -22,13 +22,13 @@
BmpProgressiveDecoder::~BmpProgressiveDecoder() = default;
FX_FILESIZE BmpProgressiveDecoder::GetAvailInput(Context* context) const {
- return BmpModule::GetAvailInput(context);
+ return BmpDecoder::GetAvailInput(context);
}
bool BmpProgressiveDecoder::Input(Context* context,
RetainPtr<CFX_CodecMemory> codec_memory,
CFX_DIBAttribute* pAttribute) {
- return BmpModule::Input(context, codec_memory, pAttribute);
+ return BmpDecoder::Input(context, codec_memory, pAttribute);
}
} // namespace fxcodec
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.cpp b/core/fxcodec/bmp/cfx_bmpcontext.cpp
index 494dfac..3702d0a 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.cpp
+++ b/core/fxcodec/bmp/cfx_bmpcontext.cpp
@@ -8,7 +8,7 @@
namespace fxcodec {
-CFX_BmpContext::CFX_BmpContext(BmpModule::Delegate* pDelegate)
+CFX_BmpContext::CFX_BmpContext(BmpDecoder::Delegate* pDelegate)
: m_Bmp(this), m_pDelegate(pDelegate) {}
CFX_BmpContext::~CFX_BmpContext() = default;
diff --git a/core/fxcodec/bmp/cfx_bmpcontext.h b/core/fxcodec/bmp/cfx_bmpcontext.h
index 0e21d31..5a49216 100644
--- a/core/fxcodec/bmp/cfx_bmpcontext.h
+++ b/core/fxcodec/bmp/cfx_bmpcontext.h
@@ -7,7 +7,7 @@
#ifndef CORE_FXCODEC_BMP_CFX_BMPCONTEXT_H_
#define CORE_FXCODEC_BMP_CFX_BMPCONTEXT_H_
-#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/bmp/bmp_decoder.h"
#include "core/fxcodec/bmp/cfx_bmpdecompressor.h"
#include "core/fxcodec/bmp/fx_bmp.h"
#include "core/fxcrt/unowned_ptr.h"
@@ -16,11 +16,11 @@
class CFX_BmpContext final : public ProgressiveDecoderIface::Context {
public:
- explicit CFX_BmpContext(BmpModule::Delegate* pDelegate);
+ explicit CFX_BmpContext(BmpDecoder::Delegate* pDelegate);
~CFX_BmpContext() override;
CFX_BmpDecompressor m_Bmp;
- UnownedPtr<BmpModule::Delegate> const m_pDelegate;
+ UnownedPtr<BmpDecoder::Delegate> const m_pDelegate;
};
} // namespace fxcodec
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
index 7414647..21e991a 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
@@ -70,15 +70,15 @@
return context_->m_pDelegate->BmpInputImagePositionBuf(rcd_pos);
}
-BmpModule::Status CFX_BmpDecompressor::ReadHeader() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadHeader() {
if (decode_status_ == DecodeStatus::kHeader) {
- BmpModule::Status status = ReadBmpHeader();
- if (status != BmpModule::Status::kSuccess)
+ BmpDecoder::Status status = ReadBmpHeader();
+ if (status != BmpDecoder::Status::kSuccess)
return status;
}
if (decode_status_ != DecodeStatus::kPal)
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
if (compress_flag_ == kBmpBitfields)
return ReadBmpBitfields();
@@ -86,11 +86,11 @@
return ReadBmpPalette();
}
-BmpModule::Status CFX_BmpDecompressor::ReadBmpHeader() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadBmpHeader() {
BmpFileHeader bmp_header;
if (!ReadData(reinterpret_cast<uint8_t*>(&bmp_header),
sizeof(BmpFileHeader))) {
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
}
bmp_header.bfType =
@@ -100,33 +100,33 @@
data_size_ =
FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&bmp_header.bfSize));
if (bmp_header.bfType != kBmpSignature)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
size_t pos = input_buffer_->GetPosition();
if (!ReadData(reinterpret_cast<uint8_t*>(&img_ifh_size_),
sizeof(img_ifh_size_))) {
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
}
if (!input_buffer_->Seek(pos))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
img_ifh_size_ =
FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&img_ifh_size_));
pal_type_ = 0;
- BmpModule::Status status = ReadBmpHeaderIfh();
- if (status != BmpModule::Status::kSuccess)
+ BmpDecoder::Status status = ReadBmpHeaderIfh();
+ if (status != BmpDecoder::Status::kSuccess)
return status;
return ReadBmpHeaderDimensions();
}
-BmpModule::Status CFX_BmpDecompressor::ReadBmpHeaderIfh() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadBmpHeaderIfh() {
if (img_ifh_size_ == kBmpCoreHeaderSize) {
pal_type_ = 1;
BmpCoreHeader bmp_core_header;
if (!ReadData(reinterpret_cast<uint8_t*>(&bmp_core_header),
sizeof(BmpCoreHeader))) {
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
}
width_ = FXWORD_GET_LSBFIRST(
@@ -137,14 +137,14 @@
reinterpret_cast<uint8_t*>(&bmp_core_header.bcBitCount));
compress_flag_ = kBmpRgb;
img_tb_flag_ = false;
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
if (img_ifh_size_ == kBmpInfoHeaderSize) {
BmpInfoHeader bmp_info_header;
if (!ReadData(reinterpret_cast<uint8_t*>(&bmp_info_header),
sizeof(BmpInfoHeader))) {
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
}
width_ = FXDWORD_GET_LSBFIRST(
@@ -162,26 +162,26 @@
dpi_y_ = static_cast<int32_t>(FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&bmp_info_header.biYPelsPerMeter)));
if (!SetHeight(signed_height))
- return BmpModule::Status::kFail;
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kFail;
+ return BmpDecoder::Status::kSuccess;
}
if (img_ifh_size_ <= sizeof(BmpInfoHeader))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
FX_SAFE_SIZE_T new_pos = input_buffer_->GetPosition();
BmpInfoHeader bmp_info_header;
if (!ReadData(reinterpret_cast<uint8_t*>(&bmp_info_header),
sizeof(bmp_info_header))) {
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
}
new_pos += img_ifh_size_;
if (!new_pos.IsValid())
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
if (!input_buffer_->Seek(new_pos.ValueOrDie()))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
uint16_t bi_planes;
width_ = FXDWORD_GET_LSBFIRST(
@@ -201,16 +201,16 @@
dpi_y_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&bmp_info_header.biYPelsPerMeter));
if (!SetHeight(signed_height))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
if (compress_flag_ != kBmpRgb || bi_planes != 1 || color_used_ != 0)
- return BmpModule::Status::kFail;
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kFail;
+ return BmpDecoder::Status::kSuccess;
}
-BmpModule::Status CFX_BmpDecompressor::ReadBmpHeaderDimensions() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadBmpHeaderDimensions() {
if (width_ > kBmpMaxImageDimension || height_ > kBmpMaxImageDimension ||
compress_flag_ > kBmpBitfields) {
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
switch (bit_counts_) {
@@ -220,17 +220,17 @@
case 16:
case 24: {
if (color_used_ > 1U << bit_counts_)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
break;
}
case 32:
break;
default:
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
FX_SAFE_UINT32 stride = CalculatePitch32(bit_counts_, width_);
if (!stride.IsValid())
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
src_row_bytes_ = stride.ValueOrDie();
switch (bit_counts_) {
@@ -239,7 +239,7 @@
case 8:
stride = CalculatePitch32(8, width_);
if (!stride.IsValid())
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
out_row_bytes_ = stride.ValueOrDie();
components_ = 1;
break;
@@ -247,7 +247,7 @@
case 24:
stride = CalculatePitch32(24, width_);
if (!stride.IsValid())
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
out_row_bytes_ = stride.ValueOrDie();
components_ = 3;
break;
@@ -259,34 +259,34 @@
out_row_buffer_.clear();
if (out_row_bytes_ <= 0)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
out_row_buffer_.resize(out_row_bytes_);
SaveDecodingStatus(DecodeStatus::kPal);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
-BmpModule::Status CFX_BmpDecompressor::ReadBmpBitfields() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadBmpBitfields() {
if (bit_counts_ != 16 && bit_counts_ != 32)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
uint32_t masks[3];
if (!ReadData(reinterpret_cast<uint8_t*>(masks), sizeof(masks)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
mask_red_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&masks[0]));
mask_green_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&masks[1]));
mask_blue_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&masks[2]));
if (mask_red_ & mask_green_ || mask_red_ & mask_blue_ ||
mask_green_ & mask_blue_) {
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
header_offset_ = std::max(header_offset_, 26 + img_ifh_size_);
SaveDecodingStatus(DecodeStatus::kDataPre);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
-BmpModule::Status CFX_BmpDecompressor::ReadBmpPalette() {
+BmpDecoder::Status CFX_BmpDecompressor::ReadBmpPalette() {
if (bit_counts_ == 16) {
mask_red_ = 0x7C00;
mask_green_ = 0x03E0;
@@ -301,7 +301,7 @@
std::vector<uint8_t, FxAllocAllocator<uint8_t>> src_pal(src_pal_size);
uint8_t* src_pal_data = src_pal.data();
if (!ReadData(src_pal_data, src_pal_size))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
palette_.resize(pal_num_);
int32_t src_pal_index = 0;
@@ -322,7 +322,7 @@
header_offset_ = std::max(
header_offset_, 14 + img_ifh_size_ + pal_num_ * (pal_type_ ? 3 : 4));
SaveDecodingStatus(DecodeStatus::kDataPre);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
bool CFX_BmpDecompressor::ValidateFlag() const {
@@ -337,19 +337,19 @@
}
}
-BmpModule::Status CFX_BmpDecompressor::DecodeImage() {
+BmpDecoder::Status CFX_BmpDecompressor::DecodeImage() {
if (decode_status_ == DecodeStatus::kDataPre) {
input_buffer_->Seek(0);
if (!GetDataPosition(header_offset_)) {
decode_status_ = DecodeStatus::kTail;
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
row_num_ = 0;
SaveDecodingStatus(DecodeStatus::kData);
}
if (decode_status_ != DecodeStatus::kData || !ValidateFlag())
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
switch (compress_flag_) {
case kBmpRgb:
@@ -360,7 +360,7 @@
case kBmpRle4:
return DecodeRLE4();
default:
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
}
@@ -368,12 +368,12 @@
return val < pal_num_;
}
-BmpModule::Status CFX_BmpDecompressor::DecodeRGB() {
+BmpDecoder::Status CFX_BmpDecompressor::DecodeRGB() {
std::vector<uint8_t, FxAllocAllocator<uint8_t>> dest_buf(src_row_bytes_);
while (row_num_ < height_) {
size_t idx = 0;
if (!ReadData(dest_buf.data(), src_row_bytes_))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
SaveDecodingStatus(DecodeStatus::kData);
switch (bit_counts_) {
@@ -407,7 +407,7 @@
green_bits += blue_bits;
red_bits += green_bits;
if (blue_bits > 8 || green_bits < 8 || red_bits < 8)
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
blue_bits = 8 - blue_bits;
green_bits -= 8;
red_bits -= 8;
@@ -433,31 +433,31 @@
}
for (uint8_t byte : out_row_buffer_) {
if (!ValidateColorIndex(byte))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
ReadNextScanline();
}
SaveDecodingStatus(DecodeStatus::kTail);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
-BmpModule::Status CFX_BmpDecompressor::DecodeRLE8() {
+BmpDecoder::Status CFX_BmpDecompressor::DecodeRLE8() {
uint8_t first_part;
col_num_ = 0;
while (true) {
if (!ReadData(&first_part, sizeof(first_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
switch (first_part) {
case kRleMarker: {
if (!ReadData(&first_part, sizeof(first_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
switch (first_part) {
case kRleEol: {
if (row_num_ >= height_) {
SaveDecodingStatus(DecodeStatus::kTail);
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
ReadNextScanline();
@@ -470,17 +470,17 @@
if (row_num_ < height_)
ReadNextScanline();
SaveDecodingStatus(DecodeStatus::kTail);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
case kRleDelta: {
uint8_t delta[2];
if (!ReadData(delta, sizeof(delta)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
col_num_ += delta[0];
size_t bmp_row_num__next = row_num_ + delta[1];
if (col_num_ >= out_row_bytes_ || bmp_row_num__next >= height_)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
while (row_num_ < bmp_row_num__next) {
std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
@@ -491,7 +491,7 @@
default: {
int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size || static_cast<int32_t>(first_part) > avail_size)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
size_t second_part_size =
first_part & 1 ? first_part + 1 : first_part;
@@ -499,13 +499,13 @@
second_part_size);
uint8_t* second_part_data = second_part.data();
if (!ReadData(second_part_data, second_part_size))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
std::copy(second_part_data, second_part_data + first_part,
out_row_buffer_.begin() + col_num_);
for (size_t i = col_num_; i < col_num_ + first_part; ++i) {
if (!ValidateColorIndex(out_row_buffer_[i]))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
col_num_ += first_part;
}
@@ -515,40 +515,40 @@
default: {
int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size || static_cast<int32_t>(first_part) > avail_size)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
uint8_t second_part;
if (!ReadData(&second_part, sizeof(second_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
std::fill(out_row_buffer_.begin() + col_num_,
out_row_buffer_.begin() + col_num_ + first_part, second_part);
if (!ValidateColorIndex(out_row_buffer_[col_num_]))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
col_num_ += first_part;
}
}
}
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
-BmpModule::Status CFX_BmpDecompressor::DecodeRLE4() {
+BmpDecoder::Status CFX_BmpDecompressor::DecodeRLE4() {
uint8_t first_part;
col_num_ = 0;
while (true) {
if (!ReadData(&first_part, sizeof(first_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
switch (first_part) {
case kRleMarker: {
if (!ReadData(&first_part, sizeof(first_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
switch (first_part) {
case kRleEol: {
if (row_num_ >= height_) {
SaveDecodingStatus(DecodeStatus::kTail);
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
ReadNextScanline();
@@ -561,17 +561,17 @@
if (row_num_ < height_)
ReadNextScanline();
SaveDecodingStatus(DecodeStatus::kTail);
- return BmpModule::Status::kSuccess;
+ return BmpDecoder::Status::kSuccess;
}
case kRleDelta: {
uint8_t delta[2];
if (!ReadData(delta, sizeof(delta)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
col_num_ += delta[0];
size_t bmp_row_num__next = row_num_ + delta[1];
if (col_num_ >= out_row_bytes_ || bmp_row_num__next >= height_)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
while (row_num_ < bmp_row_num__next) {
std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
@@ -582,11 +582,11 @@
default: {
int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
uint8_t size = HalfRoundUp(first_part);
if (static_cast<int32_t>(first_part) > avail_size) {
if (size + (col_num_ >> 1) > src_row_bytes_)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
first_part = avail_size - 1;
}
@@ -595,13 +595,13 @@
second_part_size);
uint8_t* second_part_data = second_part.data();
if (!ReadData(second_part_data, second_part_size))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
for (uint8_t i = 0; i < first_part; i++) {
uint8_t color = (i & 0x01) ? (*second_part_data++ & 0x0F)
: (*second_part_data & 0xF0) >> 4;
if (!ValidateColorIndex(color))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
out_row_buffer_[col_num_++] = color;
}
@@ -612,32 +612,32 @@
default: {
int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
if (static_cast<int32_t>(first_part) > avail_size) {
uint8_t size = HalfRoundUp(first_part);
if (size + (col_num_ >> 1) > src_row_bytes_)
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
first_part = avail_size - 1;
}
uint8_t second_part;
if (!ReadData(&second_part, sizeof(second_part)))
- return BmpModule::Status::kContinue;
+ return BmpDecoder::Status::kContinue;
for (uint8_t i = 0; i < first_part; i++) {
uint8_t second_byte = second_part;
second_byte =
i & 0x01 ? (second_byte & 0x0F) : (second_byte & 0xF0) >> 4;
if (!ValidateColorIndex(second_byte))
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
out_row_buffer_[col_num_++] = second_byte;
}
}
}
}
- return BmpModule::Status::kFail;
+ return BmpDecoder::Status::kFail;
}
bool CFX_BmpDecompressor::ReadData(uint8_t* destination, uint32_t size) {
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.h b/core/fxcodec/bmp/cfx_bmpdecompressor.h
index 98429b3..e85c805 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.h
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.h
@@ -9,7 +9,7 @@
#include <vector>
-#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/bmp/bmp_decoder.h"
#include "core/fxcodec/bmp/fx_bmp.h"
#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/retain_ptr.h"
@@ -26,8 +26,8 @@
explicit CFX_BmpDecompressor(CFX_BmpContext* context);
~CFX_BmpDecompressor();
- BmpModule::Status DecodeImage();
- BmpModule::Status ReadHeader();
+ BmpDecoder::Status DecodeImage();
+ BmpDecoder::Status ReadHeader();
void SetInputBuffer(RetainPtr<CFX_CodecMemory> codec_memory);
FX_FILESIZE GetAvailInput() const;
@@ -49,16 +49,16 @@
kTail,
};
- BmpModule::Status ReadBmpHeader();
- BmpModule::Status ReadBmpHeaderIfh();
- BmpModule::Status ReadBmpHeaderDimensions();
- BmpModule::Status ReadBmpBitfields();
- BmpModule::Status ReadBmpPalette();
+ BmpDecoder::Status ReadBmpHeader();
+ BmpDecoder::Status ReadBmpHeaderIfh();
+ BmpDecoder::Status ReadBmpHeaderDimensions();
+ BmpDecoder::Status ReadBmpBitfields();
+ BmpDecoder::Status ReadBmpPalette();
bool GetDataPosition(uint32_t cur_pos);
void ReadNextScanline();
- BmpModule::Status DecodeRGB();
- BmpModule::Status DecodeRLE8();
- BmpModule::Status DecodeRLE4();
+ BmpDecoder::Status DecodeRGB();
+ BmpDecoder::Status DecodeRLE8();
+ BmpDecoder::Status DecodeRLE4();
bool ReadData(uint8_t* destination, uint32_t size);
void SaveDecodingStatus(DecodeStatus status);
bool ValidateColorIndex(uint8_t val) const;
diff --git a/core/fxcodec/progressivedecoder.cpp b/core/fxcodec/progressivedecoder.cpp
index bbc5c35..dd30428 100644
--- a/core/fxcodec/progressivedecoder.cpp
+++ b/core/fxcodec/progressivedecoder.cpp
@@ -702,25 +702,25 @@
bool ProgressiveDecoder::BmpDetectImageTypeInBuffer(
CFX_DIBAttribute* pAttribute) {
std::unique_ptr<ProgressiveDecoderIface::Context> pBmpContext =
- BmpModule::StartDecode(this);
- BmpModule::Input(pBmpContext.get(), m_pCodecMemory, nullptr);
+ BmpDecoder::StartDecode(this);
+ BmpDecoder::Input(pBmpContext.get(), m_pCodecMemory, nullptr);
const std::vector<uint32_t>* palette;
- BmpModule::Status read_result = BmpModule::ReadHeader(
+ BmpDecoder::Status read_result = BmpDecoder::ReadHeader(
pBmpContext.get(), &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
&m_SrcComponents, &m_SrcPaletteNumber, &palette, pAttribute);
- while (read_result == BmpModule::Status::kContinue) {
+ while (read_result == BmpDecoder::Status::kContinue) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_ERR_FORMAT;
if (!BmpReadMoreData(pBmpContext.get(), &error_status)) {
m_status = error_status;
return false;
}
- read_result = BmpModule::ReadHeader(
+ read_result = BmpDecoder::ReadHeader(
pBmpContext.get(), &m_SrcWidth, &m_SrcHeight, &m_BmpIsTopBottom,
&m_SrcComponents, &m_SrcPaletteNumber, &palette, pAttribute);
}
- if (read_result != BmpModule::Status::kSuccess) {
+ if (read_result != BmpDecoder::Status::kSuccess) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
}
@@ -753,7 +753,7 @@
}
uint32_t availableData = m_pFile->GetSize() - m_offSet +
- BmpModule::GetAvailInput(pBmpContext.get());
+ BmpDecoder::GetAvailInput(pBmpContext.get());
if (neededData > availableData) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -791,8 +791,8 @@
}
FXCODEC_STATUS ProgressiveDecoder::BmpContinueDecode() {
- BmpModule::Status read_res = BmpModule::LoadImage(m_pBmpContext.get());
- while (read_res == BmpModule::Status::kContinue) {
+ BmpDecoder::Status read_res = BmpDecoder::LoadImage(m_pBmpContext.get());
+ while (read_res == BmpDecoder::Status::kContinue) {
FXCODEC_STATUS error_status = FXCODEC_STATUS_DECODE_FINISH;
if (!BmpReadMoreData(m_pBmpContext.get(), &error_status)) {
m_pDeviceBitmap = nullptr;
@@ -800,12 +800,12 @@
m_status = error_status;
return m_status;
}
- read_res = BmpModule::LoadImage(m_pBmpContext.get());
+ read_res = BmpDecoder::LoadImage(m_pBmpContext.get());
}
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
- m_status = read_res == BmpModule::Status::kSuccess
+ m_status = read_res == BmpDecoder::Status::kSuccess
? FXCODEC_STATUS_DECODE_FINISH
: FXCODEC_STATUS_ERROR;
return m_status;
diff --git a/core/fxcodec/progressivedecoder.h b/core/fxcodec/progressivedecoder.h
index 87e3d1c..30cb73c 100644
--- a/core/fxcodec/progressivedecoder.h
+++ b/core/fxcodec/progressivedecoder.h
@@ -20,7 +20,7 @@
#include "core/fxge/fx_dib.h"
#ifdef PDF_ENABLE_XFA_BMP
-#include "core/fxcodec/bmp/bmpmodule.h"
+#include "core/fxcodec/bmp/bmp_decoder.h"
#endif // PDF_ENABLE_XFA_BMP
#ifdef PDF_ENABLE_XFA_GIF
@@ -42,7 +42,7 @@
class ProgressiveDecoder :
#ifdef PDF_ENABLE_XFA_BMP
- public BmpModule::Delegate,
+ public BmpDecoder::Delegate,
#endif // PDF_ENABLE_XFA_BMP
#ifdef PDF_ENABLE_XFA_GIF
public GifDecoder::Delegate,
@@ -167,7 +167,7 @@
#endif // PDF_ENABLE_XFA_GIF
#ifdef PDF_ENABLE_XFA_BMP
- // BmpModule::Delegate
+ // BmpDecoder::Delegate
bool BmpInputImagePositionBuf(uint32_t rcd_pos) override;
void BmpReadScanline(uint32_t row_num,
pdfium::span<const uint8_t> row_buf) override;