diff --git a/bower.json b/bower.json index d085ba13b..8952dd793 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.610", + "version": "1.0.612", "keywords": [ "Mozilla", "pdf", diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 9194eb5f7..288a2c15b 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.610'; -PDFJS.build = '3dce05f'; +PDFJS.version = '1.0.612'; +PDFJS.build = '669a4d1'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -41069,6 +41069,42 @@ var Jbig2Image = (function Jbig2ImageClosure() { 0x0008 // '0000' + '001000' ]; + function decodeBitmapTemplate0(width, height, decodingContext) { + var decoder = decodingContext.decoder; + var contexts = decodingContext.contextCache.getContexts('GB'); + var contextLabel, i, j, pixel, row, row1, row2, bitmap = []; + + // ...ooooo.... + // ..ooooooo... Context template for current pixel (X) + // .ooooX...... (concatenate values of 'o'-pixels to get contextLabel) + var OLD_PIXEL_MASK = 0x7BF7; // 01111 0111111 0111 + + for (i = 0; i < height; i++) { + row = bitmap[i] = new Uint8Array(width); + row1 = (i < 1) ? row : bitmap[i - 1]; + row2 = (i < 2) ? row : bitmap[i - 2]; + + // At the beginning of each row: + // Fill contextLabel with pixels that are above/right of (X) + contextLabel = (row2[0] << 13) | (row2[1] << 12) | (row2[2] << 11) | + (row1[0] << 7) | (row1[1] << 6) | (row1[2] << 5) | + (row1[3] << 4); + + for (j = 0; j < width; j++) { + row[j] = pixel = decoder.readBit(contexts, contextLabel); + + // At each pixel: Clear contextLabel pixels that are shifted + // out of the context, then add new ones. + // If j + n is out of range at the right image border, then + // the undefined value of bitmap[i - 2][j + n] is shifted to 0 + contextLabel = ((contextLabel & OLD_PIXEL_MASK) << 1) | + (row2[j + 3] << 11) | (row1[j + 4] << 4) | pixel; + } + } + + return bitmap; + } + // 6.2 Generic Region Decoding Procedure function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) { @@ -41076,6 +41112,13 @@ var Jbig2Image = (function Jbig2ImageClosure() { error('JBIG2 error: MMR encoding is not supported'); } + // Use optimized version for the most common case + if (templateIndex === 0 && !skip && !prediction && at.length === 4 && + at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && + at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) { + return decodeBitmapTemplate0(width, height, decodingContext); + } + var useskip = !!skip; var template = CodingTemplates[templateIndex].concat(at); diff --git a/build/pdf.js b/build/pdf.js index 2de1e1422..7d1e89eb3 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.610'; -PDFJS.build = '3dce05f'; +PDFJS.version = '1.0.612'; +PDFJS.build = '669a4d1'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 66689ce55..1fa43bf76 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.610'; -PDFJS.build = '3dce05f'; +PDFJS.version = '1.0.612'; +PDFJS.build = '669a4d1'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -36212,6 +36212,42 @@ var Jbig2Image = (function Jbig2ImageClosure() { 0x0008 // '0000' + '001000' ]; + function decodeBitmapTemplate0(width, height, decodingContext) { + var decoder = decodingContext.decoder; + var contexts = decodingContext.contextCache.getContexts('GB'); + var contextLabel, i, j, pixel, row, row1, row2, bitmap = []; + + // ...ooooo.... + // ..ooooooo... Context template for current pixel (X) + // .ooooX...... (concatenate values of 'o'-pixels to get contextLabel) + var OLD_PIXEL_MASK = 0x7BF7; // 01111 0111111 0111 + + for (i = 0; i < height; i++) { + row = bitmap[i] = new Uint8Array(width); + row1 = (i < 1) ? row : bitmap[i - 1]; + row2 = (i < 2) ? row : bitmap[i - 2]; + + // At the beginning of each row: + // Fill contextLabel with pixels that are above/right of (X) + contextLabel = (row2[0] << 13) | (row2[1] << 12) | (row2[2] << 11) | + (row1[0] << 7) | (row1[1] << 6) | (row1[2] << 5) | + (row1[3] << 4); + + for (j = 0; j < width; j++) { + row[j] = pixel = decoder.readBit(contexts, contextLabel); + + // At each pixel: Clear contextLabel pixels that are shifted + // out of the context, then add new ones. + // If j + n is out of range at the right image border, then + // the undefined value of bitmap[i - 2][j + n] is shifted to 0 + contextLabel = ((contextLabel & OLD_PIXEL_MASK) << 1) | + (row2[j + 3] << 11) | (row1[j + 4] << 4) | pixel; + } + } + + return bitmap; + } + // 6.2 Generic Region Decoding Procedure function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) { @@ -36219,6 +36255,13 @@ var Jbig2Image = (function Jbig2ImageClosure() { error('JBIG2 error: MMR encoding is not supported'); } + // Use optimized version for the most common case + if (templateIndex === 0 && !skip && !prediction && at.length === 4 && + at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && + at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) { + return decodeBitmapTemplate0(width, height, decodingContext); + } + var useskip = !!skip; var template = CodingTemplates[templateIndex].concat(at); diff --git a/package.json b/package.json index ccdb847c8..b41cc1207 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.610", + "version": "1.0.612", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",