UNPKG

@abasb75/jpeg-lossless-decoder

Version:
93 lines (92 loc) 3.03 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import { ScanComponent } from './scan-component'; var ScanHeader = /** @class */ (function () { function ScanHeader() { Object.defineProperty(this, "ah", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "al", { enumerable: true, configurable: true, writable: true, value: 0 }); Object.defineProperty(this, "numComp", { enumerable: true, configurable: true, writable: true, value: 0 }); // Number of components in the scan Object.defineProperty(this, "selection", { enumerable: true, configurable: true, writable: true, value: 0 }); // Start of spectral or predictor selection Object.defineProperty(this, "spectralEnd", { enumerable: true, configurable: true, writable: true, value: 0 }); // End of spectral selection Object.defineProperty(this, "components", { enumerable: true, configurable: true, writable: true, value: [] }); } Object.defineProperty(ScanHeader.prototype, "read", { enumerable: false, configurable: true, writable: true, value: function (data) { var count = 0; var i; var temp; var length = data.get16(); count += 2; this.numComp = data.get8(); count += 1; for (i = 0; i < this.numComp; i += 1) { this.components[i] = __assign({}, ScanComponent); if (count > length) { throw new Error('ERROR: scan header format error'); } this.components[i].scanCompSel = data.get8(); count += 1; temp = data.get8(); count += 1; this.components[i].dcTabSel = temp >> 4; this.components[i].acTabSel = temp & 0x0f; } this.selection = data.get8(); count += 1; this.spectralEnd = data.get8(); count += 1; temp = data.get8(); this.ah = temp >> 4; this.al = temp & 0x0f; count += 1; if (count !== length) { throw new Error('ERROR: scan header format error [count!=Ns]'); } return 1; } }); return ScanHeader; }()); export { ScanHeader };