Skip to content

Commit

Permalink
Fix mozilla#3483 and simplify readCodingpasses()
Browse files Browse the repository at this point in the history
  • Loading branch information
fkaelberer committed Apr 16, 2014
1 parent b33f4ad commit f52dfe4
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit f52dfe4

Please sign in to comment.