summaryrefslogtreecommitdiff
path: root/core/fxcodec/lbmp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-02-06 14:41:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-06 14:41:14 +0000
commit980beeb5b06facc5bf178c03394ad9487b9b4b69 (patch)
tree20c8c4c3f9763e5d9c2887bd515432e01869a1bc /core/fxcodec/lbmp
parent8e53c8c8e19a1f40d90f47068c7dd7ee6ffa275d (diff)
downloadpdfium-980beeb5b06facc5bf178c03394ad9487b9b4b69.tar.xz
Changing the member naming style in BMPDecompressor
Currently there is no indication in the name of it being a member variable and the capitalization is inconsistent. This CL brings them all into line with Chromium style. BUG=chromium:808336 Change-Id: Iaed0272b69350f316371a67eb513934a0169f451 Reviewed-on: https://pdfium-review.googlesource.com/25430 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec/lbmp')
-rw-r--r--core/fxcodec/lbmp/fx_bmp.cpp442
-rw-r--r--core/fxcodec/lbmp/fx_bmp.h68
2 files changed, 257 insertions, 253 deletions
diff --git a/core/fxcodec/lbmp/fx_bmp.cpp b/core/fxcodec/lbmp/fx_bmp.cpp
index 73be66e256..5e02c46ef8 100644
--- a/core/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/fxcodec/lbmp/fx_bmp.cpp
@@ -29,54 +29,54 @@ uint8_t HalfRoundUp(uint8_t value) {
} // namespace
BMPDecompressor::BMPDecompressor()
- : context_ptr(nullptr),
- next_in(nullptr),
- header_offset(0),
- width(0),
- height(0),
- compress_flag(0),
- components(0),
- src_row_bytes(0),
- out_row_bytes(0),
- bitCounts(0),
- color_used(0),
- imgTB_flag(false),
- pal_num(0),
- pal_type(0),
- data_size(0),
- img_data_offset(0),
- img_ifh_size(0),
- row_num(0),
- col_num(0),
- dpi_x(0),
- dpi_y(0),
- mask_red(0),
- mask_green(0),
- mask_blue(0),
- avail_in(0),
- skip_size(0),
- decode_status(BMP_D_STATUS_HEADER) {}
+ : context_ptr_(nullptr),
+ next_in_(nullptr),
+ header_offset_(0),
+ width_(0),
+ height_(0),
+ compress_flag_(0),
+ components_(0),
+ src_row_bytes_(0),
+ out_row_bytes_(0),
+ bit_counts_(0),
+ color_used_(0),
+ imgTB_flag_(false),
+ pal_num_(0),
+ pal_type_(0),
+ data_size_(0),
+ img_data_offset_(0),
+ img_ifh_size_(0),
+ row_num_(0),
+ col_num_(0),
+ dpi_x_(0),
+ dpi_y_(0),
+ mask_red_(0),
+ mask_green_(0),
+ mask_blue_(0),
+ avail_in_(0),
+ skip_size_(0),
+ decode_status_(BMP_D_STATUS_HEADER) {}
BMPDecompressor::~BMPDecompressor() {}
void BMPDecompressor::Error() {
- longjmp(jmpbuf, 1);
+ longjmp(jmpbuf_, 1);
}
-void BMPDecompressor::ReadScanline(uint32_t row_num,
+void BMPDecompressor::ReadScanline(uint32_t row_num_,
const std::vector<uint8_t>& row_buf) {
- auto* p = reinterpret_cast<CBmpContext*>(context_ptr);
- p->m_pDelegate->BmpReadScanline(row_num, row_buf);
+ auto* p = reinterpret_cast<CBmpContext*>(context_ptr_);
+ p->m_pDelegate->BmpReadScanline(row_num_, row_buf);
}
bool BMPDecompressor::GetDataPosition(uint32_t rcd_pos) {
- auto* p = reinterpret_cast<CBmpContext*>(context_ptr);
+ auto* p = reinterpret_cast<CBmpContext*>(context_ptr_);
return p->m_pDelegate->BmpInputImagePositionBuf(rcd_pos);
}
int32_t BMPDecompressor::ReadHeader() {
- uint32_t skip_size_org = skip_size;
- if (decode_status == BMP_D_STATUS_HEADER) {
+ uint32_t skip_size_org = skip_size_;
+ if (decode_status_ == BMP_D_STATUS_HEADER) {
BmpFileHeader* pBmp_header = nullptr;
if (!ReadData(reinterpret_cast<uint8_t**>(&pBmp_header),
sizeof(BmpFileHeader))) {
@@ -87,109 +87,109 @@ int32_t BMPDecompressor::ReadHeader() {
FXWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&pBmp_header->bfType));
pBmp_header->bfOffBits = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_header->bfOffBits));
- data_size =
+ data_size_ =
FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&pBmp_header->bfSize));
if (pBmp_header->bfType != BMP_SIGNATURE) {
Error();
NOTREACHED();
}
- if (avail_in < sizeof(uint32_t)) {
- skip_size = skip_size_org;
+ if (avail_in_ < sizeof(uint32_t)) {
+ skip_size_ = skip_size_org;
return 2;
}
- img_ifh_size =
- FXDWORD_GET_LSBFIRST(static_cast<uint8_t*>(next_in + skip_size));
- pal_type = 0;
+ img_ifh_size_ =
+ FXDWORD_GET_LSBFIRST(static_cast<uint8_t*>(next_in_ + skip_size_));
+ pal_type_ = 0;
static_assert(sizeof(BmpCoreHeader) == kBmpCoreHeaderSize,
"BmpCoreHeader has wrong size");
static_assert(sizeof(BmpInfoHeader) == kBmpInfoHeaderSize,
"BmpInfoHeader has wrong size");
- switch (img_ifh_size) {
+ switch (img_ifh_size_) {
case kBmpCoreHeaderSize: {
- pal_type = 1;
+ pal_type_ = 1;
BmpCoreHeader* pBmp_core_header = nullptr;
if (!ReadData(reinterpret_cast<uint8_t**>(&pBmp_core_header),
- img_ifh_size)) {
- skip_size = skip_size_org;
+ img_ifh_size_)) {
+ skip_size_ = skip_size_org;
return 2;
}
- width = FXWORD_GET_LSBFIRST(
+ width_ = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_core_header->bcWidth));
- height = FXWORD_GET_LSBFIRST(
+ height_ = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_core_header->bcHeight));
- bitCounts = FXWORD_GET_LSBFIRST(
+ bit_counts_ = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_core_header->bcBitCount));
- compress_flag = BMP_RGB;
- imgTB_flag = false;
+ compress_flag_ = BMP_RGB;
+ imgTB_flag_ = false;
} break;
case kBmpInfoHeaderSize: {
BmpInfoHeader* pBmp_info_header = nullptr;
if (!ReadData(reinterpret_cast<uint8_t**>(&pBmp_info_header),
- img_ifh_size)) {
- skip_size = skip_size_org;
+ img_ifh_size_)) {
+ skip_size_ = skip_size_org;
return 2;
}
- width = FXDWORD_GET_LSBFIRST(
+ width_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biWidth));
int32_t signed_height = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biHeight));
- bitCounts = FXWORD_GET_LSBFIRST(
+ bit_counts_ = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biBitCount));
- compress_flag = FXDWORD_GET_LSBFIRST(
+ compress_flag_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biCompression));
- color_used = FXDWORD_GET_LSBFIRST(
+ color_used_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biClrUsed));
- dpi_x = static_cast<int32_t>(FXDWORD_GET_LSBFIRST(
+ dpi_x_ = static_cast<int32_t>(FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biXPelsPerMeter)));
- dpi_y = static_cast<int32_t>(FXDWORD_GET_LSBFIRST(
+ dpi_y_ = static_cast<int32_t>(FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biYPelsPerMeter)));
SetHeight(signed_height);
} break;
default: {
- if (img_ifh_size >
+ if (img_ifh_size_ >
std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) {
BmpInfoHeader* pBmp_info_header = nullptr;
if (!ReadData(reinterpret_cast<uint8_t**>(&pBmp_info_header),
- img_ifh_size)) {
- skip_size = skip_size_org;
+ img_ifh_size_)) {
+ skip_size_ = skip_size_org;
return 2;
}
uint16_t biPlanes;
- width = FXDWORD_GET_LSBFIRST(
+ width_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biWidth));
int32_t signed_height = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biHeight));
- bitCounts = FXWORD_GET_LSBFIRST(
+ bit_counts_ = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biBitCount));
- compress_flag = FXDWORD_GET_LSBFIRST(
+ compress_flag_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biCompression));
- color_used = FXDWORD_GET_LSBFIRST(
+ color_used_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biClrUsed));
biPlanes = FXWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biPlanes));
- dpi_x = FXDWORD_GET_LSBFIRST(
+ dpi_x_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biXPelsPerMeter));
- dpi_y = FXDWORD_GET_LSBFIRST(
+ dpi_y_ = FXDWORD_GET_LSBFIRST(
reinterpret_cast<uint8_t*>(&pBmp_info_header->biYPelsPerMeter));
SetHeight(signed_height);
- if (compress_flag == BMP_RGB && biPlanes == 1 && color_used == 0)
+ if (compress_flag_ == BMP_RGB && biPlanes == 1 && color_used_ == 0)
break;
}
Error();
NOTREACHED();
}
}
- if (width > BMP_MAX_WIDTH || compress_flag > BMP_BITFIELDS) {
+ if (width_ > BMP_MAX_WIDTH || compress_flag_ > BMP_BITFIELDS) {
Error();
NOTREACHED();
}
- switch (bitCounts) {
+ switch (bit_counts_) {
case 1:
case 4:
case 8:
case 16:
case 24: {
- if (color_used > 1U << bitCounts) {
+ if (color_used_ > 1U << bit_counts_) {
Error();
NOTREACHED();
}
@@ -200,99 +200,99 @@ int32_t BMPDecompressor::ReadHeader() {
Error();
NOTREACHED();
}
- src_row_bytes = BMP_WIDTHBYTES(width, bitCounts);
- switch (bitCounts) {
+ src_row_bytes_ = BMP_WIDTHBYTES(width_, bit_counts_);
+ switch (bit_counts_) {
case 1:
case 4:
case 8:
- out_row_bytes = BMP_WIDTHBYTES(width, 8);
- components = 1;
+ out_row_bytes_ = BMP_WIDTHBYTES(width_, 8);
+ components_ = 1;
break;
case 16:
case 24:
- out_row_bytes = BMP_WIDTHBYTES(width, 24);
- components = 3;
+ out_row_bytes_ = BMP_WIDTHBYTES(width_, 24);
+ components_ = 3;
break;
case 32:
- out_row_bytes = src_row_bytes;
- components = 4;
+ out_row_bytes_ = src_row_bytes_;
+ components_ = 4;
break;
}
- out_row_buffer.clear();
+ out_row_buffer_.clear();
- if (out_row_bytes <= 0) {
+ if (out_row_bytes_ <= 0) {
Error();
NOTREACHED();
}
- out_row_buffer.resize(out_row_bytes);
+ out_row_buffer_.resize(out_row_bytes_);
SaveDecodingStatus(BMP_D_STATUS_PAL);
}
- if (decode_status == BMP_D_STATUS_PAL) {
- skip_size_org = skip_size;
- if (compress_flag == BMP_BITFIELDS) {
- if (bitCounts != 16 && bitCounts != 32) {
+ if (decode_status_ == BMP_D_STATUS_PAL) {
+ skip_size_org = skip_size_;
+ if (compress_flag_ == BMP_BITFIELDS) {
+ if (bit_counts_ != 16 && bit_counts_ != 32) {
Error();
NOTREACHED();
}
uint32_t* mask;
if (ReadData(reinterpret_cast<uint8_t**>(&mask), 3 * sizeof(uint32_t)) ==
nullptr) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
- mask_red = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[0]));
- mask_green = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[1]));
- mask_blue = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[2]));
- if (mask_red & mask_green || mask_red & mask_blue ||
- mask_green & mask_blue) {
+ mask_red_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[0]));
+ mask_green_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[1]));
+ mask_blue_ = FXDWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(&mask[2]));
+ if (mask_red_ & mask_green_ || mask_red_ & mask_blue_ ||
+ mask_green_ & mask_blue_) {
Error();
NOTREACHED();
}
- header_offset = std::max(header_offset, 26 + img_ifh_size);
+ header_offset_ = std::max(header_offset_, 26 + img_ifh_size_);
SaveDecodingStatus(BMP_D_STATUS_DATA_PRE);
return 1;
- } else if (bitCounts == 16) {
- mask_red = 0x7C00;
- mask_green = 0x03E0;
- mask_blue = 0x001F;
+ } else if (bit_counts_ == 16) {
+ mask_red_ = 0x7C00;
+ mask_green_ = 0x03E0;
+ mask_blue_ = 0x001F;
}
- pal_num = 0;
- if (bitCounts < 16) {
- pal_num = 1 << bitCounts;
- if (color_used != 0)
- pal_num = color_used;
+ pal_num_ = 0;
+ if (bit_counts_ < 16) {
+ pal_num_ = 1 << bit_counts_;
+ if (color_used_ != 0)
+ pal_num_ = color_used_;
uint8_t* src_pal_ptr = nullptr;
- uint32_t src_pal_size = pal_num * (pal_type ? 3 : 4);
+ uint32_t src_pal_size = pal_num_ * (pal_type_ ? 3 : 4);
if (ReadData(&src_pal_ptr, src_pal_size) == nullptr) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
- palette.resize(pal_num);
+ palette_.resize(pal_num_);
int32_t src_pal_index = 0;
- if (pal_type == BMP_PAL_OLD) {
- while (src_pal_index < pal_num) {
- palette[src_pal_index++] = BMP_PAL_ENCODE(
+ if (pal_type_ == BMP_PAL_OLD) {
+ while (src_pal_index < pal_num_) {
+ palette_[src_pal_index++] = BMP_PAL_ENCODE(
0x00, src_pal_ptr[2], src_pal_ptr[1], src_pal_ptr[0]);
src_pal_ptr += 3;
}
} else {
- while (src_pal_index < pal_num) {
- palette[src_pal_index++] = BMP_PAL_ENCODE(
+ while (src_pal_index < pal_num_) {
+ palette_[src_pal_index++] = BMP_PAL_ENCODE(
src_pal_ptr[3], src_pal_ptr[2], src_pal_ptr[1], src_pal_ptr[0]);
src_pal_ptr += 4;
}
}
}
- header_offset = std::max(header_offset,
- 14 + img_ifh_size + pal_num * (pal_type ? 3 : 4));
+ header_offset_ = std::max(
+ header_offset_, 14 + img_ifh_size_ + pal_num_ * (pal_type_ ? 3 : 4));
SaveDecodingStatus(BMP_D_STATUS_DATA_PRE);
}
return 1;
}
bool BMPDecompressor::ValidateFlag() const {
- switch (compress_flag) {
+ switch (compress_flag_) {
case BMP_RGB:
case BMP_BITFIELDS:
case BMP_RLE8:
@@ -304,21 +304,21 @@ bool BMPDecompressor::ValidateFlag() const {
}
int32_t BMPDecompressor::DecodeImage() {
- if (decode_status == BMP_D_STATUS_DATA_PRE) {
- avail_in = 0;
- if (!GetDataPosition(header_offset)) {
- decode_status = BMP_D_STATUS_TAIL;
+ if (decode_status_ == BMP_D_STATUS_DATA_PRE) {
+ avail_in_ = 0;
+ if (!GetDataPosition(header_offset_)) {
+ decode_status_ = BMP_D_STATUS_TAIL;
Error();
NOTREACHED();
}
- row_num = 0;
+ row_num_ = 0;
SaveDecodingStatus(BMP_D_STATUS_DATA);
}
- if (decode_status != BMP_D_STATUS_DATA || !ValidateFlag()) {
+ if (decode_status_ != BMP_D_STATUS_DATA || !ValidateFlag()) {
Error();
NOTREACHED();
}
- switch (compress_flag) {
+ switch (compress_flag_) {
case BMP_RGB:
case BMP_BITFIELDS:
return DecodeRGB();
@@ -332,7 +332,7 @@ int32_t BMPDecompressor::DecodeImage() {
}
bool BMPDecompressor::ValidateColorIndex(uint8_t val) {
- if (val >= pal_num) {
+ if (val >= pal_num_) {
Error();
NOTREACHED();
}
@@ -341,23 +341,23 @@ bool BMPDecompressor::ValidateColorIndex(uint8_t val) {
int32_t BMPDecompressor::DecodeRGB() {
uint8_t* des_buf = nullptr;
- while (row_num < height) {
+ while (row_num_ < height_) {
size_t idx = 0;
- if (!ReadData(&des_buf, src_row_bytes))
+ if (!ReadData(&des_buf, src_row_bytes_))
return 2;
SaveDecodingStatus(BMP_D_STATUS_DATA);
- switch (bitCounts) {
+ switch (bit_counts_) {
case 1: {
- for (uint32_t col = 0; col < width; ++col)
- out_row_buffer[idx++] =
+ for (uint32_t col = 0; col < width_; ++col)
+ out_row_buffer_[idx++] =
des_buf[col >> 3] & (0x80 >> (col % 8)) ? 0x01 : 0x00;
} break;
case 4: {
- for (uint32_t col = 0; col < width; ++col) {
- out_row_buffer[idx++] = (col & 0x01)
- ? (des_buf[col >> 1] & 0x0F)
- : ((des_buf[col >> 1] & 0xF0) >> 4);
+ for (uint32_t col = 0; col < width_; ++col) {
+ out_row_buffer_[idx++] = (col & 0x01)
+ ? (des_buf[col >> 1] & 0x0F)
+ : ((des_buf[col >> 1] & 0xF0) >> 4);
}
} break;
case 16: {
@@ -366,11 +366,11 @@ int32_t BMPDecompressor::DecodeRGB() {
uint8_t green_bits = 0;
uint8_t red_bits = 0;
for (int32_t i = 0; i < 16; i++) {
- if ((mask_blue >> i) & 0x01)
+ if ((mask_blue_ >> i) & 0x01)
blue_bits++;
- if ((mask_green >> i) & 0x01)
+ if ((mask_green_ >> i) & 0x01)
green_bits++;
- if ((mask_red >> i) & 0x01)
+ if ((mask_red_ >> i) & 0x01)
red_bits++;
}
green_bits += blue_bits;
@@ -380,29 +380,29 @@ int32_t BMPDecompressor::DecodeRGB() {
blue_bits = 8 - blue_bits;
green_bits -= 8;
red_bits -= 8;
- for (uint32_t col = 0; col < width; ++col) {
+ for (uint32_t col = 0; col < width_; ++col) {
*buf = FXWORD_GET_LSBFIRST(reinterpret_cast<uint8_t*>(buf));
- out_row_buffer[idx++] =
- static_cast<uint8_t>((*buf & mask_blue) << blue_bits);
- out_row_buffer[idx++] =
- static_cast<uint8_t>((*buf & mask_green) >> green_bits);
- out_row_buffer[idx++] =
- static_cast<uint8_t>((*buf++ & mask_red) >> red_bits);
+ out_row_buffer_[idx++] =
+ static_cast<uint8_t>((*buf & mask_blue_) << blue_bits);
+ out_row_buffer_[idx++] =
+ static_cast<uint8_t>((*buf & mask_green_) >> green_bits);
+ out_row_buffer_[idx++] =
+ static_cast<uint8_t>((*buf++ & mask_red_) >> red_bits);
}
} break;
case 8:
case 24:
case 32:
- std::copy(des_buf, des_buf + src_row_bytes, out_row_buffer.begin());
- idx += src_row_bytes;
+ std::copy(des_buf, des_buf + src_row_bytes_, out_row_buffer_.begin());
+ idx += src_row_bytes_;
break;
}
- for (uint8_t byte : out_row_buffer) {
+ for (uint8_t byte : out_row_buffer_) {
if (!ValidateColorIndex(byte))
return 0;
}
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
+ ReadScanline(imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
}
SaveDecodingStatus(BMP_D_STATUS_TAIL);
return 1;
@@ -411,36 +411,37 @@ int32_t BMPDecompressor::DecodeRGB() {
int32_t BMPDecompressor::DecodeRLE8() {
uint8_t* first_byte_ptr = nullptr;
uint8_t* second_byte_ptr = nullptr;
- col_num = 0;
+ col_num_ = 0;
while (true) {
- uint32_t skip_size_org = skip_size;
+ uint32_t skip_size_org = skip_size_;
if (!ReadData(&first_byte_ptr, 1))
return 2;
switch (*first_byte_ptr) {
case RLE_MARKER: {
if (!ReadData(&first_byte_ptr, 1)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
switch (*first_byte_ptr) {
case RLE_EOL: {
- if (row_num >= height) {
+ if (row_num_ >= height_) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
Error();
NOTREACHED();
}
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
- col_num = 0;
- std::fill(out_row_buffer.begin(), out_row_buffer.end(), 0);
+ ReadScanline(imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
+ col_num_ = 0;
+ std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
SaveDecodingStatus(BMP_D_STATUS_DATA);
continue;
}
case RLE_EOI: {
- if (row_num < height) {
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
+ if (row_num_ < height_) {
+ ReadScanline(
+ imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
}
SaveDecodingStatus(BMP_D_STATUS_TAIL);
return 1;
@@ -448,23 +449,24 @@ int32_t BMPDecompressor::DecodeRLE8() {
case RLE_DELTA: {
uint8_t* delta_ptr;
if (!ReadData(&delta_ptr, 2)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
- col_num += delta_ptr[0];
- size_t bmp_row_num_next = row_num + delta_ptr[1];
- if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
+ col_num_ += delta_ptr[0];
+ size_t bmp_row_num__next = row_num_ + delta_ptr[1];
+ if (col_num_ >= out_row_bytes_ || bmp_row_num__next >= height_) {
Error();
NOTREACHED();
}
- while (row_num < bmp_row_num_next) {
- std::fill(out_row_buffer.begin(), out_row_buffer.end(), 0);
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
+ while (row_num_ < bmp_row_num__next) {
+ std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
+ ReadScanline(
+ imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
}
} break;
default: {
- int32_t avail_size = out_row_bytes - col_num;
+ int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size ||
static_cast<int32_t>(*first_byte_ptr) > avail_size) {
Error();
@@ -473,35 +475,35 @@ int32_t BMPDecompressor::DecodeRLE8() {
if (!ReadData(&second_byte_ptr, *first_byte_ptr & 1
? *first_byte_ptr + 1
: *first_byte_ptr)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
std::copy(second_byte_ptr, second_byte_ptr + *first_byte_ptr,
- out_row_buffer.begin() + col_num);
- for (size_t i = col_num; i < col_num + *first_byte_ptr; ++i) {
- if (!ValidateColorIndex(out_row_buffer[i]))
+ out_row_buffer_.begin() + col_num_);
+ for (size_t i = col_num_; i < col_num_ + *first_byte_ptr; ++i) {
+ if (!ValidateColorIndex(out_row_buffer_[i]))
return 0;
}
- col_num += *first_byte_ptr;
+ col_num_ += *first_byte_ptr;
}
}
} break;
default: {
- int32_t avail_size = out_row_bytes - col_num;
+ int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size || static_cast<int32_t>(*first_byte_ptr) > avail_size) {
Error();
NOTREACHED();
}
if (!ReadData(&second_byte_ptr, 1)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
- std::fill(out_row_buffer.begin() + col_num,
- out_row_buffer.begin() + col_num + *first_byte_ptr,
+ std::fill(out_row_buffer_.begin() + col_num_,
+ out_row_buffer_.begin() + col_num_ + *first_byte_ptr,
*second_byte_ptr);
- if (!ValidateColorIndex(out_row_buffer[col_num]))
+ if (!ValidateColorIndex(out_row_buffer_[col_num_]))
return 0;
- col_num += *first_byte_ptr;
+ col_num_ += *first_byte_ptr;
}
}
}
@@ -512,36 +514,37 @@ int32_t BMPDecompressor::DecodeRLE8() {
int32_t BMPDecompressor::DecodeRLE4() {
uint8_t* first_byte_ptr = nullptr;
uint8_t* second_byte_ptr = nullptr;
- col_num = 0;
+ col_num_ = 0;
while (true) {
- uint32_t skip_size_org = skip_size;
+ uint32_t skip_size_org = skip_size_;
if (!ReadData(&first_byte_ptr, 1))
return 2;
switch (*first_byte_ptr) {
case RLE_MARKER: {
if (!ReadData(&first_byte_ptr, 1)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
switch (*first_byte_ptr) {
case RLE_EOL: {
- if (row_num >= height) {
+ if (row_num_ >= height_) {
SaveDecodingStatus(BMP_D_STATUS_TAIL);
Error();
NOTREACHED();
}
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
- col_num = 0;
- std::fill(out_row_buffer.begin(), out_row_buffer.end(), 0);
+ ReadScanline(imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
+ col_num_ = 0;
+ std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
SaveDecodingStatus(BMP_D_STATUS_DATA);
continue;
}
case RLE_EOI: {
- if (row_num < height) {
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
+ if (row_num_ < height_) {
+ ReadScanline(
+ imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
}
SaveDecodingStatus(BMP_D_STATUS_TAIL);
return 1;
@@ -549,37 +552,38 @@ int32_t BMPDecompressor::DecodeRLE4() {
case RLE_DELTA: {
uint8_t* delta_ptr;
if (!ReadData(&delta_ptr, 2)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
- col_num += delta_ptr[0];
- size_t bmp_row_num_next = row_num + delta_ptr[1];
- if (col_num >= out_row_bytes || bmp_row_num_next >= height) {
+ col_num_ += delta_ptr[0];
+ size_t bmp_row_num__next = row_num_ + delta_ptr[1];
+ if (col_num_ >= out_row_bytes_ || bmp_row_num__next >= height_) {
Error();
NOTREACHED();
}
- while (row_num < bmp_row_num_next) {
- std::fill(out_row_buffer.begin(), out_row_buffer.end(), 0);
- ReadScanline(imgTB_flag ? row_num++ : (height - 1 - row_num++),
- out_row_buffer);
+ while (row_num_ < bmp_row_num__next) {
+ std::fill(out_row_buffer_.begin(), out_row_buffer_.end(), 0);
+ ReadScanline(
+ imgTB_flag_ ? row_num_++ : (height_ - 1 - row_num_++),
+ out_row_buffer_);
}
} break;
default: {
- int32_t avail_size = out_row_bytes - col_num;
+ int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size) {
Error();
NOTREACHED();
}
uint8_t size = HalfRoundUp(*first_byte_ptr);
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
- if (size + (col_num >> 1) > src_row_bytes) {
+ if (size + (col_num_ >> 1) > src_row_bytes_) {
Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
}
if (!ReadData(&second_byte_ptr, size & 1 ? size + 1 : size)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
for (uint8_t i = 0; i < *first_byte_ptr; i++) {
@@ -588,27 +592,27 @@ int32_t BMPDecompressor::DecodeRLE4() {
if (!ValidateColorIndex(color))
return 0;
- out_row_buffer[col_num++] = color;
+ out_row_buffer_[col_num_++] = color;
}
}
}
} break;
default: {
- int32_t avail_size = out_row_bytes - col_num;
+ int32_t avail_size = out_row_bytes_ - col_num_;
if (!avail_size) {
Error();
NOTREACHED();
}
if (static_cast<int32_t>(*first_byte_ptr) > avail_size) {
uint8_t size = HalfRoundUp(*first_byte_ptr);
- if (size + (col_num >> 1) > src_row_bytes) {
+ if (size + (col_num_ >> 1) > src_row_bytes_) {
Error();
NOTREACHED();
}
*first_byte_ptr = avail_size - 1;
}
if (!ReadData(&second_byte_ptr, 1)) {
- skip_size = skip_size_org;
+ skip_size_ = skip_size_org;
return 2;
}
for (uint8_t i = 0; i < *first_byte_ptr; i++) {
@@ -617,7 +621,7 @@ int32_t BMPDecompressor::DecodeRLE4() {
i & 0x01 ? (second_byte & 0x0F) : (second_byte & 0xF0) >> 4;
if (!ValidateColorIndex(second_byte))
return 0;
- out_row_buffer[col_num++] = second_byte;
+ out_row_buffer_[col_num_++] = second_byte;
}
}
}
@@ -626,46 +630,46 @@ int32_t BMPDecompressor::DecodeRLE4() {
NOTREACHED();
}
-uint8_t* BMPDecompressor::ReadData(uint8_t** des_buf, uint32_t data_size) {
- if (avail_in < skip_size + data_size)
+uint8_t* BMPDecompressor::ReadData(uint8_t** des_buf, uint32_t data_size_) {
+ if (avail_in_ < skip_size_ + data_size_)
return nullptr;
- *des_buf = next_in + skip_size;
- skip_size += data_size;
+ *des_buf = next_in_ + skip_size_;
+ skip_size_ += data_size_;
return *des_buf;
}
void BMPDecompressor::SaveDecodingStatus(int32_t status) {
- decode_status = status;
- next_in += skip_size;
- avail_in -= skip_size;
- skip_size = 0;
+ decode_status_ = status;
+ next_in_ += skip_size_;
+ avail_in_ -= skip_size_;
+ skip_size_ = 0;
}
void BMPDecompressor::SetInputBuffer(uint8_t* src_buf, uint32_t src_size) {
- next_in = src_buf;
- avail_in = src_size;
- skip_size = 0;
+ next_in_ = src_buf;
+ avail_in_ = src_size;
+ skip_size_ = 0;
}
uint32_t BMPDecompressor::GetAvailInput(uint8_t** avail_buf) {
if (avail_buf) {
*avail_buf = nullptr;
- if (avail_in > 0)
- *avail_buf = next_in;
+ if (avail_in_ > 0)
+ *avail_buf = next_in_;
}
- return avail_in;
+ return avail_in_;
}
void BMPDecompressor::SetHeight(int32_t signed_height) {
if (signed_height >= 0) {
- height = signed_height;
+ height_ = signed_height;
return;
}
if (signed_height == std::numeric_limits<int>::min()) {
Error();
NOTREACHED();
}
- height = -signed_height;
- imgTB_flag = true;
+ height_ = -signed_height;
+ imgTB_flag_ = true;
}
diff --git a/core/fxcodec/lbmp/fx_bmp.h b/core/fxcodec/lbmp/fx_bmp.h
index 9dfa849939..5f970c458e 100644
--- a/core/fxcodec/lbmp/fx_bmp.h
+++ b/core/fxcodec/lbmp/fx_bmp.h
@@ -75,40 +75,40 @@ class BMPDecompressor {
void SetInputBuffer(uint8_t* src_buf, uint32_t src_size);
uint32_t GetAvailInput(uint8_t** avail_buf);
- jmp_buf jmpbuf;
-
- void* context_ptr;
-
- std::vector<uint8_t> out_row_buffer;
- std::vector<uint32_t> palette;
- uint8_t* next_in;
-
- uint32_t header_offset;
- uint32_t width;
- uint32_t height;
- uint32_t compress_flag;
- int32_t components;
- size_t src_row_bytes;
- size_t out_row_bytes;
- uint16_t bitCounts;
- uint32_t color_used;
- bool imgTB_flag;
- int32_t pal_num;
- int32_t pal_type;
- uint32_t data_size;
- uint32_t img_data_offset;
- uint32_t img_ifh_size;
- size_t row_num;
- size_t col_num;
- int32_t dpi_x;
- int32_t dpi_y;
- uint32_t mask_red;
- uint32_t mask_green;
- uint32_t mask_blue;
-
- uint32_t avail_in;
- uint32_t skip_size;
- int32_t decode_status;
+ jmp_buf jmpbuf_;
+
+ void* context_ptr_;
+
+ std::vector<uint8_t> out_row_buffer_;
+ std::vector<uint32_t> palette_;
+ uint8_t* next_in_;
+
+ uint32_t header_offset_;
+ uint32_t width_;
+ uint32_t height_;
+ uint32_t compress_flag_;
+ int32_t components_;
+ size_t src_row_bytes_;
+ size_t out_row_bytes_;
+ uint16_t bit_counts_;
+ uint32_t color_used_;
+ bool imgTB_flag_;
+ int32_t pal_num_;
+ int32_t pal_type_;
+ uint32_t data_size_;
+ uint32_t img_data_offset_;
+ uint32_t img_ifh_size_;
+ size_t row_num_;
+ size_t col_num_;
+ int32_t dpi_x_;
+ int32_t dpi_y_;
+ uint32_t mask_red_;
+ uint32_t mask_green_;
+ uint32_t mask_blue_;
+
+ uint32_t avail_in_;
+ uint32_t skip_size_;
+ int32_t decode_status_;
private:
bool GetDataPosition(uint32_t cur_pos);