summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-03-21 17:40:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-03-21 17:40:55 +0000
commitcb009c8652e4f3654d666a64d962d48d4ddc2f65 (patch)
treed5954c1d6a06e94d0708aa06b5a2486226b0e2e7
parent3851aff62c7ad2f9c942b4d5d095ec0e6610bb84 (diff)
downloadpdfium-cb009c8652e4f3654d666a64d962d48d4ddc2f65.tar.xz
Rename "des_foo" to "dest_foo".
Destination variables usually have "dest" or "dst" as the prefix. Change-Id: If5bb01a5eafe1e4b42d1a6d653abb1b444b1b2fa Reviewed-on: https://pdfium-review.googlesource.com/28970 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fxcodec/bmp/cfx_bmpdecompressor.cpp16
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h12
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp793
-rw-r--r--core/fxcodec/gif/cfx_gifcontext.cpp8
-rw-r--r--core/fxcodec/gif/cfx_gifcontext.h2
-rw-r--r--core/fxcodec/gif/cfx_lzwdecompressor.cpp33
-rw-r--r--core/fxcodec/gif/cfx_lzwdecompressor.h10
-rw-r--r--core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp36
-rw-r--r--testing/libfuzzer/pdf_lzw_fuzzer.cc6
9 files changed, 482 insertions, 434 deletions
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
index ea6e2ba0bb..4494198b43 100644
--- a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
+++ b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp
@@ -357,10 +357,10 @@ bool CFX_BmpDecompressor::ValidateColorIndex(uint8_t val) {
}
int32_t CFX_BmpDecompressor::DecodeRGB() {
- std::vector<uint8_t> des_buf(src_row_bytes_);
+ std::vector<uint8_t> dest_buf(src_row_bytes_);
while (row_num_ < height_) {
size_t idx = 0;
- if (!ReadData(des_buf.data(), src_row_bytes_))
+ if (!ReadData(dest_buf.data(), src_row_bytes_))
return 2;
SaveDecodingStatus(BMP_D_STATUS_DATA);
@@ -368,17 +368,17 @@ int32_t CFX_BmpDecompressor::DecodeRGB() {
case 1: {
for (uint32_t col = 0; col < width_; ++col)
out_row_buffer_[idx++] =
- des_buf[col >> 3] & (0x80 >> (col % 8)) ? 0x01 : 0x00;
+ dest_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);
+ ? (dest_buf[col >> 1] & 0x0F)
+ : ((dest_buf[col >> 1] & 0xF0) >> 4);
}
} break;
case 16: {
- uint16_t* buf = reinterpret_cast<uint16_t*>(des_buf.data());
+ uint16_t* buf = reinterpret_cast<uint16_t*>(dest_buf.data());
uint8_t blue_bits = 0;
uint8_t green_bits = 0;
uint8_t red_bits = 0;
@@ -410,8 +410,8 @@ int32_t CFX_BmpDecompressor::DecodeRGB() {
case 8:
case 24:
case 32:
- uint8_t* des_buf_data = des_buf.data();
- std::copy(des_buf_data, des_buf_data + src_row_bytes_,
+ uint8_t* dest_buf_data = dest_buf.data();
+ std::copy(dest_buf_data, dest_buf_data + src_row_bytes_,
out_row_buffer_.begin());
idx += src_row_bytes_;
break;
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index 41e10e6dcf..18da3b3a63 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -158,7 +158,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
bool JpegReadMoreData(CCodec_JpegModule* pJpegModule,
FXCODEC_STATUS& err_status);
void PngOneOneMapResampleHorz(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
- int32_t des_line,
+ int32_t dest_line,
uint8_t* src_scan,
FXCodec_Format src_format);
bool DetectImageType(FXCODEC_IMAGE_TYPE imageType,
@@ -170,10 +170,10 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
bool TifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
void GetDownScale(int& down_scale);
- void GetTransMethod(FXDIB_Format des_format, FXCodec_Format src_format);
+ void GetTransMethod(FXDIB_Format dest_format, FXCodec_Format src_format);
void ReSampleScanline(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
- int32_t des_line,
+ int32_t dest_line,
uint8_t* src_scan,
FXCodec_Format src_format);
void Resample(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
@@ -182,13 +182,13 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
FXCodec_Format src_format);
void ResampleVert(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row);
+ int dest_row);
void ResampleVertBT(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row);
+ int dest_row);
void GifDoubleLineResampleVert(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row);
+ int dest_row);
FXCODEC_STATUS JpegStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap);
FXCODEC_STATUS PngStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap);
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 8807879e6e..f202ed83bf 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -147,43 +147,43 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len,
int size = dest_len * m_ItemSize + 4;
m_pWeightTables.resize(size, 0);
if (scale > 1) {
- int pre_des_col = 0;
+ int pre_dest_col = 0;
for (int src_col = 0; src_col < src_len; src_col++) {
- double des_col_f = src_col * scale;
- int des_col = FXSYS_round((float)des_col_f);
- PixelWeight* pWeight = GetPixelWeight(des_col);
+ double dest_col_f = src_col * scale;
+ int dest_col = FXSYS_round((float)dest_col_f);
+ PixelWeight* pWeight = GetPixelWeight(dest_col);
pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col;
pWeight->m_Weights[0] = 65536;
pWeight->m_Weights[1] = 0;
- if (src_col == src_len - 1 && des_col < dest_len - 1) {
- for (int des_col_index = pre_des_col + 1; des_col_index < dest_len;
- des_col_index++) {
- pWeight = GetPixelWeight(des_col_index);
+ if (src_col == src_len - 1 && dest_col < dest_len - 1) {
+ for (int dest_col_index = pre_dest_col + 1; dest_col_index < dest_len;
+ dest_col_index++) {
+ pWeight = GetPixelWeight(dest_col_index);
pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col;
pWeight->m_Weights[0] = 65536;
pWeight->m_Weights[1] = 0;
}
return;
}
- int des_col_len = des_col - pre_des_col;
- for (int des_col_index = pre_des_col + 1; des_col_index < des_col;
- des_col_index++) {
- pWeight = GetPixelWeight(des_col_index);
+ int dest_col_len = dest_col - pre_dest_col;
+ for (int dest_col_index = pre_dest_col + 1; dest_col_index < dest_col;
+ dest_col_index++) {
+ pWeight = GetPixelWeight(dest_col_index);
pWeight->m_SrcStart = src_col - 1;
pWeight->m_SrcEnd = src_col;
pWeight->m_Weights[0] =
- FXSYS_round((float)(((float)des_col - (float)des_col_index) /
- (float)des_col_len * 65536));
+ FXSYS_round((float)(((float)dest_col - (float)dest_col_index) /
+ (float)dest_col_len * 65536));
pWeight->m_Weights[1] = 65536 - pWeight->m_Weights[0];
}
- pre_des_col = des_col;
+ pre_dest_col = dest_col;
}
return;
}
- for (int des_col = 0; des_col < dest_len; des_col++) {
- double src_col_f = des_col / scale;
+ for (int dest_col = 0; dest_col < dest_len; dest_col++) {
+ double src_col_f = dest_col / scale;
int src_col = FXSYS_round((float)src_col_f);
- PixelWeight* pWeight = GetPixelWeight(des_col);
+ PixelWeight* pWeight = GetPixelWeight(dest_col);
pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col;
pWeight->m_Weights[0] = 65536;
pWeight->m_Weights[1] = 0;
@@ -201,10 +201,10 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
int size = dest_len * m_ItemSize + 4;
m_pWeightTables.resize(size, 0);
if (scale <= 1) {
- for (int des_row = 0; des_row < dest_len; des_row++) {
- PixelWeight* pWeight = GetPixelWeight(des_row);
- pWeight->m_SrcStart = des_row;
- pWeight->m_SrcEnd = des_row;
+ for (int dest_row = 0; dest_row < dest_len; dest_row++) {
+ PixelWeight* pWeight = GetPixelWeight(dest_row);
+ pWeight->m_SrcStart = dest_row;
+ pWeight->m_SrcEnd = dest_row;
pWeight->m_Weights[0] = 65536;
pWeight->m_Weights[1] = 0;
}
@@ -219,8 +219,8 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
int end_step = (int)step;
if (end_step >= dest_len) {
end_step = dest_len;
- for (int des_row = start_step; des_row < end_step; des_row++) {
- PixelWeight* pWeight = GetPixelWeight(des_row);
+ for (int dest_row = start_step; dest_row < end_step; dest_row++) {
+ PixelWeight* pWeight = GetPixelWeight(dest_row);
pWeight->m_SrcStart = start_step;
pWeight->m_SrcEnd = start_step;
pWeight->m_Weights[0] = 65536;
@@ -236,12 +236,12 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
pWeight->m_Weights[0] = 65536;
pWeight->m_Weights[1] = 0;
}
- for (int des_row = start_step + 1; des_row < end_step; des_row++) {
- PixelWeight* pWeight = GetPixelWeight(des_row);
+ for (int dest_row = start_step + 1; dest_row < end_step; dest_row++) {
+ PixelWeight* pWeight = GetPixelWeight(dest_row);
pWeight->m_SrcStart = start_step;
pWeight->m_SrcEnd = end_step;
pWeight->m_Weights[0] =
- FXSYS_round((float)(end_step - des_row) / (float)length * 65536);
+ FXSYS_round((float)(end_step - dest_row) / (float)length * 65536);
pWeight->m_Weights[1] = 65536 - pWeight->m_Weights[0];
}
}
@@ -395,14 +395,14 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t** pSrcBuf) {
double scale_y = (double)m_sizeY / (double)m_clipBox.Height();
int32_t row = (int32_t)((line - m_clipBox.top) * scale_y) + m_startY;
uint8_t* src_scan = (uint8_t*)pDIBitmap->GetScanline(row);
- uint8_t* des_scan = m_pDecodeBuf;
+ uint8_t* dest_scan = m_pDecodeBuf;
*pSrcBuf = m_pDecodeBuf;
int32_t src_Bpp = pDIBitmap->GetBPP() >> 3;
- int32_t des_Bpp = (m_SrcFormat & 0xff) >> 3;
+ int32_t dest_Bpp = (m_SrcFormat & 0xff) >> 3;
int32_t src_left = m_startX;
- int32_t des_left = m_clipBox.left;
+ int32_t dest_left = m_clipBox.left;
src_scan += src_left * src_Bpp;
- des_scan += des_left * des_Bpp;
+ dest_scan += dest_left * dest_Bpp;
for (int32_t src_col = 0; src_col < m_sizeX; src_col++) {
PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(src_col);
if (pPixelWeights->m_SrcStart != pPixelWeights->m_SrcEnd) {
@@ -418,32 +418,36 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t** pSrcBuf) {
if (pDIBitmap->GetPalette()) {
return false;
}
- uint32_t des_g = 0;
- des_g += pPixelWeights->m_Weights[0] * src_scan[src_col];
- des_scan[pPixelWeights->m_SrcStart] = (uint8_t)(des_g >> 16);
+ uint32_t dest_g = 0;
+ dest_g += pPixelWeights->m_Weights[0] * src_scan[src_col];
+ dest_scan[pPixelWeights->m_SrcStart] = (uint8_t)(dest_g >> 16);
} break;
case FXDIB_Rgb:
case FXDIB_Rgb32: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
const uint8_t* p = src_scan + src_col * src_Bpp;
- des_b += pPixelWeights->m_Weights[0] * (*p++);
- des_g += pPixelWeights->m_Weights[0] * (*p++);
- des_r += pPixelWeights->m_Weights[0] * (*p);
- uint8_t* pDes = &des_scan[pPixelWeights->m_SrcStart * des_Bpp];
- *pDes++ = (uint8_t)((des_b) >> 16);
- *pDes++ = (uint8_t)((des_g) >> 16);
- *pDes = (uint8_t)((des_r) >> 16);
+ dest_b += pPixelWeights->m_Weights[0] * (*p++);
+ dest_g += pPixelWeights->m_Weights[0] * (*p++);
+ dest_r += pPixelWeights->m_Weights[0] * (*p);
+ uint8_t* pDes = &dest_scan[pPixelWeights->m_SrcStart * dest_Bpp];
+ *pDes++ = (uint8_t)((dest_b) >> 16);
+ *pDes++ = (uint8_t)((dest_g) >> 16);
+ *pDes = (uint8_t)((dest_r) >> 16);
} break;
case FXDIB_Argb: {
- uint32_t des_r = 0, des_g = 0, des_b = 0;
+ uint32_t dest_r = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_b = 0;
const uint8_t* p = src_scan + src_col * src_Bpp;
- des_b += pPixelWeights->m_Weights[0] * (*p++);
- des_g += pPixelWeights->m_Weights[0] * (*p++);
- des_r += pPixelWeights->m_Weights[0] * (*p++);
- uint8_t* pDes = &des_scan[pPixelWeights->m_SrcStart * des_Bpp];
- *pDes++ = (uint8_t)((des_b) >> 16);
- *pDes++ = (uint8_t)((des_g) >> 16);
- *pDes++ = (uint8_t)((des_r) >> 16);
+ dest_b += pPixelWeights->m_Weights[0] * (*p++);
+ dest_g += pPixelWeights->m_Weights[0] * (*p++);
+ dest_r += pPixelWeights->m_Weights[0] * (*p++);
+ uint8_t* pDes = &dest_scan[pPixelWeights->m_SrcStart * dest_Bpp];
+ *pDes++ = (uint8_t)((dest_b) >> 16);
+ *pDes++ = (uint8_t)((dest_g) >> 16);
+ *pDes++ = (uint8_t)((dest_r) >> 16);
*pDes = *p;
} break;
default:
@@ -456,18 +460,18 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t** pSrcBuf) {
void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz(
const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
- int32_t des_line,
+ int32_t dest_line,
uint8_t* src_scan,
FXCodec_Format src_format) {
- uint8_t* des_scan = (uint8_t*)pDeviceBitmap->GetScanline(des_line);
+ uint8_t* dest_scan = (uint8_t*)pDeviceBitmap->GetScanline(dest_line);
int32_t src_Bpp = (m_SrcFormat & 0xff) >> 3;
- int32_t des_Bpp = pDeviceBitmap->GetBPP() >> 3;
+ int32_t dest_Bpp = pDeviceBitmap->GetBPP() >> 3;
int32_t src_left = m_clipBox.left;
- int32_t des_left = m_startX;
+ int32_t dest_left = m_startX;
src_scan += src_left * src_Bpp;
- des_scan += des_left * des_Bpp;
- for (int32_t des_col = 0; des_col < m_sizeX; des_col++) {
- PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(des_col);
+ dest_scan += dest_left * dest_Bpp;
+ for (int32_t dest_col = 0; dest_col < m_sizeX; dest_col++) {
+ PixelWeight* pPixelWeights = m_WeightHorzOO.GetPixelWeight(dest_col);
switch (pDeviceBitmap->GetFormat()) {
case FXDIB_1bppMask:
case FXDIB_1bppRgb:
@@ -478,47 +482,52 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz(
if (pDeviceBitmap->GetPalette()) {
return;
}
- uint32_t des_g = 0;
- des_g +=
+ uint32_t dest_g = 0;
+ dest_g +=
pPixelWeights->m_Weights[0] * src_scan[pPixelWeights->m_SrcStart];
- des_g +=
+ dest_g +=
pPixelWeights->m_Weights[1] * src_scan[pPixelWeights->m_SrcEnd];
- *des_scan++ = (uint8_t)(des_g >> 16);
+ *dest_scan++ = (uint8_t)(dest_g >> 16);
} break;
case FXDIB_Rgb:
case FXDIB_Rgb32: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
const uint8_t* p = src_scan;
p = src_scan + pPixelWeights->m_SrcStart * src_Bpp;
- des_b += pPixelWeights->m_Weights[0] * (*p++);
- des_g += pPixelWeights->m_Weights[0] * (*p++);
- des_r += pPixelWeights->m_Weights[0] * (*p);
+ dest_b += pPixelWeights->m_Weights[0] * (*p++);
+ dest_g += pPixelWeights->m_Weights[0] * (*p++);
+ dest_r += pPixelWeights->m_Weights[0] * (*p);
p = src_scan + pPixelWeights->m_SrcEnd * src_Bpp;
- des_b += pPixelWeights->m_Weights[1] * (*p++);
- des_g += pPixelWeights->m_Weights[1] * (*p++);
- des_r += pPixelWeights->m_Weights[1] * (*p);
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- des_scan += des_Bpp - 3;
+ dest_b += pPixelWeights->m_Weights[1] * (*p++);
+ dest_g += pPixelWeights->m_Weights[1] * (*p++);
+ dest_r += pPixelWeights->m_Weights[1] * (*p);
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ dest_scan += dest_Bpp - 3;
} break;
case FXDIB_Argb: {
- uint32_t des_a = 0, des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_a = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
const uint8_t* p = src_scan;
p = src_scan + pPixelWeights->m_SrcStart * src_Bpp;
- des_b += pPixelWeights->m_Weights[0] * (*p++);
- des_g += pPixelWeights->m_Weights[0] * (*p++);
- des_r += pPixelWeights->m_Weights[0] * (*p++);
- des_a += pPixelWeights->m_Weights[0] * (*p);
+ dest_b += pPixelWeights->m_Weights[0] * (*p++);
+ dest_g += pPixelWeights->m_Weights[0] * (*p++);
+ dest_r += pPixelWeights->m_Weights[0] * (*p++);
+ dest_a += pPixelWeights->m_Weights[0] * (*p);
p = src_scan + pPixelWeights->m_SrcEnd * src_Bpp;
- des_b += pPixelWeights->m_Weights[1] * (*p++);
- des_g += pPixelWeights->m_Weights[1] * (*p++);
- des_r += pPixelWeights->m_Weights[1] * (*p++);
- des_a += pPixelWeights->m_Weights[1] * (*p);
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- *des_scan++ = (uint8_t)((des_a) >> 16);
+ dest_b += pPixelWeights->m_Weights[1] * (*p++);
+ dest_g += pPixelWeights->m_Weights[1] * (*p++);
+ dest_r += pPixelWeights->m_Weights[1] * (*p++);
+ dest_a += pPixelWeights->m_Weights[1] * (*p);
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ *dest_scan++ = (uint8_t)((dest_a) >> 16);
} break;
default:
return;
@@ -532,23 +541,23 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass,
ASSERT(pDIBitmap);
int src_top = m_clipBox.top;
int src_bottom = m_clipBox.bottom;
- int des_top = m_startY;
+ int dest_top = m_startY;
int src_hei = m_clipBox.Height();
- int des_hei = m_sizeY;
+ int dest_hei = m_sizeY;
if (line >= src_top && line < src_bottom) {
- double scale_y = (double)des_hei / (double)src_hei;
+ double scale_y = (double)dest_hei / (double)src_hei;
int src_row = line - src_top;
- int des_row = (int)(src_row * scale_y) + des_top;
- if (des_row >= des_top + des_hei) {
+ int dest_row = (int)(src_row * scale_y) + dest_top;
+ if (dest_row >= dest_top + dest_hei) {
return;
}
- PngOneOneMapResampleHorz(pDIBitmap, des_row, m_pDecodeBuf, m_SrcFormat);
+ PngOneOneMapResampleHorz(pDIBitmap, dest_row, m_pDecodeBuf, m_SrcFormat);
if (m_SrcPassNumber == 1 && scale_y > 1.0) {
- ResampleVert(pDIBitmap, scale_y, des_row);
+ ResampleVert(pDIBitmap, scale_y, dest_row);
return;
}
if (pass == 6 && scale_y > 1.0) {
- ResampleVert(pDIBitmap, scale_y, des_row);
+ ResampleVert(pDIBitmap, scale_y, dest_row);
}
}
}
@@ -710,67 +719,68 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num,
memcpy(m_pDecodeBuf + left, row_buf, img_width);
int src_top = m_clipBox.top;
int src_bottom = m_clipBox.bottom;
- int des_top = m_startY;
+ int dest_top = m_startY;
int src_hei = m_clipBox.Height();
- int des_hei = m_sizeY;
+ int dest_hei = m_sizeY;
if (line < src_top || line >= src_bottom)
return;
- double scale_y = (double)des_hei / (double)src_hei;
+ double scale_y = (double)dest_hei / (double)src_hei;
int src_row = line - src_top;
- int des_row = (int)(src_row * scale_y) + des_top;
- if (des_row >= des_top + des_hei)
+ int dest_row = (int)(src_row * scale_y) + dest_top;
+ if (dest_row >= dest_top + dest_hei)
return;
- ReSampleScanline(pDIBitmap, des_row, m_pDecodeBuf, m_SrcFormat);
+ ReSampleScanline(pDIBitmap, dest_row, m_pDecodeBuf, m_SrcFormat);
if (scale_y > 1.0 && m_SrcPassNumber == 1) {
- ResampleVert(pDIBitmap, scale_y, des_row);
+ ResampleVert(pDIBitmap, scale_y, dest_row);
return;
}
if (scale_y <= 1.0)
return;
- int des_bottom = des_top + m_sizeY;
- int des_Bpp = pDIBitmap->GetBPP() >> 3;
- uint32_t des_ScanOffet = m_startX * des_Bpp;
- if (des_row + (int)scale_y >= des_bottom - 1) {
+ int dest_bottom = dest_top + m_sizeY;
+ int dest_Bpp = pDIBitmap->GetBPP() >> 3;
+ uint32_t dest_ScanOffet = m_startX * dest_Bpp;
+ if (dest_row + (int)scale_y >= dest_bottom - 1) {
uint8_t* scan_src =
- (uint8_t*)pDIBitmap->GetScanline(des_row) + des_ScanOffet;
- int cur_row = des_row;
- while (++cur_row < des_bottom) {
+ (uint8_t*)pDIBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ int cur_row = dest_row;
+ while (++cur_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDIBitmap->GetScanline(cur_row) + des_ScanOffet;
- uint32_t size = m_sizeX * des_Bpp;
+ (uint8_t*)pDIBitmap->GetScanline(cur_row) + dest_ScanOffet;
+ uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
}
if (bLastPass)
- GifDoubleLineResampleVert(pDIBitmap, scale_y, des_row);
+ GifDoubleLineResampleVert(pDIBitmap, scale_y, dest_row);
}
void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row) {
- int des_Bpp = pDeviceBitmap->GetBPP() >> 3;
- uint32_t des_ScanOffet = m_startX * des_Bpp;
- int des_top = m_startY;
+ int dest_row) {
+ int dest_Bpp = pDeviceBitmap->GetBPP() >> 3;
+ uint32_t dest_ScanOffet = m_startX * dest_Bpp;
+ int dest_top = m_startY;
pdfium::base::CheckedNumeric<double> scale_y2 = scale_y;
scale_y2 *= 2;
- pdfium::base::CheckedNumeric<int> check_des_row_1 = des_row;
- check_des_row_1 -= scale_y2.ValueOrDie();
- int des_row_1 = check_des_row_1.ValueOrDie();
- des_row_1 = std::max(des_row_1, des_top);
- for (; des_row_1 < des_row; des_row_1++) {
+ pdfium::base::CheckedNumeric<int> check_dest_row_1 = dest_row;
+ check_dest_row_1 -= scale_y2.ValueOrDie();
+ int dest_row_1 = check_dest_row_1.ValueOrDie();
+ dest_row_1 = std::max(dest_row_1, dest_top);
+ for (; dest_row_1 < dest_row; dest_row_1++) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row_1) + des_ScanOffet;
- PixelWeight* pWeight = m_WeightVert.GetPixelWeight(des_row_1 - des_top);
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcStart + des_top) +
- des_ScanOffet;
+ pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
+ dest_ScanOffet;
const uint8_t* scan_src2 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet;
- for (int des_col = 0; des_col < m_sizeX; des_col++) {
+ pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + dest_top) +
+ dest_ScanOffet;
+ for (int dest_col = 0; dest_col < m_sizeX; dest_col++) {
switch (pDeviceBitmap->GetFormat()) {
case FXDIB_Invalid:
case FXDIB_1bppMask:
@@ -781,51 +791,56 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert(
if (pDeviceBitmap->GetPalette()) {
return;
}
- int des_g = 0;
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)(des_g >> 16);
+ int dest_g = 0;
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)(dest_g >> 16);
} break;
case FXDIB_Rgb:
case FXDIB_Rgb32: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- scan_src1 += des_Bpp - 3;
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- scan_src2 += des_Bpp - 3;
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- scan_des += des_Bpp - 3;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ scan_src1 += dest_Bpp - 3;
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ scan_src2 += dest_Bpp - 3;
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ scan_des += dest_Bpp - 3;
} break;
case FXDIB_Argb: {
- uint32_t des_a = 0, des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- des_a += pWeight->m_Weights[0] * (*scan_src1++);
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- des_a += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- *scan_des++ = (uint8_t)((des_a) >> 16);
+ uint32_t dest_a = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_a += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_a += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ *scan_des++ = (uint8_t)((dest_a) >> 16);
} break;
default:
return;
}
}
}
- int des_bottom = des_top + m_sizeY - 1;
- if (des_row + (int)(2 * scale_y) >= des_bottom &&
- des_row + (int)scale_y < des_bottom) {
- GifDoubleLineResampleVert(pDeviceBitmap, scale_y, des_row + (int)scale_y);
+ int dest_bottom = dest_top + m_sizeY - 1;
+ if (dest_row + (int)(2 * scale_y) >= dest_bottom &&
+ dest_row + (int)scale_y < dest_bottom) {
+ GifDoubleLineResampleVert(pDeviceBitmap, scale_y, dest_row + (int)scale_y);
}
}
@@ -885,63 +900,64 @@ void CCodec_ProgressiveDecoder::BmpReadScanline(
std::copy(row_buf.begin(), row_buf.begin() + m_ScanlineSize, m_pDecodeBuf);
int src_top = m_clipBox.top;
int src_bottom = m_clipBox.bottom;
- int des_top = m_startY;
+ int dest_top = m_startY;
int src_hei = m_clipBox.Height();
- int des_hei = m_sizeY;
+ int dest_hei = m_sizeY;
if ((src_top >= 0 && row_num < static_cast<uint32_t>(src_top)) ||
src_bottom < 0 || row_num >= static_cast<uint32_t>(src_bottom)) {
return;
}
- double scale_y = (double)des_hei / (double)src_hei;
+ double scale_y = (double)dest_hei / (double)src_hei;
int src_row = row_num - src_top;
- int des_row = (int)(src_row * scale_y) + des_top;
- if (des_row >= des_top + des_hei)
+ int dest_row = (int)(src_row * scale_y) + dest_top;
+ if (dest_row >= dest_top + dest_hei)
return;
- ReSampleScanline(pDIBitmap, des_row, m_pDecodeBuf, m_SrcFormat);
+ ReSampleScanline(pDIBitmap, dest_row, m_pDecodeBuf, m_SrcFormat);
if (scale_y <= 1.0)
return;
if (m_BmpIsTopBottom) {
- ResampleVert(pDIBitmap, scale_y, des_row);
+ ResampleVert(pDIBitmap, scale_y, dest_row);
return;
}
- ResampleVertBT(pDIBitmap, scale_y, des_row);
+ ResampleVertBT(pDIBitmap, scale_y, dest_row);
}
void CCodec_ProgressiveDecoder::ResampleVertBT(
const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row) {
- int des_Bpp = pDeviceBitmap->GetBPP() >> 3;
- uint32_t des_ScanOffet = m_startX * des_Bpp;
- int des_top = m_startY;
- int des_bottom = m_startY + m_sizeY;
- pdfium::base::CheckedNumeric<int> check_des_row_1 = des_row;
- check_des_row_1 += pdfium::base::checked_cast<int>(scale_y);
- int des_row_1 = check_des_row_1.ValueOrDie();
- if (des_row_1 >= des_bottom - 1) {
+ int dest_row) {
+ int dest_Bpp = pDeviceBitmap->GetBPP() >> 3;
+ uint32_t dest_ScanOffet = m_startX * dest_Bpp;
+ int dest_top = m_startY;
+ int dest_bottom = m_startY + m_sizeY;
+ pdfium::base::CheckedNumeric<int> check_dest_row_1 = dest_row;
+ check_dest_row_1 += pdfium::base::checked_cast<int>(scale_y);
+ int dest_row_1 = check_dest_row_1.ValueOrDie();
+ if (dest_row_1 >= dest_bottom - 1) {
uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- while (++des_row < des_bottom) {
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- uint32_t size = m_sizeX * des_Bpp;
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
return;
}
- for (; des_row_1 > des_row; des_row_1--) {
+ for (; dest_row_1 > dest_row; dest_row_1--) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row_1) + des_ScanOffet;
- PixelWeight* pWeight = m_WeightVert.GetPixelWeight(des_row_1 - des_top);
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcStart + des_top) +
- des_ScanOffet;
+ pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
+ dest_ScanOffet;
const uint8_t* scan_src2 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet;
- for (int des_col = 0; des_col < m_sizeX; des_col++) {
+ pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + dest_top) +
+ dest_ScanOffet;
+ for (int dest_col = 0; dest_col < m_sizeX; dest_col++) {
switch (pDeviceBitmap->GetFormat()) {
case FXDIB_Invalid:
case FXDIB_1bppMask:
@@ -952,41 +968,46 @@ void CCodec_ProgressiveDecoder::ResampleVertBT(
if (pDeviceBitmap->GetPalette()) {
return;
}
- int des_g = 0;
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)(des_g >> 16);
+ int dest_g = 0;
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)(dest_g >> 16);
} break;
case FXDIB_Rgb:
case FXDIB_Rgb32: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- scan_src1 += des_Bpp - 3;
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- scan_src2 += des_Bpp - 3;
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- scan_des += des_Bpp - 3;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ scan_src1 += dest_Bpp - 3;
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ scan_src2 += dest_Bpp - 3;
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ scan_des += dest_Bpp - 3;
} break;
case FXDIB_Argb: {
- uint32_t des_a = 0, des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- des_a += pWeight->m_Weights[0] * (*scan_src1++);
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- des_a += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- *scan_des++ = (uint8_t)((des_a) >> 16);
+ uint32_t dest_a = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_a += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_a += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ *scan_des++ = (uint8_t)((dest_a) >> 16);
} break;
default:
return;
@@ -1371,9 +1392,9 @@ void CCodec_ProgressiveDecoder::GetDownScale(int& down_scale) {
}
}
-void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format des_format,
+void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format dest_format,
FXCodec_Format src_format) {
- switch (des_format) {
+ switch (dest_format) {
case FXDIB_1bppMask:
case FXDIB_1bppRgb: {
switch (src_format) {
@@ -1444,7 +1465,7 @@ void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format des_format,
break;
case FXCodec_1bppRgb:
case FXCodec_8bppRgb:
- if (des_format == FXDIB_Argb) {
+ if (dest_format == FXDIB_Argb) {
m_TransMethod = 12;
} else {
m_TransMethod = 8;
@@ -1471,19 +1492,19 @@ void CCodec_ProgressiveDecoder::GetTransMethod(FXDIB_Format des_format,
void CCodec_ProgressiveDecoder::ReSampleScanline(
const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
- int des_line,
+ int dest_line,
uint8_t* src_scan,
FXCodec_Format src_format) {
int src_left = m_clipBox.left;
- int des_left = m_startX;
- uint8_t* des_scan =
- pDeviceBitmap->GetBuffer() + des_line * pDeviceBitmap->GetPitch();
+ int dest_left = m_startX;
+ uint8_t* dest_scan =
+ pDeviceBitmap->GetBuffer() + dest_line * pDeviceBitmap->GetPitch();
int src_bytes_per_pixel = (src_format & 0xff) / 8;
int dest_bytes_per_pixel = pDeviceBitmap->GetBPP() / 8;
src_scan += src_left * src_bytes_per_pixel;
- des_scan += des_left * dest_bytes_per_pixel;
- for (int des_col = 0; des_col < m_sizeX; des_col++) {
- PixelWeight* pPixelWeights = m_WeightHorz.GetPixelWeight(des_col);
+ dest_scan += dest_left * dest_bytes_per_pixel;
+ for (int dest_col = 0; dest_col < m_sizeX; dest_col++) {
+ PixelWeight* pPixelWeights = m_WeightHorz.GetPixelWeight(dest_col);
switch (m_TransMethod) {
case -1:
return;
@@ -1492,45 +1513,51 @@ void CCodec_ProgressiveDecoder::ReSampleScanline(
case 1:
return;
case 2: {
- uint32_t des_g = 0;
+ uint32_t dest_g = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
- des_g += pixel_weight * src_scan[j];
+ dest_g += pixel_weight * src_scan[j];
}
- *des_scan++ = (uint8_t)(des_g >> 16);
+ *dest_scan++ = (uint8_t)(dest_g >> 16);
} break;
case 3: {
- int des_r = 0, des_g = 0, des_b = 0;
+ int dest_r = 0;
+ int dest_g = 0;
+ int dest_b = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette[src_scan[j]];
- des_r += pixel_weight * (uint8_t)(argb >> 16);
- des_g += pixel_weight * (uint8_t)(argb >> 8);
- des_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * (uint8_t)(argb >> 16);
+ dest_g += pixel_weight * (uint8_t)(argb >> 8);
+ dest_b += pixel_weight * (uint8_t)argb;
}
- *des_scan++ =
- (uint8_t)FXRGB2GRAY((des_r >> 16), (des_g >> 16), (des_b >> 16));
+ *dest_scan++ =
+ (uint8_t)FXRGB2GRAY((dest_r >> 16), (dest_g >> 16), (dest_b >> 16));
} break;
case 4: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
const uint8_t* src_pixel = src_scan + j * src_bytes_per_pixel;
- des_b += pixel_weight * (*src_pixel++);
- des_g += pixel_weight * (*src_pixel++);
- des_r += pixel_weight * (*src_pixel);
+ dest_b += pixel_weight * (*src_pixel++);
+ dest_g += pixel_weight * (*src_pixel++);
+ dest_r += pixel_weight * (*src_pixel);
}
- *des_scan++ =
- (uint8_t)FXRGB2GRAY((des_r >> 16), (des_g >> 16), (des_b >> 16));
+ *dest_scan++ =
+ (uint8_t)FXRGB2GRAY((dest_r >> 16), (dest_g >> 16), (dest_b >> 16));
} break;
case 5: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
@@ -1542,94 +1569,105 @@ void CCodec_ProgressiveDecoder::ReSampleScanline(
std::tie(src_r, src_g, src_b) =
AdobeCMYK_to_sRGB1(255 - src_pixel[0], 255 - src_pixel[1],
255 - src_pixel[2], 255 - src_pixel[3]);
- des_b += pixel_weight * src_b;
- des_g += pixel_weight * src_g;
- des_r += pixel_weight * src_r;
+ dest_b += pixel_weight * src_b;
+ dest_g += pixel_weight * src_g;
+ dest_r += pixel_weight * src_r;
}
- *des_scan++ =
- (uint8_t)FXRGB2GRAY((des_r >> 16), (des_g >> 16), (des_b >> 16));
+ *dest_scan++ =
+ (uint8_t)FXRGB2GRAY((dest_r >> 16), (dest_g >> 16), (dest_b >> 16));
} break;
case 6:
return;
case 7: {
- uint32_t des_g = 0;
+ uint32_t dest_g = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
- des_g += pixel_weight * src_scan[j];
+ dest_g += pixel_weight * src_scan[j];
}
- memset(des_scan, (uint8_t)(des_g >> 16), 3);
- des_scan += dest_bytes_per_pixel;
+ memset(dest_scan, (uint8_t)(dest_g >> 16), 3);
+ dest_scan += dest_bytes_per_pixel;
} break;
case 8: {
- int des_r = 0, des_g = 0, des_b = 0;
+ int dest_r = 0;
+ int dest_g = 0;
+ int dest_b = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette[src_scan[j]];
- des_r += pixel_weight * (uint8_t)(argb >> 16);
- des_g += pixel_weight * (uint8_t)(argb >> 8);
- des_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * (uint8_t)(argb >> 16);
+ dest_g += pixel_weight * (uint8_t)(argb >> 8);
+ dest_b += pixel_weight * (uint8_t)argb;
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- des_scan += dest_bytes_per_pixel - 3;
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ dest_scan += dest_bytes_per_pixel - 3;
} break;
case 12: {
if (m_pBmpContext) {
- int des_r = 0, des_g = 0, des_b = 0;
+ int dest_r = 0;
+ int dest_g = 0;
+ int dest_b = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette[src_scan[j]];
- des_r += pixel_weight * (uint8_t)(argb >> 16);
- des_g += pixel_weight * (uint8_t)(argb >> 8);
- des_b += pixel_weight * (uint8_t)argb;
+ dest_r += pixel_weight * (uint8_t)(argb >> 16);
+ dest_g += pixel_weight * (uint8_t)(argb >> 8);
+ dest_b += pixel_weight * (uint8_t)argb;
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- *des_scan++ = 0xFF;
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ *dest_scan++ = 0xFF;
} else {
- int des_a = 0, des_r = 0, des_g = 0, des_b = 0;
+ int dest_a = 0;
+ int dest_r = 0;
+ int dest_g = 0;
+ int dest_b = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
unsigned long argb = m_pSrcPalette[src_scan[j]];
- des_a += pixel_weight * (uint8_t)(argb >> 24);
- des_r += pixel_weight * (uint8_t)(argb >> 16);
- des_g += pixel_weight * (uint8_t)(argb >> 8);
- des_b += pixel_weight * (uint8_t)argb;
+ dest_a += pixel_weight * (uint8_t)(argb >> 24);
+ dest_r += pixel_weight * (uint8_t)(argb >> 16);
+ dest_g += pixel_weight * (uint8_t)(argb >> 8);
+ dest_b += pixel_weight * (uint8_t)argb;
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- *des_scan++ = (uint8_t)((des_a) >> 16);
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ *dest_scan++ = (uint8_t)((dest_a) >> 16);
}
} break;
case 9: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
const uint8_t* src_pixel = src_scan + j * src_bytes_per_pixel;
- des_b += pixel_weight * (*src_pixel++);
- des_g += pixel_weight * (*src_pixel++);
- des_r += pixel_weight * (*src_pixel);
+ dest_b += pixel_weight * (*src_pixel++);
+ dest_g += pixel_weight * (*src_pixel++);
+ dest_r += pixel_weight * (*src_pixel);
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- des_scan += dest_bytes_per_pixel - 3;
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ dest_scan += dest_bytes_per_pixel - 3;
} break;
case 10: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
@@ -1641,32 +1679,35 @@ void CCodec_ProgressiveDecoder::ReSampleScanline(
std::tie(src_r, src_g, src_b) =
AdobeCMYK_to_sRGB1(255 - src_pixel[0], 255 - src_pixel[1],
255 - src_pixel[2], 255 - src_pixel[3]);
- des_b += pixel_weight * src_b;
- des_g += pixel_weight * src_g;
- des_r += pixel_weight * src_r;
+ dest_b += pixel_weight * src_b;
+ dest_g += pixel_weight * src_g;
+ dest_r += pixel_weight * src_r;
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- des_scan += dest_bytes_per_pixel - 3;
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ dest_scan += dest_bytes_per_pixel - 3;
} break;
case 11: {
- uint32_t des_alpha = 0, des_r = 0, des_g = 0, des_b = 0;
+ uint32_t dest_alpha = 0;
+ uint32_t dest_r = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_b = 0;
for (int j = pPixelWeights->m_SrcStart; j <= pPixelWeights->m_SrcEnd;
j++) {
int pixel_weight =
pPixelWeights->m_Weights[j - pPixelWeights->m_SrcStart];
const uint8_t* src_pixel = src_scan + j * src_bytes_per_pixel;
pixel_weight = pixel_weight * src_pixel[3] / 255;
- des_b += pixel_weight * (*src_pixel++);
- des_g += pixel_weight * (*src_pixel++);
- des_r += pixel_weight * (*src_pixel);
- des_alpha += pixel_weight;
+ dest_b += pixel_weight * (*src_pixel++);
+ dest_g += pixel_weight * (*src_pixel++);
+ dest_r += pixel_weight * (*src_pixel);
+ dest_alpha += pixel_weight;
}
- *des_scan++ = (uint8_t)((des_b) >> 16);
- *des_scan++ = (uint8_t)((des_g) >> 16);
- *des_scan++ = (uint8_t)((des_r) >> 16);
- *des_scan++ = (uint8_t)((des_alpha * 255) >> 16);
+ *dest_scan++ = (uint8_t)((dest_b) >> 16);
+ *dest_scan++ = (uint8_t)((dest_g) >> 16);
+ *dest_scan++ = (uint8_t)((dest_r) >> 16);
+ *dest_scan++ = (uint8_t)((dest_alpha * 255) >> 16);
} break;
default:
return;
@@ -1677,37 +1718,38 @@ void CCodec_ProgressiveDecoder::ReSampleScanline(
void CCodec_ProgressiveDecoder::ResampleVert(
const RetainPtr<CFX_DIBitmap>& pDeviceBitmap,
double scale_y,
- int des_row) {
- int des_Bpp = pDeviceBitmap->GetBPP() >> 3;
- uint32_t des_ScanOffet = m_startX * des_Bpp;
- int des_top = m_startY;
- pdfium::base::CheckedNumeric<int> check_des_row_1 = des_row;
- check_des_row_1 -= pdfium::base::checked_cast<int>(scale_y);
- int des_row_1 = check_des_row_1.ValueOrDie();
- if (des_row_1 < des_top) {
- int des_bottom = des_top + m_sizeY;
- if (des_row + (int)scale_y >= des_bottom - 1) {
+ int dest_row) {
+ int dest_Bpp = pDeviceBitmap->GetBPP() >> 3;
+ uint32_t dest_ScanOffet = m_startX * dest_Bpp;
+ int dest_top = m_startY;
+ pdfium::base::CheckedNumeric<int> check_dest_row_1 = dest_row;
+ check_dest_row_1 -= pdfium::base::checked_cast<int>(scale_y);
+ int dest_row_1 = check_dest_row_1.ValueOrDie();
+ if (dest_row_1 < dest_top) {
+ int dest_bottom = dest_top + m_sizeY;
+ if (dest_row + (int)scale_y >= dest_bottom - 1) {
uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- while (++des_row < des_bottom) {
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- uint32_t size = m_sizeX * des_Bpp;
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
}
return;
}
- for (; des_row_1 < des_row; des_row_1++) {
+ for (; dest_row_1 < dest_row; dest_row_1++) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row_1) + des_ScanOffet;
- PixelWeight* pWeight = m_WeightVert.GetPixelWeight(des_row_1 - des_top);
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row_1) + dest_ScanOffet;
+ PixelWeight* pWeight = m_WeightVert.GetPixelWeight(dest_row_1 - dest_top);
const uint8_t* scan_src1 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcStart + des_top) +
- des_ScanOffet;
+ pDeviceBitmap->GetScanline(pWeight->m_SrcStart + dest_top) +
+ dest_ScanOffet;
const uint8_t* scan_src2 =
- pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + des_top) + des_ScanOffet;
- for (int des_col = 0; des_col < m_sizeX; des_col++) {
+ pDeviceBitmap->GetScanline(pWeight->m_SrcEnd + dest_top) +
+ dest_ScanOffet;
+ for (int dest_col = 0; dest_col < m_sizeX; dest_col++) {
switch (pDeviceBitmap->GetFormat()) {
case FXDIB_Invalid:
case FXDIB_1bppMask:
@@ -1718,55 +1760,60 @@ void CCodec_ProgressiveDecoder::ResampleVert(
if (pDeviceBitmap->GetPalette()) {
return;
}
- int des_g = 0;
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)(des_g >> 16);
+ int dest_g = 0;
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)(dest_g >> 16);
} break;
case FXDIB_Rgb:
case FXDIB_Rgb32: {
- uint32_t des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- scan_src1 += des_Bpp - 3;
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- scan_src2 += des_Bpp - 3;
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- scan_des += des_Bpp - 3;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ scan_src1 += dest_Bpp - 3;
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ scan_src2 += dest_Bpp - 3;
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ scan_des += dest_Bpp - 3;
} break;
case FXDIB_Argb: {
- uint32_t des_a = 0, des_b = 0, des_g = 0, des_r = 0;
- des_b += pWeight->m_Weights[0] * (*scan_src1++);
- des_g += pWeight->m_Weights[0] * (*scan_src1++);
- des_r += pWeight->m_Weights[0] * (*scan_src1++);
- des_a += pWeight->m_Weights[0] * (*scan_src1++);
- des_b += pWeight->m_Weights[1] * (*scan_src2++);
- des_g += pWeight->m_Weights[1] * (*scan_src2++);
- des_r += pWeight->m_Weights[1] * (*scan_src2++);
- des_a += pWeight->m_Weights[1] * (*scan_src2++);
- *scan_des++ = (uint8_t)((des_b) >> 16);
- *scan_des++ = (uint8_t)((des_g) >> 16);
- *scan_des++ = (uint8_t)((des_r) >> 16);
- *scan_des++ = (uint8_t)((des_a) >> 16);
+ uint32_t dest_a = 0;
+ uint32_t dest_b = 0;
+ uint32_t dest_g = 0;
+ uint32_t dest_r = 0;
+ dest_b += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_g += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_r += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_a += pWeight->m_Weights[0] * (*scan_src1++);
+ dest_b += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_g += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_r += pWeight->m_Weights[1] * (*scan_src2++);
+ dest_a += pWeight->m_Weights[1] * (*scan_src2++);
+ *scan_des++ = (uint8_t)((dest_b) >> 16);
+ *scan_des++ = (uint8_t)((dest_g) >> 16);
+ *scan_des++ = (uint8_t)((dest_r) >> 16);
+ *scan_des++ = (uint8_t)((dest_a) >> 16);
} break;
default:
return;
}
}
}
- int des_bottom = des_top + m_sizeY;
- if (des_row + (int)scale_y >= des_bottom - 1) {
+ int dest_bottom = dest_top + m_sizeY;
+ if (dest_row + (int)scale_y >= dest_bottom - 1) {
uint8_t* scan_src =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- while (++des_row < des_bottom) {
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ while (++dest_row < dest_bottom) {
uint8_t* scan_des =
- (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet;
- uint32_t size = m_sizeX * des_Bpp;
+ (uint8_t*)pDeviceBitmap->GetScanline(dest_row) + dest_ScanOffet;
+ uint32_t size = m_sizeX * dest_Bpp;
memmove(scan_des, scan_src, size);
}
}
@@ -1778,19 +1825,19 @@ void CCodec_ProgressiveDecoder::Resample(
uint8_t* src_scan,
FXCodec_Format src_format) {
int src_top = m_clipBox.top;
- int des_top = m_startY;
+ int dest_top = m_startY;
int src_hei = m_clipBox.Height();
- int des_hei = m_sizeY;
+ int dest_hei = m_sizeY;
if (src_line >= src_top) {
- double scale_y = (double)des_hei / (double)src_hei;
+ double scale_y = (double)dest_hei / (double)src_hei;
int src_row = src_line - src_top;
- int des_row = (int)(src_row * scale_y) + des_top;
- if (des_row >= des_top + des_hei) {
+ int dest_row = (int)(src_row * scale_y) + dest_top;
+ if (dest_row >= dest_top + dest_hei) {
return;
}
- ReSampleScanline(pDeviceBitmap, des_row, m_pDecodeBuf, src_format);
+ ReSampleScanline(pDeviceBitmap, dest_row, m_pDecodeBuf, src_format);
if (scale_y > 1.0) {
- ResampleVert(pDeviceBitmap, scale_y, des_row);
+ ResampleVert(pDeviceBitmap, scale_y, dest_row);
}
}
}
@@ -2304,13 +2351,13 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
case FXDIB_8bppMask: {
for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) {
uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row);
- uint8_t* des_line = (uint8_t*)pFormatBitmap->GetScanline(row);
+ uint8_t* dest_line = (uint8_t*)pFormatBitmap->GetScanline(row);
for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) {
uint8_t _a = 255 - src_line[3];
uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255;
uint8_t g = (src_line[1] * src_line[3] + 0xFF * _a) / 255;
uint8_t r = (src_line[2] * src_line[3] + 0xFF * _a) / 255;
- *des_line++ = FXRGB2GRAY(r, g, b);
+ *dest_line++ = FXRGB2GRAY(r, g, b);
src_line += 4;
}
}
@@ -2320,16 +2367,16 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
int32_t desBpp = (m_pDeviceBitmap->GetFormat() == FXDIB_Rgb) ? 3 : 4;
for (int32_t row = 0; row < pClipBitmap->GetHeight(); row++) {
uint8_t* src_line = (uint8_t*)pClipBitmap->GetScanline(row);
- uint8_t* des_line = (uint8_t*)pFormatBitmap->GetScanline(row);
+ uint8_t* dest_line = (uint8_t*)pFormatBitmap->GetScanline(row);
for (int32_t col = 0; col < pClipBitmap->GetWidth(); col++) {
uint8_t _a = 255 - src_line[3];
uint8_t b = (src_line[0] * src_line[3] + 0xFF * _a) / 255;
uint8_t g = (src_line[1] * src_line[3] + 0xFF * _a) / 255;
uint8_t r = (src_line[2] * src_line[3] + 0xFF * _a) / 255;
- *des_line++ = b;
- *des_line++ = g;
- *des_line++ = r;
- des_line += desBpp - 3;
+ *dest_line++ = b;
+ *dest_line++ = g;
+ *dest_line++ = r;
+ dest_line += desBpp - 3;
src_line += 4;
}
}
diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp
index 6159e56c13..3e09489f64 100644
--- a/core/fxcodec/gif/cfx_gifcontext.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -348,21 +348,21 @@ uint32_t CFX_GifContext::GetAvailInput(uint8_t** avail_buf) const {
return avail_in_;
}
-uint8_t* CFX_GifContext::ReadData(uint8_t** des_buf_pp, uint32_t data_size) {
+uint8_t* CFX_GifContext::ReadData(uint8_t** dest_buf_pp, uint32_t data_size) {
if (!next_in_)
return nullptr;
if (avail_in_ <= skip_size_)
return nullptr;
- if (!des_buf_pp)
+ if (!dest_buf_pp)
return nullptr;
if (data_size == 0)
return nullptr;
if (avail_in_ - skip_size_ < data_size)
return nullptr;
- *des_buf_pp = next_in_ + skip_size_;
+ *dest_buf_pp = next_in_ + skip_size_;
skip_size_ += data_size;
- return *des_buf_pp;
+ return *dest_buf_pp;
}
CFX_GifDecodeStatus CFX_GifContext::ReadGifSignature() {
diff --git a/core/fxcodec/gif/cfx_gifcontext.h b/core/fxcodec/gif/cfx_gifcontext.h
index 3a367bd361..ba23522b79 100644
--- a/core/fxcodec/gif/cfx_gifcontext.h
+++ b/core/fxcodec/gif/cfx_gifcontext.h
@@ -66,7 +66,7 @@ class CFX_GifContext : public CCodec_GifModule::Context {
uint8_t img_pass_num_;
protected:
- uint8_t* ReadData(uint8_t** des_buf_pp, uint32_t data_size);
+ uint8_t* ReadData(uint8_t** dest_buf_pp, uint32_t data_size);
CFX_GifDecodeStatus ReadGifSignature();
CFX_GifDecodeStatus ReadLogicalScreenDescriptor();
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.cpp b/core/fxcodec/gif/cfx_lzwdecompressor.cpp
index 09df6e767b..d4fd43d321 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor.cpp
+++ b/core/fxcodec/gif/cfx_lzwdecompressor.cpp
@@ -44,12 +44,12 @@ CFX_LZWDecompressor::~CFX_LZWDecompressor() {}
CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf,
uint32_t src_size,
- uint8_t* des_buf,
- uint32_t* des_size) {
- if (!src_buf || src_size == 0 || !des_buf || !des_size)
+ uint8_t* dest_buf,
+ uint32_t* dest_size) {
+ if (!src_buf || src_size == 0 || !dest_buf || !dest_size)
return CFX_GifDecodeStatus::Error;
- if (*des_size == 0)
+ if (*dest_size == 0)
return CFX_GifDecodeStatus::InsufficientDestSize;
next_in_ = src_buf;
@@ -59,15 +59,15 @@ CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf,
uint32_t i = 0;
if (decompressed_next_ != 0) {
- uint32_t extracted_size = ExtractData(des_buf, *des_size);
+ uint32_t extracted_size = ExtractData(dest_buf, *dest_size);
if (decompressed_next_ != 0)
return CFX_GifDecodeStatus::InsufficientDestSize;
- des_buf += extracted_size;
+ dest_buf += extracted_size;
i += extracted_size;
}
- while (i <= *des_size && (avail_in_ > 0 || bits_left_ >= code_size_cur_)) {
+ while (i <= *dest_size && (avail_in_ > 0 || bits_left_ >= code_size_cur_)) {
if (code_size_cur_ > GIF_MAX_LZW_EXP)
return CFX_GifDecodeStatus::Error;
@@ -96,7 +96,7 @@ CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf,
continue;
}
if (code == code_end_) {
- *des_size = i;
+ *dest_size = i;
return CFX_GifDecodeStatus::Success;
}
@@ -122,11 +122,11 @@ CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf,
}
code_old_ = code;
- uint32_t extracted_size = ExtractData(des_buf, *des_size - i);
+ uint32_t extracted_size = ExtractData(dest_buf, *dest_size - i);
if (decompressed_next_ != 0)
return CFX_GifDecodeStatus::InsufficientDestSize;
- des_buf += extracted_size;
+ dest_buf += extracted_size;
i += extracted_size;
}
}
@@ -134,7 +134,7 @@ CFX_GifDecodeStatus CFX_LZWDecompressor::Decode(uint8_t* src_buf,
if (avail_in_ != 0)
return CFX_GifDecodeStatus::Error;
- *des_size = i;
+ *dest_size = i;
return CFX_GifDecodeStatus::Unfinished;
}
@@ -182,15 +182,16 @@ bool CFX_LZWDecompressor::DecodeString(uint16_t code) {
return true;
}
-uint32_t CFX_LZWDecompressor::ExtractData(uint8_t* des_buf, uint32_t des_size) {
- if (des_size == 0)
+uint32_t CFX_LZWDecompressor::ExtractData(uint8_t* dest_buf,
+ uint32_t dest_size) {
+ if (dest_size == 0)
return 0;
- uint32_t copy_size = des_size <= decompressed_next_
- ? des_size
+ uint32_t copy_size = dest_size <= decompressed_next_
+ ? dest_size
: static_cast<uint32_t>(decompressed_next_);
std::reverse_copy(decompressed_.data() + decompressed_next_ - copy_size,
- decompressed_.data() + decompressed_next_, des_buf);
+ decompressed_.data() + decompressed_next_, dest_buf);
decompressed_next_ -= copy_size;
return copy_size;
}
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor.h b/core/fxcodec/gif/cfx_lzwdecompressor.h
index 717c055973..e6e0634b10 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor.h
+++ b/core/fxcodec/gif/cfx_lzwdecompressor.h
@@ -26,12 +26,12 @@ class CFX_LZWDecompressor {
CFX_GifDecodeStatus Decode(uint8_t* src_buf,
uint32_t src_size,
- uint8_t* des_buf,
- uint32_t* des_size);
+ uint8_t* dest_buf,
+ uint32_t* dest_size);
// Used by unittests, should not be called in production code.
- uint32_t ExtractDataForTest(uint8_t* des_buf, uint32_t des_size) {
- return ExtractData(des_buf, des_size);
+ uint32_t ExtractDataForTest(uint8_t* dest_buf, uint32_t dest_size) {
+ return ExtractData(dest_buf, dest_size);
}
std::vector<uint8_t>* DecompressedForTest() { return &decompressed_; }
@@ -43,7 +43,7 @@ class CFX_LZWDecompressor {
void ClearTable();
void AddCode(uint16_t prefix_code, uint8_t append_char);
bool DecodeString(uint16_t code);
- uint32_t ExtractData(uint8_t* des_buf, uint32_t des_size);
+ uint32_t ExtractData(uint8_t* dest_buf, uint32_t dest_size);
uint8_t code_size_;
uint8_t code_size_cur_;
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
index 0d0906eb10..551bc1e23e 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
+++ b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
@@ -24,12 +24,12 @@ TEST(CFX_LZWDecompressor, ExtractData) {
std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest();
*decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
*(decompressor->DecompressedNextForTest()) = decompressed->size();
- uint8_t des_buf[20];
- memset(des_buf, static_cast<uint8_t>(-1), sizeof(des_buf));
+ uint8_t dest_buf[20];
+ memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf));
- EXPECT_EQ(0u, decompressor->ExtractDataForTest(des_buf, 0));
- for (size_t i = 0; i < FX_ArraySize(des_buf); ++i)
- EXPECT_EQ(static_cast<uint8_t>(-1), des_buf[i]);
+ EXPECT_EQ(0u, decompressor->ExtractDataForTest(dest_buf, 0));
+ for (size_t i = 0; i < FX_ArraySize(dest_buf); ++i)
+ EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
EXPECT_EQ(10u, *(decompressor->DecompressedNextForTest()));
for (size_t i = 0; i < *(decompressor->DecompressedNextForTest()); ++i)
@@ -41,15 +41,15 @@ TEST(CFX_LZWDecompressor, ExtractData) {
std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest();
*decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
*(decompressor->DecompressedNextForTest()) = decompressed->size();
- uint8_t des_buf[20];
- memset(des_buf, static_cast<uint8_t>(-1), sizeof(des_buf));
+ uint8_t dest_buf[20];
+ memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf));
- EXPECT_EQ(5u, decompressor->ExtractDataForTest(des_buf, 5));
+ EXPECT_EQ(5u, decompressor->ExtractDataForTest(dest_buf, 5));
size_t i = 0;
for (; i < 5; ++i)
- EXPECT_EQ(9 - i, des_buf[i]);
- for (; i < FX_ArraySize(des_buf); ++i)
- EXPECT_EQ(static_cast<uint8_t>(-1), des_buf[i]);
+ EXPECT_EQ(9 - i, dest_buf[i]);
+ for (; i < FX_ArraySize(dest_buf); ++i)
+ EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
EXPECT_EQ(5u, *(decompressor->DecompressedNextForTest()));
for (i = 0; i < *(decompressor->DecompressedNextForTest()); ++i)
@@ -61,16 +61,16 @@ TEST(CFX_LZWDecompressor, ExtractData) {
std::vector<uint8_t>* decompressed = decompressor->DecompressedForTest();
*decompressed = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
*(decompressor->DecompressedNextForTest()) = decompressed->size();
- uint8_t des_buf[20];
- memset(des_buf, static_cast<uint8_t>(-1), sizeof(des_buf));
+ uint8_t dest_buf[20];
+ memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf));
- EXPECT_EQ(10u,
- decompressor->ExtractDataForTest(des_buf, FX_ArraySize(des_buf)));
+ EXPECT_EQ(10u, decompressor->ExtractDataForTest(dest_buf,
+ FX_ArraySize(dest_buf)));
size_t i = 0;
for (; i < 10; ++i)
- EXPECT_EQ(9 - i, des_buf[i]);
- for (; i < FX_ArraySize(des_buf); ++i)
- EXPECT_EQ(static_cast<uint8_t>(-1), des_buf[i]);
+ EXPECT_EQ(9 - i, dest_buf[i]);
+ for (; i < FX_ArraySize(dest_buf); ++i)
+ EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
EXPECT_EQ(0u, *(decompressor->DecompressedNextForTest()));
}
diff --git a/testing/libfuzzer/pdf_lzw_fuzzer.cc b/testing/libfuzzer/pdf_lzw_fuzzer.cc
index 71c258969d..7e10d2a1ee 100644
--- a/testing/libfuzzer/pdf_lzw_fuzzer.cc
+++ b/testing/libfuzzer/pdf_lzw_fuzzer.cc
@@ -23,13 +23,13 @@ void LZWFuzz(const uint8_t* src_buf,
for (uint32_t compressions_ratio = kMinCompressionRatio;
compressions_ratio <= kMaxCompressionRatio; compressions_ratio++) {
- std::vector<uint8_t> des_buf(compressions_ratio * src_size);
+ std::vector<uint8_t> dest_buf(compressions_ratio * src_size);
// This cast should be safe since the caller is checking for overflow on
// the initial data.
- uint32_t des_size = static_cast<uint32_t>(des_buf.size());
+ uint32_t dest_size = static_cast<uint32_t>(dest_buf.size());
if (CFX_GifDecodeStatus::InsufficientDestSize !=
decompressor->Decode(const_cast<uint8_t*>(src_buf), src_size,
- des_buf.data(), &des_size))
+ dest_buf.data(), &dest_size))
return;
}
}