/* istanbul ignore next */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "../decode-stream", "../utils"], function (require, exports, decode_stream_1, utils_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfAscii85Stream = (function (_super) {
__extends(_PdfAscii85Stream, _super);
function _PdfAscii85Stream(str, maybeLength) {
var _this = this;
if (maybeLength) {
maybeLength *= 0.8;
}
_this = _super.call(this, maybeLength) || this;
_this.stream = str;
_this.input = new Uint8Array(5);
return _this;
}
_PdfAscii85Stream.prototype.readBlock = function () {
var tildaCharacter = 0x7e;
var lowerCharacter = 0x7a;
var eof = -1;
var str = this.stream;
var c = str.getByte();
while (utils_1._isWhiteSpace(c)) {
c = str.getByte();
}
if (c === eof || c === tildaCharacter) {
this.eof = true;
return;
}
var bufferLength = this.bufferLength;
var buffer;
var i;
if (c === lowerCharacter) {
buffer = this.ensureBuffer(bufferLength + 4);
for (i = 0; i < 4; ++i) {
buffer[bufferLength + i] = 0;
}
this.bufferLength += 4;
}
else {
var input = this.input;
input[0] = c;
for (i = 1; i < 5; ++i) {
c = str.getByte();
while (utils_1._isWhiteSpace(c)) {
c = str.getByte();
}
input[Number.parseInt(i.toString(), 10)] = c;
if (c === eof || c === tildaCharacter) {
break;
}
}
buffer = this.ensureBuffer(bufferLength + i - 1);
this.bufferLength += i - 1;
if (i < 5) {
for (; i < 5; ++i) {
input[Number.parseInt(i.toString(), 10)] = 0x21 + 84;
}
this.eof = true;
}
var t = 0;
for (i = 0; i < 5; ++i) {
t = t * 85 + (input[Number.parseInt(i.toString(), 10)] - 0x21);
}
for (i = 3; i >= 0; --i) {
buffer[bufferLength + i] = t & 0xff;
t >>= 8;
}
}
};
return _PdfAscii85Stream;
}(decode_stream_1._PdfDecodeStream));
exports._PdfAscii85Stream = _PdfAscii85Stream;
});
|