summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-09 18:35:36 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-09 18:35:36 +0000
commit575ceba24463a2211e8669f8d919d3c91385d72b (patch)
treede61b2c00c95f97b9e31ff38aae113702137a9b4
parent27924e6c9d43f0eba57d14004853d5a8ba47de26 (diff)
downloadpdfium-575ceba24463a2211e8669f8d919d3c91385d72b.tar.xz
Make memory usage in CJBig2_HTRDProc::DecodeImage() O(1).
Instead of allocating an N-pixel array to store some temporary values, just use a single integer. BUG=chromium:840728 Change-Id: I7a0ff83d814eff127033f25020a7c398db3c2062 Reviewed-on: https://pdfium-review.googlesource.com/32290 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
-rw-r--r--core/fxcodec/jbig2/JBig2_HtrdProc.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
index 7d11482225..29c8118883 100644
--- a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
@@ -121,19 +121,15 @@ std::unique_ptr<CJBig2_Image> CJBig2_HTRDProc::DecodeImage(
return nullptr;
HTREG->fill(HDEFPIXEL);
- std::vector<uint32_t> GSVALS(HGW * HGH);
for (uint32_t y = 0; y < HGH; ++y) {
for (uint32_t x = 0; x < HGW; ++x) {
- for (uint8_t J = 0; J < GSPLANES.size(); ++J)
- GSVALS[y * HGW + x] |= GSPLANES[J]->getPixel(x, y) << J;
- }
- }
- for (uint32_t mg = 0; mg < HGH; ++mg) {
- for (uint32_t ng = 0; ng < HGW; ++ng) {
- int32_t x = (HGX + mg * HRY + ng * HRX) >> 8;
- int32_t y = (HGY + mg * HRX - ng * HRY) >> 8;
- uint32_t pat_index = std::min(GSVALS[mg * HGW + ng], HNUMPATS - 1);
- HTREG->ComposeFrom(x, y, (*HPATS)[pat_index].get(), HCOMBOP);
+ uint32_t gsval = 0;
+ for (uint8_t i = 0; i < GSPLANES.size(); ++i)
+ gsval |= GSPLANES[i]->getPixel(x, y) << i;
+ uint32_t pat_index = std::min(gsval, HNUMPATS - 1);
+ int32_t out_x = (HGX + y * HRY + x * HRX) >> 8;
+ int32_t out_y = (HGY + y * HRX - x * HRY) >> 8;
+ HTREG->ComposeFrom(out_x, out_y, (*HPATS)[pat_index].get(), HCOMBOP);
}
}
return HTREG;