Simplify adjustment code in CJPX_Decoder::Decode().
In the adjust < 0 path, adjust > 0 cannot be true. In the adjust >= 0
path, adjust - 1 < 0 translates to adjust == 0.
Change-Id: I119a254d24d3e4a327a18540b5f49a2d94a9187f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82715
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/jpx/cjpx_decoder.cpp b/core/fxcodec/jpx/cjpx_decoder.cpp
index c9d1d1a..ba7a19f 100644
--- a/core/fxcodec/jpx/cjpx_decoder.cpp
+++ b/core/fxcodec/jpx/cjpx_decoder.cpp
@@ -546,11 +546,7 @@
uint8_t* pPixel = pScanline + col * m_Image->numcomps;
int src = comps.data[row * width + col];
src += comps.sgnd ? 1 << (comps.prec - 1) : 0;
- if (adjust > 0) {
- *pPixel = 0;
- } else {
- *pPixel = static_cast<uint8_t>(src << -adjust);
- }
+ *pPixel = static_cast<uint8_t>(src << -adjust);
}
}
} else {
@@ -560,8 +556,8 @@
uint8_t* pPixel = pScanline + col * m_Image->numcomps;
int src = comps.data[row * width + col];
src += comps.sgnd ? 1 << (comps.prec - 1) : 0;
- if (adjust - 1 < 0) {
- *pPixel = static_cast<uint8_t>((src >> adjust));
+ if (adjust == 0) {
+ *pPixel = static_cast<uint8_t>(src);
} else {
int pixel = (src >> adjust) + ((src >> (adjust - 1)) % 2);
pixel = pdfium::clamp(pixel, 0, 255);