[Pkg-javascript-commits] [pdf.js] 29/161: Optimized bounding box tests in JBIG2's decodeBitmap
David Prévot
taffit at moszumanska.debian.org
Sat Apr 19 14:16:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit e2a4328ff26ffda170d385c58b292f5fa7df34fc
Author: p01 <p01 at opera.com>
Date: Fri Mar 7 12:12:45 2014 +0100
Optimized bounding box tests in JBIG2's decodeBitmap
---
src/core/jbig2.js | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 1110008..4cf95e5 100755
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -258,13 +258,19 @@ var Jbig2Image = (function Jbig2ImageClosure() {
changingTemplateEntries = new Uint8Array(changingTemplateEntries);
var changingEntriesLength = changingTemplateEntries.length;
+
+ // Get the safe bounding box edges from the width, height, minX, maxX, minY
+ var sbb_left = -minX;
+ var sbb_top = -minY;
+ var sbb_right = width - maxX;
+
var pseudoPixelContext = ReusedContexts[templateIndex];
var bitmap = [];
var decoder = decodingContext.decoder;
var contexts = decodingContext.contextCache.getContexts('GB');
- var ltp = 0, c, j, i0, j0, k, contextLabel = 0;
+ var ltp = 0, c, j, i0, j0, k, contextLabel = 0, bit, shift;
for (var i = 0; i < height; i++) {
if (prediction) {
var sltp = decoder.readBit(contexts, pseudoPixelContext);
@@ -283,7 +289,7 @@ var Jbig2Image = (function Jbig2ImageClosure() {
}
// Are we in the middle of a scanline, so we can reuse contextLabel
// bits?
- if (i + minY > 0 && j + minX >= 0 && j + maxX < width) {
+ if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
// If yes, we can just shift the bits that are reusable and only
// fetch the remaining ones.
contextLabel = (contextLabel << 1) & reuseMask;
@@ -296,11 +302,17 @@ var Jbig2Image = (function Jbig2ImageClosure() {
} else {
// compute the contextLabel from scratch
contextLabel = 0;
- for (k = 0; k < templateLength; k++) {
- i0 = i + templateY[k];
+ var shift = templateLength - 1;
+ for (k = 0; k < templateLength; k++, shift--) {
j0 = j + templateX[k];
- if (i0 >= 0 && j0 >= 0 && j0 < width) {
- contextLabel |= bitmap[i0][j0] << (templateLength - 1 - k);
+ if (j0 >= 0 && j0 < width) {
+ i0 = i + templateY[k];
+ if (i0 >= 0) {
+ bit = bitmap[i0][j0];
+ if (bit) {
+ contextLabel |= bit << shift;
+ }
+ }
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list