Do check once, instead of one per pixel in CJPX_Decoder::Decode().
Pull a check out of the inner for-loop inside CJPX_Decoder::Decode(), as
its result will be the same every time. This results in a 3% speedup,
as measured by running:
testing/tools/safetynet_measure.py --profiler perfstat bug_1698.pdf,
where bug_1698.pdf is the PDF attached to https://crbug.com/pdfium/1698.
Change-Id: Ie098f96130c6c6d0a8212f0cacc886886f5bdbe3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/82714
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 2a706d8..c9d1d1a 100644
--- a/core/fxcodec/jpx/cjpx_decoder.cpp
+++ b/core/fxcodec/jpx/cjpx_decoder.cpp
@@ -536,14 +536,14 @@
uint8_t* pChannel = channel_bufs[channel];
const int adjust = adjust_comps[channel];
const opj_image_comp_t& comps = m_Image->comps[channel];
+ if (!comps.data)
+ continue;
+
if (adjust < 0) {
for (uint32_t row = 0; row < height; ++row) {
uint8_t* pScanline = pChannel + row * pitch;
for (uint32_t col = 0; col < width; ++col) {
uint8_t* pPixel = pScanline + col * m_Image->numcomps;
- if (!comps.data)
- continue;
-
int src = comps.data[row * width + col];
src += comps.sgnd ? 1 << (comps.prec - 1) : 0;
if (adjust > 0) {
@@ -558,9 +558,6 @@
uint8_t* pScanline = pChannel + row * pitch;
for (uint32_t col = 0; col < width; ++col) {
uint8_t* pPixel = pScanline + col * m_Image->numcomps;
- if (!comps.data)
- continue;
-
int src = comps.data[row * width + col];
src += comps.sgnd ? 1 << (comps.prec - 1) : 0;
if (adjust - 1 < 0) {