[Pkg-javascript-commits] [pdf.js] 19/56: Fix #3483 and simplify readCodingpasses()

David Prévot taffit at moszumanska.debian.org
Thu May 15 15:17:44 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 f52dfe4c81ab05ebd0a270c65b2c8c5426fccef7
Author: fkaelberer <o_0_o at gmx.de>
Date:   Wed Apr 16 21:40:37 2014 +0200

    Fix #3483 and simplify readCodingpasses()
---
 src/core/jpx.js | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/core/jpx.js b/src/core/jpx.js
index 6f55574..dfd80d8 100644
--- a/src/core/jpx.js
+++ b/src/core/jpx.js
@@ -135,7 +135,7 @@ var JpxImage = (function JpxImageClosure() {
       var context = {};
       try {
         var position = start;
-        while (position < end) {
+        while (position + 1 < end) {
           var code = readUint16(data, position);
           position += 2;
 
@@ -781,24 +781,22 @@ var JpxImage = (function JpxImageClosure() {
       }
     }
     function readCodingpasses() {
-      var value = readBits(1);
-      if (value === 0) {
+      if (readBits(1) === 0) {
         return 1;
       }
-      value = (value << 1) | readBits(1);
-      if (value == 0x02) {
+      if (readBits(1) === 0) {
         return 2;
       }
-      value = (value << 2) | readBits(2);
-      if (value <= 0x0E) {
-        return (value & 0x03) + 3;
+      var value = readBits(2);
+      if (value < 3) {
+        return value + 3;
       }
-      value = (value << 5) | readBits(5);
-      if (value <= 0x1FE) {
-        return (value & 0x1F) + 6;
+      value = readBits(5);
+      if (value < 31) {
+        return value + 6;
       }
-      value = (value << 7) | readBits(7);
-      return (value & 0x7F) + 37;
+      value = readBits(7);
+      return value + 37;
     }
     var tileIndex = context.currentTile.index;
     var tile = context.tiles[tileIndex];

-- 
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